Is it possible to create a save/load button or something? (in Gamebook) [solved]

Hello, it's me again! Thank you for all those who helped me with my previous problem! I... kinda have a new dilemma, hehe...

While I was making the chapter1 of my game, it occurred to me that if the game would be long, players would exit and come back to start over again would be a complete turn off. They'd want to load from their previous progress. So my question is, Is it possible to create a save/load button in Gamebook?

Also, I remembered a previous question I had before. I never understood how the code works but now I will give it a try again.
If for example the player wants to view their achievements/stats (I plan to separate the page link to achievements and stats), I can make a page that leads them to the achievements/stats page but how do I make it that the "return to game" button will return them to their current position.

Something like this I guess..
Page2: player opens achievements to see what he/she can accomplish. Player clicks a link that leads to Page1
Page1: this is the achievements screen where player views the list of achievements, there's a "return to game" link after viewing it
Page2: player returns to page2 because that's where the "return to game" link leads to

But if for example, the player is in Page5 and views the achievements again, the link in "return to game" leads back to Page2.
How do I make it that the link of "return to game" leads back to the last page visited?

Questions:

  1. Is it possible to create a save/load button in Gamebook? If it's possible, can you help me?
  2. How do I make it that the link of "return to game" leads back to the last page visited?

I am a beginner here, I use Gamebook in an attempt to make a game. Please help me.
I can understand the explanation easy if there is a step by step screenshot on what to do or a code view of what I should be doing. Please help me.

Thank you in advanced!


It should already have a save command built in. If you are using a pc, it saves to a new file. If you are online, you need to have an account to save, and it saves it on your account.


K.V.

Step 1

Go to the 'Script' tab on your game object.

Add this into the script in code view:

firsttime {
  player.changedparentBak = player.changedparent
  player.changedparent => {
    player.lastpage = oldvalue
    invoke (player.changedparentBak)
  }
}

image


Step 2

Make a page named "Save".

Change it from 'text' to 'script'.

Put this for the script in code view:

request (RequestSave, "")
MovePlayer (player.lastpage)

image


Step 3

The easiest way to create a link is adding this to your page's text (replacing "SAVE THE GAME" with whatever you'd like the link to say):

{page:Save:SAVE THE GAME}


If you want that to show up every turn, go back to Step 1 and add this line to end: msg("{page:Save:SAVE THE GAME}")

(You could add this as an alternative: AddPageLink (player.parent, Save, "SAVE THE GAME"))

The revised script would look like this:

firsttime {
  player.changedparentBak = player.changedparent
  player.changedparent => {
    player.lastpage = oldvalue
    invoke (player.changedparentBak)
  }
}
AddPageLink (player.parent, Save, "SAVE THE GAME")

image


Hello! I am sorry for replying late. I tested it out. An error appears when I try to save it.
Here is what I did.

<!--Saved by Quest 5.7.6606.27193-->
<asl version="550">
  <include ref="GamebookCore.aslx" />
  <game name="Sample Training">
    <gameid>9873d63f-0d25-4b0b-8c0c-7d3b089a15f4</gameid>
    <version>1.0</version>
    <firstpublished>2018</firstpublished>
    <category>Simulation</category>
    <description type="string"></description>
    <defaultbackground>Black</defaultbackground>
    <defaultforeground>Cornsilk</defaultforeground>
    <defaultlinkforeground>GreenYellow</defaultlinkforeground>
    <roomenter type="script"><![CDATA[
      player.guide = "Guide1"
      player.guide = "Guide2"
      player.guide = "Guide3"
      firsttime {
        player.changedparentBak = player.changedparent
        player.changedparent => {
          player.lastpage = oldvalue
          invoke (player.changedparentBak)
        }
      }
      AddPageLink (player.parent, Save, "SAVE THE GAME")
    ]]></roomenter>
  </game>
  <object name="Page1">
    <inherit name="scripttext" />
    <description>Choose a guide.</description>
    <options type="stringdictionary">
      <item>
        <key>Page10</key>
        <value>Guide1</value>
      </item>
      <item>
        <key>Page11</key>
        <value>Guide2</value>
      </item>
      <item>
        <key>Page9</key>
        <value>Guide3</value>
      </item>
    </options>
    <script type="script">
    </script>
    <object name="player">
      <inherit name="defaultplayer" />
    </object>
  </object>
  <object name="Save">
    <inherit name="script" />
    <script type="script"><![CDATA[
      firsttime {
        player.changedparentBak = player.changedparent
        player.changedparent => {
          player.lastpage = oldvalue
          invoke (player.changedparentBak)
        }
      }
      request (RequestSave, "oldvalue")
      MovePlayer (player.lastpage)
    ]]></script>
  </object>
  <object name="Chapter 1">
    <inherit name="scripttext" />
    <script type="script"><![CDATA[
      firsttime {
        player.changedparentBak = player.changedparent
        player.changedparent => {
          player.lastpage = oldvalue
          invoke (player.changedparentBak)
        }
      }
      AddPageLink (player.parent, Save, "SAVE THE GAME")
    ]]></script>
    <description>Chapter 1</description>
  </object>
  <object name="Chapter 2">
    <description>Chapter 2.</description>
  </object>
</asl>

K.V.

What are the errors? Can you copy them and paste them here, please?


Here.

Error running script: Unknown object or variable 'oldvalue'


K.V.
<!--Saved by Quest 5.7.6606.27193-->
<asl version="550">
  <include ref="GamebookCore.aslx" />
  <game name="Sample Training">
    <gameid>9873d63f-0d25-4b0b-8c0c-7d3b089a15f4</gameid>
    <version>1.0</version>
    <firstpublished>2018</firstpublished>
    <category>Simulation</category>
    <description type="string"></description>
    <defaultbackground>Black</defaultbackground>
    <defaultforeground>Cornsilk</defaultforeground>
    <defaultlinkforeground>GreenYellow</defaultlinkforeground>
    <roomenter type="script"><![CDATA[
      player.guide = "Guide1"
      player.guide = "Guide2"
      player.guide = "Guide3"
      if (not HasAttribute (player, "changedparentBak")) {
        player.changedparentBak = player.changedparent
        player.changedparent => {
          if (IsDefined("oldvalue")){
            player.lastpage = oldvalue
          }
          else {
            player.lastpage = player.parent
          }
          invoke (player.changedparentBak)
        }
      }
      AddPageLink (player.parent, Save, "SAVE THE GAME")
    ]]></roomenter>
  </game>
  <object name="Page1">
    <inherit name="scripttext" />
    <description>Choose a guide.</description>
    <options type="stringdictionary">
      <item>
        <key>Page10</key>
        <value>Guide1</value>
      </item>
      <item>
        <key>Page11</key>
        <value>Guide2</value>
      </item>
      <item>
        <key>Page9</key>
        <value>Guide3</value>
      </item>
    </options>
    <script type="script">
    </script>
    <object name="player">
      <inherit name="defaultplayer" />
    </object>
  </object>
  <object name="Save">
    <inherit name="script" />
    <script type="script"><![CDATA[
      request (RequestSave, "")
      MovePlayer (player.lastpage)
    ]]></script>
  </object>
  <object name="Chapter 1">
    <inherit name="scripttext" />
    <description>Chapter 1</description>

  </object>
  <object name="Chapter 2">
    <description>Chapter 2.</description>
  </object>
  <object name="Page10">
    <description>fsafs</description>
  </object>
</asl>

K.V.

NOTE:

      player.guide = "Guide1"
      player.guide = "Guide2"
      player.guide = "Guide3"

This is in your game.roomenter script. That means this code runs every time you change pages.

Plus, you might as well delete the first two lines. This will set player.guide to "Guide3" nearly instantaneously.


K.V.

I'm not being mean here, I promise, but I think you should make a very simple game first. Maybe with only one or two attributes to set and one goal.

You don't have to share it with anyone, but make sure it plays correctly.

If you try to make your first game cool, you are likely to become frustrated during the process. Make your first game very, very basic. Maybe 3 - 10 pages. Then make a second little game, adding one more trick to your bag. Rinse and repeat. Once you're comfortable with the fundamentals, THEN start writing your real game.


This goes for everyone's first few games. Even mine. I am in no way trying to discourage you.

Quest is an instrument. We have to learn the notes, the chords, and how to play the simple stuff before we can create our masterpiece(s).


Basically, your first game book shouldn't be very long; not long enough to necessitate a save feature, at any rate.


Oh I see okay wait I will delete it.
I have two questions.

If I delete

player.guide = "Guide1"
player.guide = "Guide2"

How will I do the choices for the three types of guide if only "Guide3" remains? I wanted to do the same concept of "choose your race; elf, mage, warrior, etc." but instead of "race", they choose a "guide".

Update:
The "Save Game" works now thank you thank you very much!

  1. Should I follow the format of the "save game" to do the "load game"?
  2. Is it possible to add a print message when they save the game. Like instead of "C:\Users\karinchan\Desktop\samplesave.quest-save" I can replace it with "Game Saved!"?

How will I do the choices for the three types of guide if only "Guide3" remains?

That is what it is set to in the end, anyway. You are not adding three choices. You are setting it to three different values three times in a row. The last one is what it ends up being set to, and the last one is "Guide3".

It works like this:

player.guide = "Guide1"

Now it is set to "Guide1".

player.guide = "Guide2"

Now it is set to "Guide2".

player.guide = "Guide3"

Now it is set to "Guide3".


Should I follow the format of the "save game" to do the "load game"?

Nope. You can't load a game from inside a game.

If online, after saving the first time, there will be two options: 'Play (resume)' or 'Restart Game'.

If playing in the desktop version (which I see you are), you need to open the file that was created when saving. Yours is on your desktop, and called "samplesave.quest-save". Open that file (just double-click it) to "load" that saved game.


Is it possible to add a print message when they save the game. Like instead of "C:\Users\karinchan\Desktop\samplesave.quest-save" I can replace it with "Game Saved!"?

Nope.

You can do lots of complicated coding to make it print a custom message, but it will print it before or after C:\Users\karinchan\Desktop\samplesave.quest-save, depending on what sort of mood Quest is in at the moment. But it's a waste of time. It behaves poorly intermittently.


Me, Monster, like to make gamebooks in Squiffy, karinchan999!

Has karinchan999 every tried Squiffy??? Monster thinks Squiffy is easy! And Monster likes Squiffy more than Quest!!!

Monster use Twine before, but Squiffy makes writing gamebooks easier!


Hello! Thank you for also helping me.

I will still type player.guide = "Guide1" until Guide3 to set the value?

Oh I see. Thank you very much for explaining. I checked the "sample save" file that I did earlier to load the game and it works! Thank you thank you! And thank you again K.V.! Thank you very much!

Ooooh, I will stick to that. Thank you!


Hello The Quest Forum Monster!
Yes I tried Squiffy before, it is indeed easier :D but I'm not sure how to do the stats and stuff when I use it so I am learning in Gamebook instead. :D


SqUifFy eAsY!

http://docs.textadventures.co.uk/squiffy/attributes.html


Play Monster's game, karinchan999! U could paste it in sQuiffy and RUN it! (It is FUNNY, funny!!! {(~.!.~)})

@title Monster's Squiffy-time Adventure

<center><h1>Monster's Squiffy-time Adventure</h1><h3>Choose Your Own Adventure!</h3><h4>by The Quest Forum Monster</h4></center>

<b style="font-size:110%">Once upon a time,</b> me (Monster), was reading this very same story you (Adventurer) are reading right now, when a scary PERSON appeared!

Monster was [[scared]](last part, scared=true)!

Monster was [[not scared at all]](last part, scared=false)!


[[last part]]:
{if scared=true:
"Oh, no!" Monster cried!  
"Leave Monster alone, big, scary PERSON!"

Then, Monster run away, and no more story.

<center><h1>THE END</h1></center>
}{else:
"Go away, ugly, stupid PERSON!"  Monster yelled.  Then, Monster wave his arms over his head, like, "GRAWWRR!!!"

Dumb, scary person run away.
}
Monster so happy!  He was really <i>scared</i> of the scary person!  (Could you tell?  Shh!  Don't do no telling, okay?!?)

+++MORE

You (Adventurer) are {if scared=true:loser}{else:winner}!

<center><h1>THE END</h1></center>

Thank you but I can't study and master both squiffy and gamebook at the same time.


Monster not sad.

When karinchan999 gets fed up with Quest gamebook, karinchan999 maybe learn Squiffy. That okay with Monster.

Me sorry, karinchan999. Quest text adventure good. Quest gamebook bad.

Have nice day!


:D


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

Support

Forums