0 votes
by (1.3k points)

Hi, I have this code:

<<button "confirm">><<return>><</button>>

But, it doesn't seem to work. Is there any reason for this?

Or is there another way to achieve this that works?

If I put <<return>> outside of the button, it works. It works perfectly. So, I don't understand.

1 Answer

0 votes
by (159k points)
selected by
 
Best answer

It appears you may of found a bug in the <<return>> macro, and the related <<back>> macro.

I strongly suggest you create a new issue on the SugarCube project repository explaining what you have discovered so that the developer knows about the problem and can fix it.

As a short term work around you could do the following, which also moves the Reader forward to the previously visited Passage, just like the <<return>> macro does.

<<button "confirm" `previous()`>><</button>>

note: the delimiters around the above previous() function are not single quotes, rather they are back-quotes which are explained in the Passing an expression as an argument section of the Macro Library documentation.

by (1.3k points)
Yeah, that works! Thanks for that, greyelf.
by (68.6k points)

It's not a bug.  I'm surprised that was even suggested, as they have never worked that way.

When invoked, the <<back>> and <<return>> macros create links which navigate the story history when activated by the player, they do not navigate the history directly themselves.  Thus, you cannot use them within the <<button>> or <<link>> macros.

If links are unpalatable and you really want buttons to do the same.  I'd suggest either styling the links created by <<back>> and <<return>> to look like buttons or using something like the following constructs, which provide similar functionality.

A <<button>> which acts somewhat like <<back>>:

<<button "Back">><<script>>Engine.backward();<</script>><</button>>

A <<button>> which acts somewhat like <<return>>: (already shown by greyelf)

<<button "Return" `previous()`>><</button>>

 

by (1.3k points)
Oh right. Now that you explain it that way, yeah, I see it. They just create links for users to click on. Makes sense.
...