I would like to have unlockable chapters in my gamebook

I have no experience in coding, but I would like for my gamebook to have chapters... And for the next chapter to only be unlocked when you get one of multiple endings at the end of the chapter currently being read... This will be to prevent readers from skipping chapters, and make sure they read all of the chapters in order the first time they read through the gamebook

I would like to make all of my gamebook in Quest's gamebook mode, but is it possible? Can we put coding scripts in the gamebook game engine? How would I code this?


Just have the passage out of, say chapter 1, require a "key" that unlocks the door to chapter 2...
And so on.


Thank you so so much, but I do not know how to do that !!


The simplest way to do this would probably be by setting a flag that triggers everytime the player reads an ending of a chapter, something like "Chapter1seen". Then you need to make something on the chapter select screen that can read if you have the flag enabled, an "if function" will do nicely there, when it detects it you want it to add the page, that's also found in the script command box.

In case that wasn't entirely clear I made a quick mockup of how this might look, you can save the code under this message to check it out and to play with how it works, after you get my "ending" you'll just need to press any key to get launched back to the chapter selection menu.

Hope that helps!

<asl version="580">
  <include ref="GamebookCore.aslx" />
  <game name="Chapter test">
    <gameid>767230e3-ff35-41f1-83cf-10b1e4f598a5</gameid>
    <version>1.0</version>
    <firstpublished>2023</firstpublished>
  </game>
  <object name="Chapter select page">
    <inherit name="scripttext" />
    <description type="string"></description>
    <options type="stringdictionary" />
    <script type="script">
      SetForegroundColour ("LightGreen")
      msg ("This is the chapter select page.")
      AddPageLink (Chapter select page, Chapter 1, "Chapter 1")
      if (GetBoolean(game, "Chapter1seen")) {
        AddPageLink (Chapter select page, Chapter 2, "Chapter 2")
      }
    </script>
    <object name="player">
      <inherit name="defaultplayer" />
    </object>
  </object>
  <object name="Chapter 1">
    <inherit name="scripttext" />
    <description type="string"></description>
    <script type="script">
      SetForegroundColour ("LightGreen")
      msg ("You played through this chapter and got the \"Betrayed by a goat\" ending.")
      SetFlagOn ("Chapter1seen")
      wait {
        MovePlayer (Chapter select page)
      }
    </script>
  </object>
  <object name="Chapter 2">
    <inherit name="scripttext" />
    <description type="string"></description>
    <script type="script">
      msg ("Now you can play chapter two.")
    </script>
  </object>
</asl> ```

Thank you so so so much !!!! May I credit you if I ever post the book?


Sorry, but I do not know where to put the code.. Do I put it in different chunks in different places? Do I copy paste certain chunks of code into different pages, and how do I know where each separate chunk of code ends and where the next begins? Or do I put it all into the script tab on the "game" page, and if so, is it all of the code in one script or chunks of code divided up between different scripts?


This is basically an entire gamebook worth of code you'll only need these parts in your own game:

      msg ("This is the chapter select page.")
      AddPageLink (Chapter select page, Chapter 1, "Chapter 1")
      if (GetBoolean(game, "Chapter1seen")) {
        AddPageLink (Chapter select page, Chapter 2, "Chapter 2")

That is the code for a menu selection page.

And this part sets the flag once you get an ending in a chapter

      msg ("You played through this chapter and got the \"Betrayed by a goat\" ending.")
      SetFlagOn ("Chapter1seen")
      wait {
        MovePlayer (Chapter select page)
      }

If you paste this in your script on the page where you have your menu selection and your endings respectively it should do the trick.

Hope that helps, if you have any more questions feel free to shoot me a message.

Also if you want to credit me I'd be honored, Mal or Malphas are good.


Thank you very much! I will try this code out now!


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

Support

Forums