Scripting issues

Redd00
26 Dec 2018, 12:46

Uh i got a little bit confused. I want to use a boolean data like for example, setting player's power to true. But i didnt see any options to do that. I found an alternative to this that is by using flag. Is there a difference between flag and boolean and how do i use boolean?


hegemonkhan
26 Dec 2018, 14:09

(filler for getting my edited post, updated/posted)


For quest, a 'flag' is a Boolean Data Type

A Boolean Data Type is data that is only either: 'true' or 'false'

(Dualism Data: Opposite/Binary Data, and for Booleans: specifically using 'true' and 'false')

A Boolean VARIABLE is a variable that holds either 'true' or 'false' Boolean Data

VARIABLE = true
VARIABLE = false

here's some examples of Boolean Attribute VARIABLES:

NAME_OF_OBJECT.NAME_OF_BOOLEAN_ATTRIBUTE = VALUE_OR_EXPRESSION

game.paused = true
game.paused = false
player.flying = true
player.flying = false
player.poisoned = true
player.poisoned = false
tv.switchedon = false
tv.switchedon = true

orc.dead = true // conceptually: orc is dead
orc.alive - false // conceptually: orc is dead

orc.dead = false // conceptually: orc is alive
orc.alive = true // conceptually: orc is alive


Truth Tables / Logic Gates / Boolean Algebra / Symbolic Logic:

https://en.wikipedia.org/wiki/Truth_table
https://en.wikipedia.org/wiki/Logic_gate
https://en.wikipedia.org/wiki/Boolean_algebra
https://philosophy.lander.edu/logic/symbolic.html

Definition Logic:

true -> TRUE
false -> FALSE

Negation ('not') Logic:

not true -> FALSE
not false -> TRUE

Conjunction ('and') Logic:

true and true -> TRUE
true and false -> FALSE
false and true -> FALSE
false and false -> FALSE

Disjunction ('or') Logic:

true or true -> TRUE
true or false -> TRUE
false or true -> TRUE
false or false -> FALSE


in the GUI-Editor (what you're using with all of the controls/options, tabs, buttons, drop-down menus, boxes, etc):

for Game Book:

'WHATEVER' Page -> 'Page' Tab -> Page Type: [script] or [script + text] -> (see below)

add new script -> 'variables' section/category -> 'set a variable or an attribute' Script -> (see below, examples)

set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] VALUE_OR_EXPRESSION

set variable game.paused = [EXPRESSION] true
set variable game.paused = [EXPRESSION] false
set variable player.flying = [EXPRESSION] true
set variable player.flying = [EXPRESSION] false
set variable player.poisoned = [EXPRESSION] true
set variable player.poisoned = [EXPRESSION] false
set variable orc.dead = [EXPRESSION] true
set variable orc.dead = [EXPRESSION] false
set variable tv.switchedon = [EXPRESSION] true
set variable tv.switchedon = [EXPRESSION] false

an in-code example of Conjunction ('and') Logic:

player.currency_integer_attribute = 0

create ("utility_object")

utility_object.boolean_stringlist_attribute = NewStringList ()
list add (utility_object.boolean_stringlist_attribute, "true")
list add (utility_object.boolean_stringlist_attribute, "false")

// -----------------------------------------

player.room_cleaned_boolean_attribute = StringListItem (utility_object.boolean_stringlist_attribute, GetRandomInt (0, ListCount (utility_object.boolean_stringlist_attribute) - 1))

// player.room_cleaned_boolean_attribute = [random: true/false]

player.mowed_lawn_boolean_attribute = StringListItem (utility_object.boolean_stringlist_attribute, GetRandomInt (0, ListCount (utility_object.boolean_stringlist_attribute) - 1))

// player.room_cleaned_boolean_attribute = [random: true/false]

if (player.cleaned_room_boolean_attribute and player.mowed_lawn_boolean_attribute) {
  player.currency_integer_attribute = player.currency_integer_attribute + 5
  msg ("You did your chores, so you get $5")
}
else if (player.cleaned_room_boolean_attribute) {
  msg ("While you cleaned your room, you still got to mow the lawn, before you can get $5")
}
else if (player.mowed_lawn_boolean_attribute) {
  msg ("While you mowed the lawn, you still got to clean your room, before you can get $5")
}
else {
  msg ("You've not done either of your chores, you still got to clean your room and mow the lawn, before you can get $5")
}