0 votes
by (120 points)
First foray into Twine, and I may be biting off more than I can chew:

I'm setting up a passage with text that replaces with new text on mouseover and increments a story variable, and when the story variable reaches a certain threshold, I want to reveal the link to the next passage. The trouble is that as far as I understand, I can't use if: to check for a change in a variable that happens within the passage, unless that if: statement is hidden, in which case it'll run and check the variable once it's revealed. This poses its own catch-22 (how would I trigger the hidden hook to show in the first place if I can't really use if:?), but the larger problem is that every time I've tried to incorporate hidden: or show: macros, they read as errors and don't do anything.

I thought updating to the most recent version would solve the problem, but it hasn't. This seems like a really fundamental functionality problem, or else there's something really basic I'm not grasping.

1 Answer

0 votes
by (159k points)

You didn't supply an example of your passage's marked text content of how you are actually using the (mouseover:) macro within that passage, so I assumed that marked text content looks something like the following.

The |quick>[quick] |brown>[brown] |fox>[fox] |jumps>[jumps over] the lazy |dog>[dog].

|hiddenlink)[ [[Continue->Next Passage]]]

The following solution relies on using a child passage combined with the (replace:) macro and the (display:) macro to cause a block of code logic to be executed each time one of the (mouseover-replace:) macros are triggered.

1. The child passage containing the conditional logic. (I named mine Counter Logic in this example)

{
	(set: $counter to it + 1)
	(if: $counter is 3)[
		(show: ?hiddenlink)
	]
}

2. The (mouseover-replace:) macro calls, placed later in the same passage as the marked text content.

{
	|workarea>[]
	(set: $counter to 0)
	(mouseover-replace: ?quick)[
		slow
		(replace: ?workarea)[(display: "Counter Logic")]
	]
	(mouseover-replace: ?brown)[
		black
		(replace: ?workarea)[(display: "Counter Logic")]
	]
	(mouseover-replace: ?fox)[
		bear
		(replace: ?workarea)[(display: "Counter Logic")]
	]
	(mouseover-replace: ?jumps)[
		jumped on
		(replace: ?workarea)[(display: "Counter Logic")]
	]
	(mouseover-replace: ?dog)[
		cat
		(replace: ?workarea)[(display: "Counter Logic")]
	]
}

note: you will notice that I uses the related (mouseover-replace:) macro instead of the macro you mentioned, this is because it allowed by to use a simplier marked text content example, however the technique I have used above will also work (possible requiring a slight modification) with any mouseover (or click) macro that supports the execution of an associated hook.

by (120 points)

Thank you for the response! I've applied your advice where I could, but I'm running into a couple of snags—show: won't parse and for whatever reason that |hiddentext) tag doesn't take. First off, for the sake of clarity, here's the code as it stands now, first in the main passage:

The table is [filled nearly end-to-end with cheese logs and crackers]<food1|, laden with [pendulous grapes]<food2|, and [creaks beneath the mighty load of the centerpiece: a golden-brown roast turkey]<food3|.

|hiddenlink)[ [[You're stuffed to the gills.->Digest1]]]

{
|workarea>[]
(mouseover-replace: ?food1)[coated with a fine dusting of crumbs and morsels outside your reach(replace: ?workarea)[(display: "Eaten Logic")]]
(mouseover-replace: ?food2)[skeletonized stems(replace: ?workarea)[(display: "Eaten Logic")]]
(mouseover-replace: ?food3)[strewn with bones picked clean and cracked open for precious marrow (replace: ?workarea)[(display: "Eaten Logic")]]
}

and in the child (I left out setting $eaten to 0; I have that set in a startup passage):

{
(set: $eaten to it + 1)
(if: $eaten is 3)[(show: ?hiddenlink)]
}

I left out the spacing and tabulation in your example formatting because in the initial run it was throwing off the formatting of the passage text—presumably there's a trick there I'm not grasping.

In any case, when I try to run the game as-written, the link that's supposed to be hidden, as well as the |hiddenlink) tag, are plainly visible, and I get this error back:

"I can't run the macro 'show:' because it doesn't exist."

...