I can't get counters to increase in my gamebook

I have a gamebook I'm working on where there's a counter called time. I have a room where entering it when time=1 gives you one thing and time being greater than 1 giving you another thing but I can only seem to get the time=1 result when I enter the room multiple times after using an increase counter script. Are counters broken or am I missing something. I use the GUI editor so GUI solutions would be much more helpful.


I just noticed it double posted on me because I double clicked, whoops


If you are setting the time counter when you enter the room:
time=1
then time will always be =1
To count, it needs to be time=time +1


make sure that your 'time' counter (Integer) VARIABLE is an Attribute VARIABLE:

Attribute VARIABLES are contained/held within Objects, so they're global (you can use them anywhere, no scope/location limitation) and permanent, so long as the Object holding/containing them, exists or still exists:

Attribute VARIABLE: NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION

ball_1.color = "red"
ball_1.shape = "sphere"

ball_2.color = "blue"
ball_2.shape = "oval"

see how the 'color' and 'shape' String Attributes are DATA (characteristics/traits/attributes) OF (contained within) specific OBJECTS, so, for example:

'ball_1.color' and 'ball_2.color' are two different String Attributes, despite being the same 'color' String Attribute, due to them belonging to 2 specific (different) Objects

and Objects can have multiple Attributes too, as shown: 'ball_1.color' and 'ball_1.shape', and, 'ball_2.color' and 'ball_2.shape'

vs

Variable VARIABLE: NAME_OF_Variable = VALUE_OR_EXPRESSION

color = "red"
shape = "sphere"

in order to have multiple Values without Objects, you'd need multiple Variables, to simulate having Objects:

ball_1_color = "red"
ball_1_shape = "sphere"

ball_2_color = "blue"
ball_2_shape = "cube"

having 4 Variables:
ball_1_color
ball_1_shape
ball_2_color
ball_2_shape

instead of just two Attributes (due to using Objects):
NAME_OF_OBJECT.color
NAME_OF_OBJECT.shape

lastly, Variables only exist within their scope (location), and cease to exist once their scope's scripting (location) is done

one location can't use Variables from another location (unless they're passed as Parameters/Arguments), unlike with Attributes


GUI/Editor's 'WHATEVER' Object's Attribute Tab's Attribute box' (the box at the bottom) 'add' options/controls:

[Object Name: the default 'player' Player Object, the special and required 'game' Object, or one of your 'WHATEVER' Page/Room Objects]
Attribute Name: time
Attribute Type: int // integer
Attribute Value: 0 // or whatever value you want it to start as

in code, as scripting, examples:

player.time = 0
or
game.time = 0
or
Page1.time = 0

in GUI/Editor, as scripting, example:

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

set variable player.time = [EXPRESSION] 0
or
set variable game.time = [EXPRESSION] 0
or
set variable Page1.time = [EXPRESSION] 0


then for your event/action that increases your 'time' counter (Integer) Attribute, you'd want, for example:

using GUI/Editor's scripting, an example:

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

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

or you can just do the 'increase counter' helper Script option under whatever its category/section (but this is limited to using addition and only using a '1' Value: +1 increase), whereas doing it like I showed above yourself, let's you put in whatever expression you want, for examples:

set variable player.time = [EXPRESSION] player.time * 7
// example using 'multiplication' and the '7' value (x7), instead of 'addition' and the '1' value (+1)

and you can have as complex an expression as you'd like, for example:

set variable player.maximum_life = [EXPRESSION] (player.strength + player.endurance) / 2

in code, as scripting, examples:

player.time = player.time + 1

player.time = player.time * 7

player.maximum_life = player.strength + player.endurance) / 2


and then for the other event/action that handles what happens:

using the GUI/Editor's scripting:

add new script -> 'scripts' section/category -> 'if' Script -> (see below for example)

if [EXPRESSION] player.time = 0

-> then -> add new script -> (WHATEVER scripting)

else if [EXPRESSION] player.time = 1

-> then -> add new script -> (WHATEVER scripting)

else if [EXPRESSION] player.time = 2

-> then -> add new script -> (WHATEVER scripting)

etc etc etc more or less 'else ifs' has needed


or, you may want to do ranges/bounds instead, here's an example of it (as code for quickness):

(using school test taking: score and grade, for this example, but its the same mechanics, just got to replace with what you're doing/using for your Objects' names and your Attributes' names, and etc whatever other changes needed for what you want to do or are doing)

// getting a random value for your test score, to see it in action:

text.score = GetRandomInt (0,100)

// or, if you want to also see the min-max range/bounds checking in action:

text.score = GetRandomInt (-100,200)

------------

// setting min-max bounds/range:

test.maximum_score = 100
test.minimum_score = 0

------------

// min-max bounds/range checking:

if (test.score > test.maximum_score) {
  test.score = test.maximum_score
} else if (test.score < test.minimum_score) {
  test.score = test.minimum_score
}

// if score more than 100, score is 100
// else if score is less than 0, score is 0

----------

// high to low range checking:

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"
}

---------

// alternative (more efficient: less operations) high to low checking:

if (test.score > 89) {
  test.grade = "A"
} else if (test.score > 79) {
  test.grade = "B"
} else if (test.score > 69) {
  test.grade = "C"
} else if (test.score > 59) {
  test.grade = "D"
} else {
  test.grade = "F"
}

-----------

// low to high checking:

if (test.score < 60) {
  test.grade = "F"
} else if (test.score < 70) {
  test.grade = "D"
} else if (test.score < 80) {
  test.grade = "C"
} else if (test.score < 90) {
  test.grade = "B"
} else {
  test.grade = "A"
}

None of these solutions seemed to change my issue. Trying time=time+1 doesn't work and I only get the expression option when I choose to set a variable.


"time" as in a clock???
or "time" as in number of times the room is visited???
In text adventure, the step up from gamebook with ALL the features, there is a "once:" command to display text only the first time you enter a room.
(Not sure if gamebook has the same feature.)
I guess there is...


Can you show the code you've got?
It might be easier to figure out why it isn't working if we can see what you've got.


Log in to post a reply.

Support

Forums