Examples
Player: {
trapped: false
Event: Enter_Room {
// If player enters either trapRoom1 or trapRoom2, trapped property of player is set to true
if (currentRoom() == trapRoom1 || currentRoom() == trapRoom2){
trapped = true
display("You have stepped into a trap!")
}
}
Event: Leave_Room {
if (trapped){
// If player is trapped, rolls a random number between 1 and 6.
// If number is greater than 4, player manages to escape the trap
if (rand(1,6) > 4){
trapped = false
display("You managed to free yourself from the trap!")
}
// If player is still trapped,
// moves player back before entering the room which player was moving towards
if (trapped)
moveTo(currentRoom())
}
}
}