• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Random problem appeared

N

nlolotte

Guest
So it was working fine but now its stopped when I press enter to go to inventory I can then not press enter to go back to the main room? Please can someone help me as to why this has randomly stopped working. Is it because the player object is persistent?
Information about object: par_player
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: true
Parent:
Children
obj_player
Mask:
No Physics Object
Key Press Event for <Enter> Key:
execute code:

global.roomcamefrom = room ;
global.playerx = x
global.playery = y
room_goto(rm_inventory);

Information about object: obj_inventory_controller
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Draw Event:
execute code:

draw_text(365,y+64,"-DESCRIPTION-");

var i;
draw_text(350,y+96,global.inventory[global.cursor_pos-1,1]);


Key Press Event for <Enter> Key:
execute code:

room_goto( global.roomcamefrom );
obj_player.x = global.playerx
obj_player.y =global.playery
 

Llama_Code

Member
If your player object is persistent, then you are carrying it in to the inventory room with you which means BOTH objects are going to run their enter action, the player is probably running first thus setting global.roomcamefrom to the current room - the inventory room.
 
N

nlolotte

Guest
how can i resolve this without changing obj_player's persistence
 

Llama_Code

Member
You can use an if statement on the player object to not execute the enter action if your in the inventory room...

if (room != rm_inventory)
{
global.roomcamefrom = room ;
global.playerx = x
global.playery = y
room_goto(rm_inventory);
}
 
Top