Storing Choices over Games

So, I'm writing a Gamebook that heavily features choice and consequence. The only problem is I plan for it to be a series. Is there some way I can make choices in one game affect outcomes in another?


Not too easily...
Quest has a file read function, but not a usable file save function...


K.V.

I'd suggest using old school passwords (like some old Nintendo games did).

I've created 2 (extremely basic) example games to test out using passwords.

In Game 1, there are only two choices. The first sets game.choice1 to "2" or "3", depending on which page the player picks. The second sets game.choice2 to "4" or "5" (depending on which page the player picks).

I only have two choices here, so the password will only consist of two characters. (In fact, in this case, it can only be "24", "25", "34", or "35", but that is besides the point.)

To print the password for the player, I just put this in a text box:
{game.choice1}{game.choice2}

To "decode" that in the next game:

//THIS CODE HAS BEEN EDITED SINCE FIRST POSTED
      msg ("Please enter your password from story one:")
      JS.uiShow ("#txtCommand,#txtCommandDiv")
      get input {
        msg (result)
        JS.uiHide ("#txtCommand,#txtCommandDiv")
        game.choice1 = Chr(result[0])
        msg ("game.choice1: " + game.choice1)
        game.choice2 = Chr(result[1])
        msg ("game.choice2: " + game.choice2)
      }

Game 1:

<!--Saved by Quest 5.8.6794.35054-->
<asl version="580">
  <include ref="GamebookCore.aslx" />
  <game name="Serial Gamebook - Part 1">
    <gameid>61b941bf-6789-4ca2-8c6a-c0be0f8dde52</gameid>
    <version>1.0</version>
    <firstpublished>2019</firstpublished>
  </game>
  <object name="Page1">
    <description>Choose:</description>
    <options type="stringdictionary">
      <item>
        <key>Page2</key>
        <value>Go to page 2</value>
      </item>
      <item>
        <key>Page3</key>
        <value>Go to page 3</value>
      </item>
    </options>
    <object name="player">
      <inherit name="defaultplayer" />
    </object>
  </object>
  <object name="Page2">
    <inherit name="scripttext" />
    <script type="script">
      game.choice1 = "2"
    </script>
    <description>Choose:</description>
    <options type="stringdictionary">
      <item>
        <key>Page4</key>
        <value>Go to page 4</value>
      </item>
      <item>
        <key>Page5</key>
        <value>Got to page 5</value>
      </item>
    </options>
  </object>
  <object name="Page3">
    <inherit name="scripttext" />
    <script type="script">
      game.choice1 = "3"
    </script>
    <options type="stringdictionary">
      <item>
        <key>Page4</key>
        <value>Go to page 4</value>
      </item>
      <item>
        <key>Page5</key>
        <value>Go to page 5</value>
      </item>
    </options>
    <description>Choose:</description>
  </object>
  <object name="Page4">
    <inherit name="scripttext" />
    <script type="script">
      game.choice2 = "4"
    </script>
    <description><![CDATA[STORY ONE COMPLETE<br/><br/>Write this password down (you'll need it for the next story)!<br/><br/>{game.choice1}{game.choice2}]]></description>
  </object>
  <object name="Page5">
    <inherit name="scripttext" />
    <script type="script">
      game.choice2 = "5"
    </script>
    <description><![CDATA[STORY ONE COMPLETE<br/><br/>Write this password down (you'll need it for the next story)!<br/><br/>{game.choice1}{game.choice2}]]></description>
  </object>
</asl>

Game 2:

<!--Saved by Quest 5.8.6794.35054-->
<asl version="580">
  <include ref="GamebookCore.aslx" />
  <game name="Serial Gamebook - Part 2">
    <gameid>acf0ac46-501c-4a83-835a-cfffb03c4088</gameid>
    <version>1.1</version>
    <firstpublished>2019</firstpublished>
  </game>
  <object name="Page1">
    <description>This is page 1. Type a description here, and then create links to other pages below.</description>
    <options type="stringdictionary">
      <item>
        <key>Page2</key>
        <value>This link goes to page 2</value>
      </item>
      <item>
        <key>Page3</key>
        <value>And this link goes to page 3</value>
      </item>
    </options>
  </object>
  <object name="Page2">
    <description>This is page 2. Type a description here, and then create links to other pages below.</description>
  </object>
  <object name="Page3">
    <description>This is page 3. Type a description here, and then create links to other pages below.</description>
  </object>
  <object name="EnterPassword">
    <inherit name="script" />
    <script type="script">
      msg ("Please enter your password from story one:")
      JS.uiShow ("#txtCommand,#txtCommandDiv")
      get input {
        msg (result)
        JS.uiHide ("#txtCommand,#txtCommandDiv")
        game.choice1 = Chr(result[0])
        msg ("game.choice1: " + game.choice1)
        game.choice2 = Chr(result[1])
        msg ("game.choice2: " + game.choice2)
      }
    </script>
    <object name="player">
      <inherit name="defaultplayer" />
    </object>
  </object>
</asl>

The more choices you have, the more daunting the task will be, but, as my dear old daddy used to say, "ya' gotta feed the monkey if you wanna watch him [EXPLETIVE DELETED]."


You'll also need to code a way to check for incorrect passwords, now that I think about it. . .

If no one else has posted a way to do that by the next time I visit this site, I'll try to come up with something for you.


Thanks, I got most of that accomplished. Just one thing. The game.choices do appear on the second game when I input the code, but it won't let me do anything with them, and the page link I tried to put behind the get input didn't work.


K.V.

Post the code, and we'll get you fixed up.


K.V.

Oh, I had some errors in that code.

This code has been tested more thoroughly (sorry about that):

msg ("Please enter your password from story one:")
JS.uiShow ("#txtCommand,#txtCommandDiv")
get input {
  msg (result)
  JS.uiHide ("#txtCommand,#txtCommandDiv")
  game.choice1 = Chr(result[0])
  msg ("game.choice1: " + game.choice1)
  game.choice2 = Chr(result[1])
  msg ("game.choice2: " + game.choice2)
  if (game.choice1 = "3") {
    if (game.choice2 = "5") {
      msg ("{page:Page4:Go to bonus page!}")
    }
  }
}

Had to use Chr() to convert the bits of text from result into strings. . .


I have had a go at updating my save/load library so it stores data in the browser, in "localStorage". It is still in beta, and only works in the browser, making it awkward to test, but in theory it should work.

https://github.com/ThePix/quest/wiki/Library:-Save-and-Load

You might be best just using the JavaScript from library, and using your own functions, as you do not want to save everything, and the commands are not required anyway.


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

Support

Forums