A
arirish
Guest
I am maybe a third to a halfway done with level layouts for my game and I've hit a snag. I added a new element in the current set of rooms - a sort of basic puzzle - which, if the player does something wrong, can make the room impassable. So I thought to add another object which, when interacted with, would restart the current room. However, I've quickly discovered it's not going to be that simple.
I tried this simple bit of code (using a key press event for now, for testing purposes):
And in my control object's Room Start event I added:
And that all works fine. Enemies and items respawn, and my player returns to the start of the room. I thought I had it fixed, until I collected an object and then restarted the room. The object remains in my inventory as well as respawning in the room, and any benefits it confer (ie variables changed) remain conferred.
So, what I need to figure out is how - without manually recording the state of all variables one by one on room start - to make sure this doesn't happen. A way to reset the room - and the character and variables - to how they were when they entered the room. Right now the only way I can see is to do similar to I did with x and y positions, and save them all on room start, but there are quite a lot and it could easily get very messy.
I tried this simple bit of code (using a key press event for now, for testing purposes):
Code:
room_persistent=false
room_restart();
obj.x=startx
obj.y=starty
Code:
room_persistent=false
startx=obj.x
starty=obj.y
So, what I need to figure out is how - without manually recording the state of all variables one by one on room start - to make sure this doesn't happen. A way to reset the room - and the character and variables - to how they were when they entered the room. Right now the only way I can see is to do similar to I did with x and y positions, and save them all on room start, but there are quite a lot and it could easily get very messy.