0 votes
by (200 points)
when use a click macro using this code

<<click bag>> <<script> <<[[bag]]>> <</script>> <</click>> the <<[[bag]]>> is for the shortform of the display macro. when i click on it the passage text does not appear which is "you pickup the old worn bag
<<set $bag = true>>"

2 Answers

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

There are a couple of issues with your example.
1. As previously explained, the <<click>> macro has been deprecated and should be replaced with one of the <<link>> related macros.

2. The String argmument being passed to your <<click>> macro should be wrapped in either single or double quote characters.
eg. (note: the following example assumes the <<click>> is replaced with a <<link>>)

<<link "bag">> ... <</link>>

3. [optional] I suggest using the String based argument version of the <<include>> macro instead of the Markup based Link based argument version. It saves the engine the effort needed to extract the Passage Name from the Markup based Link.

<<include "bag">>

The second set of examples you supplied @Sage should work as you require, as shown by the following TWEE Notation based example. (which is a slightly modified version of your 2nd set).

:: StoryInit
<<set $bag = false>>

:: Start
<<linkreplace "bag">>
	\<<include "bag">>
	/* The following line is for testing purposes only, it and this comment can be safely deleted. */
	\<<replace "#outcome">>bag: $bag<</replace>>

/* The following line is for testing purposes only, it and this comment can be safely deleted. */
@@#outcome;bag: $bag@@

:: bag
<<set $bag = true>>\
you pickup the old worn bag.


0 votes
by (1.1k points)

You have a couple of options. Link, as click is on its way out, or the one I like for this LinkReplace.


DEPRECATED: This macro has been deprecated and should no longer be used. See the <<link>> macro for its replacement.

Check it out: 


<<if $bag is false>>
    On the ground you see a key.
    <<linkreplace "Pick up the bag">><<set $bag to true>>You have a bag.<</linkreplace>>
    There is nothing here.


by (200 points)

what i am now trying to use link replace for does not seem to work.

<<linkreplace "bag">><<include [[bag]]>><</linkreplace>>

which points to the passage [[bag]]. this is what passage [[bag]] looks like,

you pickup the old worn bag
<<set $bag to true>>

it shows the text but does not run the code inside the passage. then i tried running the code inside of link replace such as this

<<linkreplace "bag">><<set $bag to true>> you picked up the bag<</linkreplace>>

the varible is set to [] in the story init as shown

<<set $Bag= []>>

the varible bag is used as if statment to show if a link is show in the StoryMenu

<<if $bag is true>>[[Inventory]]<<else>><<endif>>

when i set it outside of the linkreplace the code works.

Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.