Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

Sugarcube 2 - Replacing placeholder text based on conditions

$
0
0
I got my original problem fixed but have run into another one. Is it possible to do what I'm wanting to do below? That is, can I have the interactive text replaced with something if the crate has been opened using the methods I'm using, or am I going about it completely wrong?
<<silently>>
<<set $roomWidth = 16>>
<<set $roomLength = 12>>
<<set $crateOpen = "{{{>> }}}In the northwest corner, there is a small crate (you opened it earlier).">>
<<if $cave_room1_crate == "Open">><<replace "#crateText">>$crateOpen<</replace>><</if>>
<</silently>>
{{{>> }}}You find yourself in a small room. The dimensions of the room are <<print $roomWidth>> feet by <<print $roomLength>> feet. 

{{{>> }}}Exits are [[north|cave_room6]] and [[west|cave_room2]].

<span id="crateText">{{{>> }}}In the northwest corner of the room, there is a small <span id="crate"><<click "crate">><<replace "#crate">>crate<</replace>><<replace "#output">>Inside the crate, you find a <span id="item">small silver key</span>, a large <span id="keyItem">Yellow Key</span>, and <span id="gold">25 gold</span>.<</replace>><<set $playerScore +=25>><</click>><<set $cave_room1_crate = "Open">></span>;</span> next to it, a medium-sized <span id="chest"><<click "chest">><<replace "#chest>>chest<</replace>>.<</click>>.</span> <span id="torch">A <<click "torch">><<replace "#torch">><</replace>><<replace "#output">>You take the torch from the wall.<</replace>><</click>> hangs on the wall.</span>

<span id="output"></span>

I tried moving the "If" statement lower in the code (in case it wasn't working because I was attempting to perform a function before the tag was created), but that still threw the "no elements matched selector" error. Thoughts?

Viewing all articles
Browse latest Browse all 1844

Trending Articles