Gamebook Commands

Convenient_Cultist
25 Feb 2017, 19:08Hi,
I was wondering if there is a way to only display a text if the player had chosen a certain answer a few pages before.
Or do I have to put the decision whether the text will displayed on the same page as the text that will/ will not be displayed?
Confusing stuff.
hegemonkhan
25 Feb 2017, 23:24You need a record, an 'indicator/flag/state', for determining what happens, which are VARIABLES, and in quest are known as Attributes (global/"permanent" VARIABLES --- so long as the Object containing/holding them exists/still exists of course).
for an example of Attributes and the 'if' Script in action:
some earlier Page:
test.score = 76 // or whatever Value that you have getting determined for it
some later Page:
if (test.score >= 90) {
test.grade = "A"
} else if (test.score >= 80) {
test.grade = "B"
} else if (test.score >= 70) {
test.grade = "C"
} else if (test.score >= 60) {
test.grade = "D"
} else {
test.grade = "F"
}
// result: test.grade = "C"
// -------------------------------------
some earlier Page:
test.score = 43 // let's say that inside of 76 like above, you've got 43 determined as the Value instead
some later Page:
if (test.score >= 90) {
test.grade = "A"
} else if (test.score >= 80) {
test.grade = "B"
} else if (test.score >= 70) {
test.grade = "C"
} else if (test.score >= 60) {
test.grade = "D"
} else {
test.grade = "F"
}
// result: test.grade = "F"
so, to do scripting:
'WHATEVER' Page Object -> 'Page' Tab -> Page Type: [SCRIPT] or [SCRIPT+TEXT] -> (see below)
Attribute scripting (creation/adding/setting, including of their initial Values, and/or manipulation/changing/altering/re-setting of their Values):
add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)
set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] VALUE_OR_EXPRESSION
now, unlike the Text Adventure, the Game Book, only has two Objects for holding your own (custom) Attributes:
- the 'player' Player Object
- the 'game' Game Settings Object
so, for examples:
set variable player.strength = [EXPRESSION] 100
set variable player.alias = [EXPRESSION] "HK"
set variable game.state = [EXPRESSION] 0
set variable game.hard_mode = [EXPRESSION] false
however, you can still create the effect of other Objects:
set variable game.orc_1_strength = [EXPRESSION] 100
set variable game.orc_1_life = [EXPRESSION] 500
set variable game.orc_2_strength = [EXPRESSION] 40
set variable game.orc_2_life = [EXPRESSION] 200
you can use 'player' Player Object too, but it doesn't make logical sense (this doesn't matter at all for the computer, it'll work fine, but it's a bit jarring for a human to read/think-about), lol:
set variable player.orc_1_strength = [EXPRESSION] 500
and for the 'if' Scripting:
add new script -> 'Scripts' section/category -> 'if' Script -> (see below)
if [EXPRESSION] NAME_OF_OBJECT.NAME_OF_ATTRIBUTE // if (TRUE), for Boolean Attributes only
or
if [EXPRESSION] NAME_OF_OBJECT.NAME_OF_ATTRIBUTE OPERATOR VALUE_OR_EXPRESSION
and, there's also Negation ('not'):
if [EXPRESSION] not NAME_OF_OBJECT.NAME_OF_ATTRIBUTE // if (not TRUE), for Boolean Attributes only
or
if [EXPRESSION] not NAME_OF_OBJECT.NAME_OF_ATTRIBUTE OPERATOR VALUE_OR_EXPRESSION
or
if [EXPRESSION] NAME_OF_OBJECT.NAME_OF_ATTRIBUTE <> VALUE_OR_EXPRESSION