Page Links Not Appearing (Gamebook)

When I first created my Gamebook, the starter links worked fine. Then I renamed the first room "Intro" and turned it into a Script page to run this script:

msg ("You kneel before the king, wondering with more than a little trepidation why you, of all people, were summoned to the royal palace on this auspicious day.<br/><br/>\"What is your name, peasant?\" the king asks in a booming voice that fills your heart with fear.<br/>")
GetInput() {
  player.alias = CapFirst(LCase(result))
msg ("\"" + player.alias + ", if it p-please Your G-Grace,\" you stutter.")
msg ("<br/>\"It does not please me. I myself would be ashamed to bear such a name. But you can have it changed at a later 
date. At present, I have a task for you, " + player.alias + " the Peasant.\"")
  AddPageLink (Intro, Page3, "Do Something!")
}

Everything works fine, except the page link never appears. I tried turning the page to Script+Text and adding page links in the details section, but all that did was put a giant blank space in the middle of my message printouts. I also moved the player to the basic Page2 and added a couple of page links there, but they didn't appear either. My link color is Crimson and the background color is white, so they are not simply hard to see... they just aren't appearing for some reason.

I'm using the online editor.


Okay, I see your problem.

Everything works fine, except the page link never appears.

apparently, your code is this:

  AddPageLink (Intro, Page3, "Do Something!")

This would only work if your Page2 and Page3 were still named Page2and Page3.

Hope this helps.


(Note: I'm answering just by skim-reading the code, so I could be completely wrong here)

I think the problem is with the order of execution.

When you visit a page, Quest runs the page's script (if there is one), displays the page's text (if there is one), and displays the page's links (if there are any).

In this case, the script displays an input box, and makes a note of another script (the one inside the GetInput block) to run when the player enters something.

So the order of events is:

  1. Display the first message.
  2. Display the input box to ask for the player's name
  3. Display the links currently in that page's dictionary
  4. Wait for the player to input something
  5. Display the second message
  6. Add a link to the page's dictionary

Your new link is added, but the page's links have already been copied to the screen. So you need to send your link to the screen manually.

Instead of:

  AddPageLink (Intro, Page3, "Do Something!")

I think you need

  if (not HasString (game, "optionsoutputsection")) {
    game.optionsoutputsection = StartNewOutputSection()
    EndOutputSection (game.optionsoutputsection)
  }
  JS.eval ("$('."+game.optionsoutputsection+"').append('<span>" + ProcessText("{command:Page3:Do Something!}") + "</span>');")

(You would want to use AddPageLink as well if you want the link to still be there when you visit the page in future


@Sh4dowGaming1234

Page2 and Page3 are still called that. :(

@mrangel

Your logic makes sense, but where do I put that code? I clicked "Code View" and pasted it instead of the AddPageLink, but it just instantly gave me an internal error...


Also, why do the links not appear on Page2 either, when that is an only text page (just the basic Page2 but with a link to Page3).

EDIT: It's because I didn't write anything in the link text box. [facepalm]


Well, I "fixed" it using a workaround. Now I just have the Intro page automatically transport you to the Intro Links page, which is a Text page with links that do appear.

This problem is very annoying, though. I would still appreciate it if anyone could tell me how to get AddPageLink to work.


I clicked "Code View" and pasted it instead of the AddPageLink, but it just instantly gave me an internal error...

The web editor gives an internal error on leaving code view if the code contains a string with a < character in.

If using the web editor, remove the >s, then once it's saved you can re-add them to the string in the GUI view.
(This is one of the most annoying bugs in the web editor if you're doing complex things)

You can probably remove the <span> tags if you prefer… I just put them in as a placeholder, because there will need to be some HTML there if you want to do this on a page that already contains links and I can't remember what else is there as well as the <span>.


Thanks, I'll try that!


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

Support

Forums