0 votes
by (370 points)
edited by

Using Harlowe 2-1-0 in Twine 2-2-1. I have a simple inventory, to which I want to add different items as we go. These will mostly be just "Key Items," so the overall inventory should be pretty sparse. I want it set up so that whenever an item is added, you can click on the item's name, which is displayed in the Inventory screen from the array, and it will in turn display the item's description and other info below. However, when I put the (click:) macro in, I get the "☕ Invalid or unexpected token►This error message was reported by your browser's Javascript engine. I don't understand it either, but it usually means that an expression was badly written." message, linked to the (click: "shotgun").

Here's the code for my inventory screen:

(if: $inv's length > 0)[You have (print: $inv.join(", ")) in your backpack, and $money dollars in your pocket.](else:)[You have nothing in your backpack, but you do have $money dollars in your pocket.]
(if: $inv contains "your shotgun")[(click: “shotgun”)[(print: $shotguntext)]]

I've also tried the expression with putting the text from $shotguntext into its own passage, and trying to display that passage instead, but it still has the same problem. What's puzzling me is that it worked previously, and in a sepparate instance where I use nearly identical code to display "Messages" in an array that is the cell phone. The only difference here is that I use (click-replace:) for that section, and I tried using that here as well, and it didn't do me any good.

Here's the code that puts the shotgun into the inventory, and sets it's properties:

(set: $sgowner to "Mr. Gilmore")
(set: $inv to $inv + (a: "your shotgun"))
(set: $sgammo to 20)
(set: $shotguntext to "The shotgun you got from $sgowner's office. Simple, effective, and deadly, this weapon will undoubtedly save your life multiple times.

Ammo: $sgammo")

Am I missing something simple here?

1 Answer

+1 vote
by (68.6k points)
selected by
Best answer
Look at the macro invocation carefully.  You've used curly/typographic quotes, which are not valid syntactically, on its argument.  You need to switch to using normal quotes.

I'm guessing a copy/paste from an external source, probably a word processor, is the culprit.
by (370 points)
Thanks so much! It's amazing how little things like that can make all the difference. I've been staring at this for a few hours now trying to figure it out, but I was focusing on the context rather than the actual figures.