So I got a bit stuck because of my limited knowledge of both SugarCube and JavaScript. I manage to create a dungeon with 20 seperate passages (rooms) and added a custom macro that puts you randomly in one of those passages each time you move through the door. I've also created a basic turn based combat system using few different passages for player turn/enemy turn, using magic, items and death. The way it works is that there's a set chance for enemy to appear each time player enters a new random room and then he's moved to combat passages.
Now, the problem I have. When the battle ends (with player still alive) the player should be moved back to the exact same room he got attacked. For example, he enters the dungeon and custom macro puts him in the room 9. Then he moves through the door and, again, custom macro puts him in, let's say, room 14 where he gets attacked. He's moved to the combat passages. He defeats his enemy and after the firght he should be moved back to the exact same room, which in this case is room 14. Problem is that the fight can start in each one of those 20 rooms and I want the player to always get back to the same room he got attacked in.
Is there any way, through maybe somehow saving the passage where the fight starts, to set it in a way that will always move the player to the same room he got attacked in?
I'd appreciate any kind of help.
Now, the problem I have. When the battle ends (with player still alive) the player should be moved back to the exact same room he got attacked. For example, he enters the dungeon and custom macro puts him in the room 9. Then he moves through the door and, again, custom macro puts him in, let's say, room 14 where he gets attacked. He's moved to the combat passages. He defeats his enemy and after the firght he should be moved back to the exact same room, which in this case is room 14. Problem is that the fight can start in each one of those 20 rooms and I want the player to always get back to the same room he got attacked in.
Is there any way, through maybe somehow saving the passage where the fight starts, to set it in a way that will always move the player to the same room he got attacked in?
I'd appreciate any kind of help.