0 votes
by (130 points)

in manual:

(set: $dagger to (datamap: "id", "dagger", "cost", 10, "damage", 1))
(set: $weapon to $dagger)
Your current weapon is a (print: $weapon's id).

in real life works:

(set: $dagger to (dm: "id", ["dagger"], "cost", 10, "damage", 1))
(set: $weapon to $dagger)
Your current weapon is a (print: $weapon's "id").


Use Twine 2.2.1 , Hallowe 2.1.0

1 Answer

+1 vote
by (149k points)

The current Harlowe 2.x syntax highlighter used by the Twine 2.x application only knows about the newer 'short' alias of macros like (datamap:) and (array:), which is why it now marks the 'long' form of the related macro names as it does.

The story format's JavaScript engine on the other hand supports both the 'long' and 'short' forms of these macros, so both of your examples will actually work when your generated story HTML is run.

So there isn't actually anything invalid with the syntax of either of your usages of the datamap macro, it's the syntax highlighter that is wrong.

note: there is no need to wrap the "dagger" value in your 2nd example within an anonymous hook.

by (130 points)
Ok. Thanks for the quick and informative response (:
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.