Windows Persistent SOLVED

Chaser

Member
hi, any ideas why a persistant object is not being 'carried over' to the next/new room, its object properties are checked as persistent and there are no other codes within the object, such as game_start etc, like it explains in the help section.

object(with persistent checked) collides with object, room_goto(new/next room). go's to new/next room but persistent object does not appear. strange?

would appreciate any ideas here as i'm baffled. :)
 

curato

Member
so there is no code in the object at all. If there is post it . If not, how do you know it isn't carried over? What does the object do?
 

samspade

Member
hi, any ideas why a persistant object is not being 'carried over' to the next/new room, its object properties are checked as persistent and there are no other codes within the object, such as game_start etc, like it explains in the help section.

object(with persistent checked) collides with object, room_goto(new/next room). go's to new/next room but persistent object does not appear. strange?

would appreciate any ideas here as i'm baffled. :)
This is a probably which can be easily checked with the debugger. Run the game in the debugger and after transferring rooms either pause the debugger or turn on the real time debugging and look for the instance to see if it is there. You can also then check other values. If you're unfamiliar with the debugger here are two tutorials:

Written Tutorial

 

Chaser

Member
there is code in the object, but not code such as Game Start, Game End, Room Start and Room End . It's my player object. I didn't think you were allowed to just post code. OK, il have a go.
create event:
grav = 1;
depth = 0;
behaviour = behaviour.P1_idle;
combo = 0;
playerhealth = 100;
playerlife = 3;
/// level timer
global.time = 300;

step event:
/// call control script
/// Players behaviour ingame and runs those scripts
switch(behaviour)
{
case behaviour.P1_idle: scr_P1_idle(); break;
case behaviour.P1_walk: scr_P1_walk(); break;
case behaviour.P1_jump: scr_P1_jump(); break;
case behaviour.P1_uppercut: scr_P1_uppercut(); break;
case behaviour.P1_fall: scr_P1_fall(); break;
case behaviour.P1_pause: scr_P1_pause(); break;
case behaviour.P1_death: scr_P1_death(); break;
case behaviour.P1_run: scr_P1_run(); break;
case behaviour.P1_punch_light: scr_P1_punch_light(); break;
case behaviour.P1_punch_hard: scr_P1_punch_hard(); break;
case behaviour.P1_kick_light: scr_P1_kick_light(); break;
case behaviour.P1_kick_hard: scr_P1_kick_hard(); break;
case behaviour.P1_jump_movekick: scr_P1_jump_movekick(); break;
case behaviour.P1_hurt: scr_P1_hurt(); break;
case behaviour.P1_hurt_knockdown: scr_P1_hurt_knockdown(); break;
case behaviour.P1_pickup: scr_P1_pickup(); break;
case behaviour.P1_climb: scr_P1_climb(); break;
case behaviour.P1_tazer_jab: scr_P1_tazer_jab(); break;
case behaviour.P1_noinput: scr_player_noinput(); break;
case behaviour.P1_newlife: scr_P1_newlife(); break;
case behaviour.P1_place: scr_P1_place(); break;

}

/// Collision detections & actions
scr_P1_Wall_collisions();
scr_attack_status();

collision event: (obj_checkpoint)
room_goto(rm_market_street_checkpoint);
 

curato

Member
just a rough guess is that is may be carrying over, but you are using it as a in level object and it is in the wrong position somewhere on your level instead of where you want it.
 

Chaser

Member
yeah, i was thinking that, i used x = Player_1.x, y = Player_1.y in the step event to see if that worked but that didn't work. i did try the debugger, according to that, the player instance is not in the level so it isn't being carried over. i'l keep trying some other ideas, but i'm fast running out. :)
 
H

Homunculus

Guest
You could try running a show_debug_message in the room_start event of the object. If it's there, you'll see the message in the output window.
 

kburkhart84

Firehammer Games
Indeed, if you run in debug mode it can very clearly show what all instances are in the room at the time. If it really is going missing and you can prove it, then try going to a different room, even an empty room, and see if it disappears. If it does not, then it points to something in that new room destroying it. If it disappears in ANY room that you move it to, then there has to be some code running somewhere, that is either disabling the persistent variable, or destroying the object.
 

samspade

Member
yeah, i was thinking that, i used x = Player_1.x, y = Player_1.y in the step event to see if that worked but that didn't work. i did try the debugger, according to that, the player instance is not in the level so it isn't being carried over. i'l keep trying some other ideas, but i'm fast running out. :)
If you check the built in variables you can see where its x and y is.
 

Chaser

Member
right OK, the first room the player is in is 1200 wide, so when you get to the end you hit the object then move to the new room which is only 256 wide, so when moving to the next room the players x value remains at 1200(or nearest point to the collision), so it's in the room, and exactly where it should be when persistent is concerned. i'm not taking into account the room size when moving rooms and updating the x value accordingly. :) sorry everyone, but i do appreciate the help, it would of took me a while for my cogs in my brain to turn for me to figure that out, thanks to your help i got there in the end. awesome. :)
 

kburkhart84

Firehammer Games
oh wait,the debugger says it is in the room. But god knows where. :)
I figured that was the case...as the guy above said, feel free to use that debugger to figure out where. Generally, it would be in the same place it was in the other room.

That said, I generally don't like using persistent objects except as controller objects. Player objects, etc... I like to keep non-persistent. Then those objects only need to read global state from either global variables or the controller object that is persistent. Then, if you only can enter that next room in one place, you set the player in the right spot using a different instance that belongs to that room. If you are doing something like a Metroidvania where you could enter from different rooms, then you can simply set a variable saying what room you are in just before going to the next room, and then have a controller in the next room that checks where you came from and positions the player accordingly.

There is a good though that it is best to make objects limit what they do. The object for the player for example should really only control the player itself, not any state variables like lives, etc... My above advice comes from my thoughts on following that paradigm.
 
Top