Initializing attributes for the "player" object in Quest gamebook

Hi!

I've recently started working with Quest gamebook, since it looks much easier to work with than the interactive text adventure thingie. I've searched the forums earlier and found out how I can actually set attributes by transforming a page to "Script mode" and then make a Set Variable script and all that. But here's my issue. I bind a counter "quests_done" to my player (player.quests_done) and initialize it to 0 on the first page of the book. Then at some point, I have a "player.quests_done = player.quests_done + 1", which is basically the first time the player completes a quest. When I reach that page, I check the "Debugger" and it's showing me that attribute "quests_done" of the object "player" is actually now 1. But then, when from the said page, I click the link to another page where I have a script to print in the number of quests done by the player, it prints 0 and the debugger shows that it's actually reset to 0 again. I feel like there's something wrong with where I've added my scripts but I can't quite figure out what exactly seems to be the issue. Can anyone help me? I can provide any additional information if needed.


(filler for getting my edited post, updated/posted)


based on what you've said (assuming that your other scripting is correctly increasing your value), either:

  1. you're returning to the Page that sets it to '0' (either as its normal scripting: Page Type: [script] or [script + text], or as its 'on entering page' or whatever like that, scripting), and thus it's set back to '0'

  2. you got the script that sets it to '0' on some global scripting ('on entering page' for every/any page, turnscripts/timers if game book has these, etc)


if your game isn't too big, if you don't mind posting your entire game code, we can quickly see the issue and fix it for you (and explain it to you too), just right click on your 'NAME_OF_GAME.aslx' game file, and choose to open it, and select a text editor software (notepad, wordpad, Apple: text editor, notepad++, etc), which will open up into your entire game code, highlight all of it, copy it, and then paste it here in the post's code box, like so:

m```
(paste code here)
m```

but without the m's in front, which produces this:

(paste code here)

if you're working online... you got to download your own game, then unzip (using: winrar, winzip, etc) the published 'NAME_OF_GAME.quest' file, which unpackages it, allowing you to get to your 'NAME_OF_GAME.aslx' game file, and then do the above section's instructions


P.S.

a really good way to debug, is to manually insert 'msg' (Print a message) Scripts, for an example (using a Text Adventure though):

<game name="NAME_OF_GAME">

  <attr name="example_integer_attribute" type="int">0</attr>

  <attr name="start" type="script">

    msg ("Debug: 1, game.example_integer_attribute (" + TypeOf (game.example_integer_attribute) + "): " + game.example_integer_attribute)

    game.example_integer_attribute = 0

    msg ("Debug: 2, game.example_integer_attribute (" + TypeOf (game.example_integer_attribute) + "): " + game.example_integer_attribute)

  </attr>

</game>

<turnscript name="example_turnscript">

  <enabled />

  <script>

    msg ("Debug: 3, game.example_integer_attribute (" + TypeOf (game.example_integer_attribute) + "): " + game.example_integer_attribute)

    game.example_integer_attribute = game.example_integer_attribute + 1

    msg ("Debug: 4, game.example_integer_attribute (" + TypeOf (game.example_integer_attribute) + "): " + game.example_integer_attribute)

    example_function

  </script>

</turnscript>

<function name="example_function">

  msg ("Debug: 5, game.example_integer_attribute (" + TypeOf (game.example_integer_attribute) + "): " + game.example_integer_attribute)

  game.example_integer_attribute = 0

  msg ("Debug: 6, game.example_integer_attribute (" + TypeOf (game.example_integer_attribute) + "): " + game.example_integer_attribute)

</function>

Did you initialize the variable under the 'game' object? Any scripts located under the game object (on the game page) will run every time the player moves. Put the script on the page where the player completes the quest, and you should be good.


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

Support

Forums