0 votes
by (150 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 (159k 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 (150 points)
Ok. Thanks for the quick and informative response (: