How do I add gems to a gamebook?


Why is something so simple and so common so impenetrable? The most successful interactive fiction seems to be gamebooks, but, for the life of me, I can't find decent documentation on how to make them.

Just gems. The player gets, for example, 120 gems at the start and the page says, "You have [number of gems] gems.", so it says "You have 120 gems.". If the game had added 3 gems, the page would say, "You have 123 gems.". This is what I'm trying to make happen.

How do I add something like coins or gems to a gamebook? Not a text adventure Not an object in a room; it's a gamebook. I tried setting the counter, but it didn't work. The page just defaulted to 0 gems. to a gamebook, in quest? Please can someone explain to me how to do this?

Thank you.


unfortunately, most use Text Adventures as it has the full programming capability, so there's little documentation of using Game Books.

to do stuff with Game Books requires scripting, which is done via:

'whatever' Page Object -> 'Page' Tab -> Page Type: [SCRIPT] or [SCRIPT+TEXT] -> (see below)

add new script -> (choose your script, more details below)

so, use your first page to add/create all the Attributes and their initial Values, you want to be in your game, which is done via the 'set variable or attribute' Script:

'YOUR_FIRST_PAGE' Page Object -> 'Page' Tab -> 'Page Type: [SCRIPT] or [SCRIPT+TEXT] -> (see below)

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


replace my 'NAME_OF_OBJECT' with either (you ONLY have two choices in/for/with the Game Book):


for example:


next, replace my 'NAME_OF_ATTRIBUTE' with whatever you want as the name of whatever the Attribute you want to create/add (quest knows the type of Attribute from the Value you give it, my 'VALUE_OR_EXPRESSION' part), for example (I like being descriptive with my names, so I add the '_integer_attribute' to it's name, but you can just do 'strength', just remember that all names must be unique, as the 'name' String Attribute is the ID for quest):

set variable player.strength_integer_attribute = [EXPRESSION] VALUE_OR_EXPRESSION

last, we need to give it a Value, which can be a simple Value or a complex Expression, for this example, we're going to give it a simple Value of '0' (zero), as this is it's starting/initial value, so replace my 'VALUE_OR_EXPRESISON' with '0', see below:

set variable player.strength_integer_attribute = [EXPRESSION] 0

(the Value of '0' is what tells quest that this is an Integer Value and thus the Attribute is an Integer Attribute)

(my own personal naming system/convention of 'xxx_integer_attribute' has nothing at all to do with what type of Attribute it is, only the Value does. If we gave the Attribute the value of 'true' or 'false', then the Attribute would be a Boolean Attribute, for example: set variable game.orc_dead = [EXPRESSION] false, our simulated 'orc object' starts off not dead, it starts out alive. And when we want the orc to be dead, we'd change/re-set it's Value to being 'true', set variable game.orc_dead = [EXPRESSION] true, and there's other types of Attributes as well, such as Strings, Lists, and Dictionaries. Not sure if the Game Book supports Object reference Attributes and Objectlist Attribute or not, as you are limited to only the 'game' Game Object, 'player' Player Object, and the Page Objects)

so, now when the game begins, the first page will create/add/put/give our 'strength_integer_attribute = 0' onto our 'player' Player Object

we can now use this Attribute (player.strength_integer_attribute), as much as we want, and where-ever/when-ever we want, for example, we can have a page for showing our character's stats:

'YOUR_CHARACTER_STAT_SCREEN' Page Object -> 'Page' Tab -> 'Page Type: [SCRIPT] or [SCRIPT+TEXT] -> (see below)

add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "Strength: " + player.strength_integer_attribute
// outputs/displays (currently in this example progression):
// Strength: 0

now, what about adjusting/changing our 'player.strength_integer_attribute' Integer Attribute ???

well, where/when ever you want it to happen, let's say on page 2:

'YOUR_PAGE_2' Page Object -> 'Page' Tab -> 'Page Type: [SCRIPT] or [SCRIPT+TEXT] -> (see below)

add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [MESSAGE] You find and drink a strength potion, increasing your strength by five.

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

set variable player.strength_integer_attribute = [EXPRESSION] player.strength_integer_attribute + 5

and now, if you were to go back to your 'YOUR_CHARACTER_STAT_SCREEN' page, it'll now show/display your new strength:

Strength: 5

for greater detail, here's a link (it's for Text Adventures, but the scripting itself is the same for Text Adventures and Game Book, but the location/access to the scripting is different, and the Game Book doesn't have the non-scripting 'Attribute -> Add' capability that the Text Adventure has, nor does the Game Book have unlimited and custom Objects like the Text Adventure does, of course):

you can also look here:
and more (search through the pages of the 'ifansswers' link above)

as for output/display/messaging formatting, you can use 'concatenation', and maybe also the 'text processor commands', see here:

for example:

print [EXPRESSION] "You have {player.strength_integer_attribute} strength."

or, using concatenation: (the 'msg' Script in coding is your 'print a message -> print [EXPRESSION]' Script in the GUI/Editor)

print [EXPRESSION] "You have " + player.strength_integer_attribute + " strength."

with 'printing a message' Script:

the [MESSAGE] option is for just text/string only:

print [MESSAGE] Hi, my name is HK, what is your name? Ah, nice to meet you, my strength is 100, what is your strength? ah, it's 40, you got to get stronger to challenge me to a fight.

print [MESSAGE] You have 70 strength.

the [EXPRESSION] option is for VARIABLES and/or Text/String:

// just a VARIABLE (an Attribute / an Attribute VARIABLE):
print [EXPRESSION] player.strength_integer_attribute
// output of let's say/pretend that it's 70:
// 70

// just text/string (same as the [MESSAGE] option, except you do need to have it within double quotes this time, as you got to tell quest that it is a string/text via the double quotes, whereas the [MESSAGE] option does that for you, so you don't need the double quotes):

print [EXPRESSION] "You have 70 strength."
// output:
// You have 70 strength.

// VARIABLE+ Text/String:

print [EXPRESSION] "You have " + player.strength_integer_attribute + " strength."
// pretend (70=strength) output:
// You have 70 strength.

// VARIABLE+ Text/String:

print [EXPRESSION] "Strength: " + player.strength_integer_attribute
// pretend (70=strength) output:
// Strength: 70

print [EXPRESSION] player.strength_integer_attribute + " strength"
// pretend (70=strength) output:
// 70 strength

the [EXPRESSION] option let's you type/program/code in what you want, whether it's for a 'print a message' Script or 'set a variable or attribute' Script (which I use the [EXPRESSION] option as a way to "cheat" around not knowing the GUI/Editor's script options, lol, when I'm helping people on this stuff, laughs) or the 'if' Script. Otherwise, if you know the GUI/Editor's script options choose them instead of using the [EXPRESSION] option. However, there's some things that aren't GUI/Editor Script options, and so you have to use the [EXPRESSION] option. For example, in the GUI/Editor's script options you got the 'IncreaseObjectCounter', which increases an Integer Attribute by 1, but what if you want to increase it by 5 instead? You can't unless you use the [EXPRESSION] option and code/type it in yourself (which I've shown/done in this post example of mine). What if you don't want to use addition but muliplication? you can't unless you use the [EXPRESSION] option:

set variable player.strength_integer_attribute = [EXPRESSION] player.strength_integer_attribute * 3

same with the 'DecreaseObjectCounter', it ONLY subtracts by 1, so if you want to do a different value, you got to use the [EXPRESSION] option:

set variable player.strength_integer_attribute = [EXPRESSION] player.strength_integer_attribute - 3

and also, if you want to do division instead:

set variable player.strength_integer_attribute = [EXPRESSION] player.strength_integer_attribute / 7

IncreaseObjectCounter (player, "strength_integer_attribute") // I believe this is how the 'IncreaseObjectCounter' GUI/Editor Script option is/looks in code, and in the GUI/Editor, it's something like this I believe: IncreaseObjectCounter: [OBJECT] player [ATTRIBUTE/VALUE] strength_integer_attribute

is the exact same thing as the GUI/Editor's scripting (using the [EXPRESSION] option):

set variable player.strength_integer_attribute = [EXPRESSION] player.strength_integer_attribute + 1

and also this directly in code is the exact same thing as well:

player.strength_integer_attribute = player.strength_integer_attribute + 1

This topic is now closed. Topics are closed after 60 days of inactivity.