In Text Link Text to Page Not Working

Gnizam
23 May 2014, 23:14
This is a very annoying problem that stops my game in it's tracks. When I try to link text to a page it doesn't work. When I play test the game it says:
Error running script: Error evaluating expression 'DictionaryContains(player.parent.options, command)': DictionaryContains function expected dictionary parameter but was passed 'null'

Walkthrough:
Click the option: Keep Drifting
Then click: Open your eyes
*BAM* Error.

Here are the game files:
https://app.box.com/s/l6baaii97m7ultezbxry

jaynabonne
24 May 2014, 15:26
There seems to be a bug in the gamebook code where it *really* wants an options dictionary on a page. The problem is that until you create a link option, that dictionary doesn't exist.

The solution is to create an empty options dictionary on the pages that have only inline links. There are two ways to do it:

1) The code view way. Switch to Code View, and for each page that has no links, add this line on that page:

<options type="stringdictionary" />

2) The GUI way. On a page that will have no links, still create a link and then delete it. For example, click "Link to Existing Page", pick some random page and then enter random text for the link. Then click the new link and delete it. That will leave an empty options dictionary on the page. It looks like you were sort of working that out yourself with your random looking "esfr" link on the "Open Your Eyes" page. Just delete that link now, and it will still keep working for that page.

Hope that helps!

jaynabonne
24 May 2014, 15:53
Actually, here's a better solution, one where you don't have to patch each page.

I've attached an updated game file for you which has a function added to it, which replaces the core HandleCommand that's giving you trouble with one that won't. You can just take the attached file and continue from there.

In case you're curious or wish to patch it yourself - to patch another game or the same if you've advanced it - then I just added the following (in Code View) above the closing </asl> tag in the game:

  <function name="HandleCommand" parameters="command">
<![CDATA[
if (command = "undo") {
// ignore
}
else {
newpage = GetObject(command)
if (newpage = null) {
msg ("Error - no page named '" + command + "'")
}
else {
if (not game.clearlastpage and HasAttribute(player.parent, "options")) {
if (DictionaryContains(player.parent.options, command)) {
optiontext = StringDictionaryItem(player.parent.options, command)
msg ("<b>" + optiontext + "</b>")
msg ("")
}
JS.disableAllCommandLinks()
}
player.parent = GetObject(command)
}
}
]]>
</function>

It just adds the "and HasAttribute(player.parent, "options")" part to the "if".

With this change, you don't need to go through the irritating workaround I posted above.

Gnizam
25 May 2014, 13:21
Good time to mention I don't know what I'm doing, I can't figure out how to use the game file.

jaynabonne
25 May 2014, 13:59
This is just an updated version of one of the files you gave me. So wherever you got the original files from (whichever folder), just download and save the attached file to that place to replace your game file.