How to make a counter in a Gamebook?

To put it simply, I want to make a counter that adds +1 each time the player goes to a new page. When that counter reaches 50, I want the player to be taken to a specific page that they couldn't access before. My only problem is I don't really know coding that well and I'm still new to Quest. I managed to setup a script for the counter to take the player to the page, but getting the counter to work is more tricky.


game.counter=game.counter+1
if(game.counter=>49) {
( show new page link)
}


programming has the Assignment operation, so conceptually this is how it works, an example:

the '=' assignment operation/operator means its storing the final (if there's calculations) value on its right side into the VARIABLE on its left side:

VARIABLE = VALUE_OR_EXPRESSION

// VARIABLE <=== FINAL_VALUE <=== VALUE_OR_EXPRESSION

// initial/starting player stat value:
player.strength = 0

player.strength = player.strength + 5

// player.strength (new) = player.strength (old: 0) + 5
// player.strength (new) = (0) + 5
// player.strength (new) = 5

// new player stat value: player.strength = 5

// old player stat value: player.strength = 5

// player.strength (new) = player.strength (old: 5) + 5
// player.strength (new) = (5) + 5
// player.strength (new) = 10

// new player stat value: player.strength = 10

// old player stat value: player.strength = 10

// player.strength (new) = player.strength (old: 10) + 5
// player.strength (new) = (10) + 5
// player.strength (new) = 15

// new player stat value: player.strength = 15


the 'counter' usage in the GUI/EDitor means it is doing addition by only 1, if you want to do the other arithmetic operations and/or by a different value, than you can't use the 'counter' method in the GUI/Editor, you got to do the scripting yourself:

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

set variable VARIABLE = [EXPRESSION] VALUE_OR_EXPRESSION

examples:

set variable player.strength = [EXPRESSION] 0

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

// create ("katana")
// katana.damage = 50
// player.weapon = katana
// player.strength = 100
set variable player.damage = [EXPRESSION] player.weapon.damage + player.weapon.damage * player.strength / 100


Arithmetic Operations (simple ones, can be more complex, of course, see above section's examples, for the GUI/Editor's scripting format, as it's a bit different from the directly in-code scripting examples below):

Addition: +

player.strength = player.strength + 9

Subtraction: -

player.strength = player.strength - 6

Multiplication: *

player.strength = player.strength * 3

Division: /

player.strength = player.strength / 2

Modulus (division, but it gets/returns/finds the REMAINDER): %

player.strength = player.strength % 10


I'm sorry but neither of these have helped. I need to know the function of adding +1 to the counter each time the person moves to a new page. The second answer is excessively confusing.


I know text adventure better than gamebook... so...
In the UI, there is a folder icon called "game".
I think this will increment the counter on each page you enter...

OK. figured it out...
add this code to the game folder:
firsttime {
game.c = 0
}
otherwise {
game.c = game.c+1
}

Now... do you know how to make an exit visible???


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

Support

Forums