Hello all. I’m new here, new to coding, and new to using Twine. I’ve been working on a story for a week or so now, and I’m having trouble figuring out why I can’t get the button macro to work. I’ll post the code below. I try testing sections in their own passages at first before implementing them into the story.
<<set $coins to 200>> <<set $melee= >> Welcome to the shop! You have <span id=“money”><<print $coins>></span> coins. What would you like to buy? <span id=“sold”></span> <span id=“cash”></span> <span id=“nocash”></span> <span id=“nosell”></span> <<button “Buy Steel Sword for 100 coins”>> <<if $coins gte 100>> <<set $melee.push(“Steel Sword”)>> <<set $coins to ($coins - 100)>> <<replace “#money”>><<print $coins>><</replace>> <<replace “#cash”>>You bought a Steel Sword! Don’t forget to visit the Inventory page to equip it!<</replace>> <<elseif $coins lt 100>> <<replace “#nocash”>>Sorry, you don’t have enough coins for this item.<</replace>> <</if>> <</button>>
There’s another section that is basically identical except that it replaces buy with sell (using the “sold” and “nosell” span ids. I keep getting the
error: <<set>>:bad evaluation: invalid or unexpected token in a pop-up on my browser. Any help would be greatly appreciated!