Hello everyone,
I'm trying to get Sugarcube's remove macro to work. Even if I use the example code in Sugarcube's documentation, which is
I'd like a <span id="huge-cupcake">humongous </span>cupcake, please.
<<remove "#huge-cupcake">>
on a fresh Twine story, I keep on getting the same error:
Error: <<remove>>: no elements matched the selector "#huge-cupcake"
What am I doing wrong? Is there any 2.0 syntax that I'm missing?
Thanks!
Comments
And... there's no reason to use a <span> if you haven't defined it in css, so it wouldn't surprise me if <<remove>> was looking for a css selector.
So you need to try something like:
Any other ideas?
<<click "test">><<remove "#huge-cupcake">><<set $hashugecupcake to 1>><</click>>
And then click on the word test.
If this works you can probably also try removing the css. I may have been wrong about the need for css there.
(You don't need the set macro there, I just put it in because that seems to be what the example is doing - having the player take a cupcake.)
and on another passage I have this:
And, I keep on getting an error.
The cupcake code was taken straight from the Sugarcube documentation. I was trying to debug this with the simplest possible code (example code, new Twine story), which was not working either. It's weird that wrapping it in a click elements works. I have no clue how to solve the issue though.
You could try putting the <<remove>> in the PassageDone special passage. That may work, since that should execute the <<remove>> code after the passage text is determined, but before the passage is displayed. Alternatively could used <<timedcontinue>> in the replace set, but that will produce flickering.
That said... I'm confused about why you need to use <<remove>> for this purpose?
Why not just go:
?
Write in the StoryInit passage:
<<set $rootsStolen to false>>
And then go and initialise every other variable you use there - it's best practice, for these reasons. I had assumed all variables were initialised.
Try putting in your start passage:
If that doesn't work, then something is going on with your variables.
Thank you so much for the help, Claretta
BTW, if you want to use those kind of signs, you need to write <<if $rootsStolen == false>>.
Double equal signs is equal to "to".
A double equals sign == is used for comparison. <if $rootsStolen == false>>
People get = & == confused so that is one reason it can help to use the to and is keywords instead.
So I prefer to use is and to, because if I make a mistake, I will be notified.
Regardless. As you've found out, this is a job for the <<if>> macro anyway.
<div id = "error"> </div>
<<replace "#error">> do stuff <</replace>>
The last line is where I get the error.
Okay so this works, with proceed only taking you to the next passage if the name is letters only, clicking on it otherwise will tell you if its not and not "goto" the next passage. I did understand before posting my error message that the post above me had to do with my error, and the entire thread, but I wasn't clear as to the why.