It looks like you're new here. If you want to get involved, click one of these buttons!
<<link "Click here" $urlopts["nav"]>>
but this does not:
<<goto $urlopts["nav"]>>
:: Goto Passage [script]
(function () {
macros.add("goto", {
handler: function () {
try {
state.display(this.args[0]);
}
catch (e) {
return this.error("Go to passage: " + e.message);
}
}
});
}());
The macro code doesn't throw any visible error messages, but I messed around a bit with wrapping it in a <<click>> and was able to see a message "This passage does not exist". So, it seems as though the problem is that while <<link "Click here" $urlopts["nav"]>> can properly parse the value stored in $urlopts["nav"], my <<goto>> macro cannot. <<click "Click here to go to " + $urlopts["nav"]>><<goto $urlopts["nav"] >><</click>>
This wasn't able to set the link text from $urlopts["nav"] either, so I'm wondering if there is simply something else I need to do when passing that sort of value into custom macros...?
Comments
I'm not sure but that's where I'd start.
You cannot use state.display() to display a new passage while in the middle of displaying another.
<<click>> does not accept expressions, so you effectively passed it three arguments (1: "Click here to go to ", 2: "+", 3: $urlopts["nav"]).
Just doing a <<display>> from ::Start doesn't call PassageReady for the new passage, which I need it to do.
It sounds like I should be able to forward using state.display() from ::PassageDone, though, so I'll plan on doing that, something like this:
Ah. I would have thought that you could fix that with a little extra logic, I mean you do know which passage it's supposed to be after all, but maybe you're doing something really complicated in there.
That's not going to work either. Both methods of doing pre-/post-render tasks (SugarCube's PassageDone/PassageDone passages and the prerender/postrender task objects, which SugarCube also supports) are called within the bounds of state.display().
I suppose that I could add a configuration property for the starting passage, which would default to Start, but that you could change st startup (probably something like config.startPassage).
Another options would be a timed version of the goto macro, that would go there after a timeout, but that feels hacky to me.
Well, as I said, I can add a configuration property for the starting passage, if what you'd have to do otherwise is a bother. I mean, it's general enough that I don't have any reservations about adding it.
That's because it is.