Increasing and decreasing variable values.

TFG
26 Jun 2013, 05:25
I've been bashing my head against the wall over this for a good few hours. All progress on a game I've been working on stopped dead in its tracks as soon as I tried implementing this.

It should be noted that I am making a gamebook. But what I am trying to do is take a variable and increase its value a step after repeatedly performing an action. I am assuming I have to use the "for" script in order to do this, but I've no idea how to make it work. Something to do with creating a stringlist, right? Thing is, I don't even know what I'm doing there either.

I am sure this is a really simple issue and has been answered before, but I looked and couldn't find exactly what I was trying to do. Or if I did, I simply didn't understand it since I'm a newbie to all of this.

Pertex
26 Jun 2013, 07:00
TFG wrote:It should be noted that I am making a gamebook. But what I am trying to do is take a variable and increase its value a step after repeatedly performing an action.

What exactly do you want to do?

TFG
26 Jun 2013, 07:44
I am looking to be able to create certain stats and then give unique descriptions based on how high or low the variable values of those stats are. Like if the variable value is < 50, then whatever characteristic the variable is used to describe becomes X, but if it is > 50, it becomes Y instead. I am also looking to be able to set a fixed maximum and minimum value as well, because I want certain actions in the game to affect these variable values and I don't want actions that decrease the value to go below zero or the actions that increase the value go beyond whatever I'd like the maximum to be.

I can't use counters, because, or at least as far as I know anyway, you cannot have the text read out the counter values. You also can't fix the minimum and maximum values in the way I want or be able to increase the values by a specified number, as I want some actions to increase or decrease the variable values more than other actions.

I hope this is comprehensible, and I truly appreciate the help.

Pertex
26 Jun 2013, 08:08
"actions" means going to a new page?

TFG
26 Jun 2013, 08:26
Yes, sorry.

Pertex
26 Jun 2013, 09:30
Hmm,I am not used to create gamebooks but I think you can do it this way:

1. initialize a variable on page 1. Here test is set to 0
page1.jpg


2. every other page can modify this variable:
page2.jpg

TFG
26 Jun 2013, 09:38
I really can't thank you enough, that helped a lot!

Alex
26 Jun 2013, 09:42
Use counters for this - it's even simpler.

Pertex
26 Jun 2013, 09:46
But how do you increase a counter by a vlaue greater than 1?

TFG
26 Jun 2013, 09:53
And can you incorporate counters into the text processor in the same way you can with variables?

Pertex
26 Jun 2013, 09:56
Yes, If you have a counter named test you can use it in the text processor like this: {game.test}

Alex
26 Jun 2013, 10:53
Ah, sorry, missed that part. Yes you can't do this yet. But it would be simple enough for the gamebook library script functions to be updated to allow this (maybe a separate function for simplicity).

Note that counters are really just integer attributes on the game object anyway - that's why the work in the text processor. It also means you can use "set variable or attribute" with them if you want to increase their value by more than one (the counter would have to exist first though).

Pertex
26 Jun 2013, 14:14
Alex wrote: It also means you can use "set variable or attribute" with them if you want to increase their value by more than one (the counter would have to exist first though).


Thats right, but it's not clear for a gamebook writer that he can increase a counter named "test" , but if he want to work with this variable he must use "game.test".

I think I will add some functions to make this easier