"If" Script Help --> Gamebook
PhilMakesGames
22 Oct 2016, 16:26So here's my dilemma:
The player can either go directly to an elevator, or pull a fire alarm, and THEN go to the elevator.
Basically, if you skip the fire alarm, you just go up the elevator.
But if you turn on the alarm, a guy will enter the elevator with you. So how would I use a script to both add text to the elevator page (stating that someone entered) AND add a link to the new page with his dialogue (which isn't present unless you use the alarm)
hegemonkhan
23 Oct 2016, 19:45something like this (it's an in-code example):
// I'm not sure if you can do 'get input' or 'show menu' in the Game Book, but for this example, pretend we can, lol
// 'whatever' Page's scripting ( Page Type: [script] or [script+text] ):
msg ("Go to elevator (1) or pull the fire alarm (2)")
get input {
if (result = "1") {
msg ("You go to the elevator")
player.parent = elevator
game.choice_X = true
} else if (result = "2") {
msg ("You pull the fire alarm and then go to the elevator")
player.parent = elevator
game.choice_X = false
} else {
msg ("You made the wrong choice, resulting in you getting burned up in the fire!")
msg ("GAME OVER")
finish // not sure if the Game Book has this Script/Function or not..
}
}
<page name="elevator">
// I think this is (one way at least in) how it's done with the Game Book's 'page' Objects:
<script>
if (game.choice_x) {
msg ("You enter the elevator alone.")
} else {
msg ("As you enter the elevator, you here someone yelling to wait, which you do, with him rushing inside the elevator with you.")
}
</script>
</page>