Gamebook - Flags/Booleans
Elsis77
18 Jun 2017, 02:40Hello! I recently started using the Gamebook mode instead of the text adventures mode since gamebook is more suited for my type of game.
Creating flags and ifs for text adventure mode is really simple for me but I don't get how to implement flags and ifs in the gamebook mode.
Can somebody please explain it to me and give me some examples? I don't get the examples in the text processor help page. Thanks in advance!
major powers
18 Jun 2017, 03:09Not sure of your level of understanding (I'm not one to be teaching), so just starting from scratch:
Change your page to "Script + Text":
http://i.imgur.com/s8LARH2.png
Next, change to code view, and enter a flag, name it whatever you want:
http://i.imgur.com/xb2RS0U.png
Then, when you want to reference it, be all like this (names changes, but use all the "if GetBoolean" shit for real)
http://imgur.com/RB9JQve
IF on the other hand you want to see it in non-code but graphical user interface view, let me know!!!
"GUI" view example:
http://imgur.com/0qZDT56

Elsis77
18 Jun 2017, 03:16Thank you for your reply! I'm a beginner with Gamebook, however, how do I change it to Script + Text on a browser? Thanks again!
major powers
18 Jun 2017, 03:20Click the Page Type drop down menu!
http://i.imgur.com/s8LARH2.png
(are you on a PC?)

Elsis77
18 Jun 2017, 03:24IM ON A MAC BUT I FOUND IT IM SOOOO HAPPYYYY
THANK YOU SO MUCH !!!
hegemonkhan
18 Jun 2017, 05:10already explained by Major powers, but just to add in my own commentary on it:
the Game Book is limited to scripting for creating Attributes:
'NAME_OF_USUALLY_YOUR_STARTING_PAGE' Page -> 'Page' Tab -> Page Type: [script] or [text+script]
(the adding of scripts should be the same as it is in Text Adventures, see line below)
add new script -> 'WHATEVER' category/section -> 'WHATEVER' Script
'flags' (in the unfortunate common use of the word) are just Boolean Attributes (having only two states/values of: true/false), for example:
game.orc_dead = false // GUi/Editor: add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> set variable game.orc_dead = [EXPRESSION] false
or
game.orc_dead = true // GUi/Editor: add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> set variable game.orc_dead = [EXPRESSION] true
add new script -> 'scripts' section/category -> 'if' Script -> if [EXPRESSION] game.orc_dead
-> then, -> add new script -> 'output' section/category -> 'print a message' Script -> print [MESSAGE] The orc is dead
else,
-> add new script -> 'output' section/category -> 'print a message' Script -> print [MESSAGE] The orc is alive
the '[MESSAGE]' script option is for only displaying TEXT. You do NOT have your TEXT in double quotes, unless you want the double quotes to be displayed, such as conveying someone is speaking: print [MESSAGE] You walk up to the male npc, and greet him, "Hi, my name is HK, what is your name?", you smile and wait for his answer. // output: You walk up to the male npc, and greet him, "Hi, my name is HK, what is your name?", you smile and wait for his answer.
the '[EXPRESSION]' script option is for being able to code in whatever you want to do yourself, which includes the displayment (for the 'msg / print a message' Script) of VARIABLES or VARIABLES+TEXT or TEXT. When you use the '[EXPRESSION]' with the 'msg / print a message' Script, your TEXT parts need to be within double quotes.
if (game.orc_dead) { // with Booleans, this short-hand form is understood as: if (game.orc_dead = true)
msg ("The orc is dead")
} else { // effectively: if (not game.orc_dead) // which is short-form for: if (not game.orc_dead = true) // or: if (game.orc_dead = false) // or: if (game.orc_dead <> true)
msg ("The orc is alive")
}
I don't know the GUI/Editor and its script options that well, so that's why I 'cheat' and use the '[EXPRESSION]' script option, which lets me type/code in what I want, but I'm sure there's the specific GUI/Editor scripts and script options for doing all of this stuff, but I just don't know them very well.
Also, you can do what Major Powers does, and use (via 'call function' Script) Functions, such as the helper (and more powerful/useful) Function 'GetBoolean(NAME_OF_OBJECT.NAME_OF_BOOLEAN_ATTRIBUTE)', for example:
peudo code-GUI/Editor scripting:
if (GetBoolean (NAME_OF_OBJECT, "NAME_OF_ATTRIBUTE")) { // maybe it's something like this with the scripting options: if [?????????] [object] NAME_OF_OBJECT [text] NAME_OF_ATTRIBUTE
-> then, -> msg ("The Boolean Attribute's Value is: true")
} else {
-> msg ("The Boolean Attribute's Value is: false")
}
or as I would do for its usage in/with the 'if' Script (is to use the [EXPRESSION] script option), peudo code-GUI/Editor scripting:
if [EXPRESSION] NAME_OF_OBJECT.NAME_OF_BOOLEAN_ATTRIBUTE
-> then, -> msg ("The Boolean Attribute's Value is: true")
else,
-> msg ("The Boolean Attribute's Value is: false")
}