Setting Variables in Gamebook Mode

Bafflebox
29 Apr 2014, 08:55
Hi folks!
I wanted to make a Gamebook type of game along the lines of the Choice of Games .... games. Yich, that sentence is making me doubt my fluency.
Anyway, rather key to that is setting variables to be taken into the next page upon clicking your decision. My question is ... how?
Once I figure this out, I'm sure I can figure most other things out myself, but the Gamebook mode seems to have been barely documented — either that, or I'm even more of a noobie than I initially thought.
I hope someone can help ^-^

To clarify:
PAGE 1
Blabla, story, blablabla.
Decision 1 (sets var1 to 1 and takes you to page 2)
Decision 2 (sets var1 to 2 and takes you to page 2)
Decision 3 (sets var1 to 3 and takes you to page 2)

PAGE 2
Story content depending on var1

jaynabonne
29 Apr 2014, 19:23
The only way I can see to do that is to have some intermediate pages which are not shown. Bear with me while I explain. :)

There are different page types in Gamebook mode. You can see this under the "Page type" dropdown for a page. The normal page type is "Text". This page only has text. There are also two others of interest: "Script" and "Script + Text". The latter will run a script and then dump out the text like a normal page. The former is a page that only has a script to run. What use is this? Well, it can be used to do some scripty things and then move you off to another page. It's just a transition page with no text of its own.

So, as somewhat painful as it might seem, create three intermediate pages (e.g. Page1_1, Page1_2 and Page1_3). For each, set the type to "Script". Then add script to set the variables you want (or whatever else). Be sure the last script command on each page is a "Move player to page" command, with page being your Page 2. The script will be run, and the player will then be taken to Page 2.

Note that I haven't tried the above, but looking at the Quest core, it looks like this is the way to do it. If that doesn't work, we'll try again. :)

Tomineitor
29 Apr 2014, 22:48
Mmmhh, what if you :

Story,blabla,lbababasdad

Decision A ( takes you to a script page, activate variable/flag A, then take you to page"X")
Decision B ( takes you to a script page, activate variable/flag B, then take you to page"X")
Decision C ( takes you to a script page, activate variable/flag C, then take you to page"X")

*BTW, I use flags as variables like ex: You have picked up the rock! (activate "you have a rock" flag)

hope that helps you :D

Bafflebox
29 Apr 2014, 22:49
Oh, thanks a heap! That makes everything so much easier.
It's not clean, but I'll take it! Works like a charm :D

Bafflebox
30 Apr 2014, 08:22
So, having done all that, one particular type of variable is giving me trouble.
For the sake of practice, I made a little something to let the player become nervous, but it returns a bunch of errors:

Error running script: Invalid attribute name 'game.nervosity'
The lightswitch does nothing.
Error running script: Invalid attribute name 'game.nervosity'
Error running script: Error compiling expression 'game.nervosity > 10': CompareElement: Operation 'GreaterThan' is not defined for types 'Object' and 'Int32'



Does anybody know what I should do to fix this? I really only need a simple counter to compare values against.

Pertex
30 Apr 2014, 09:56
Sure. If you use the functions "set counter" or "increase counter", you have to specify the counter name not the variable.
The variable is "game.nervosity" but the counter is "nervosity"

Bafflebox
30 Apr 2014, 10:16
It works now, I'd have taken so long to figure that out by myself XD *is evidently not coding-inclined*
Thanks a bunch! :D