Descrease/Increase values on datamap

Hi I’m using Twine Harlowe 3.1 and plan on using datamaps to help with variables and choices in my narrative.
Is it possible to increase and decrease values on 'Key’s within datamaps?

For example,
“Messages, 2” would become “Messages, 1” after the passage containing a message was opened.

Would really appreciate any help,

Thank you!

Please use the New Topic form’s “optional tags” field to state the name and version/series number of the Story Format you are using, it makes it easier for others to quickly see which story format the topic is associated with.

note: You didn’t include an example of the DataMap in question, so I will assume that the initialisation of it looks something like the following…

(set: $phone to (dm: "Messages", 2))

You can use the (set:) macro to change the value of a DataMap property.

(set: $phone to (dm: "Messages", 2))
Messages: (print: $phone's Messages)

(set: $phone's Messages to it - 1)
Messages: (print: $phone's Messages)

warning: Due to how Harlowe has implemented its collection type objects (like Array and DataMap) you may notice some delays in the processing of a Passage’s content if your code does a lot of property updating or looping through the contents of Arrays. If you are planning on doing such things a lot in your project then you may want to consider switch to another story format like SugarCube.

Sorry, I didn’t look over properly the tags. I appreciate you getting back to me with help.

Is it only possible to change the values within the same passage as the original data map? As I would like to have the value change throughout.
So for instance can the value decrease in another passage, and constantly change values in different passages.

(set: $phone to (dm: “Messages”, 2))
Messages: (print: $phone’s Messages)
[[Message 1 -> Message 1]]

The in the “Message 1” passage the value would have decreased

(set: $phone’s Messages to it - 1)
Messages: (print: $phone’s Messages)

Sorry if this makes little sense, I just want the best way to track changing values. Thanks for getting back to me, I’m a bit new in understanding Twine fully.

Once the DataMap story variable has been initialised you can change the value of its properties in either the current or later passages.

[[Message 1 -> Message 1]]

The above Markup based link has an invalid white space character between the -> direction operator and the start of the Target Passage Name, this will result in the Auto Create Missing Passages feature of the Twine 2.x application creating a Passage with a name of " Message 1" (note the space before the M)

<!-- BAD Markup based links. -->
[[Link Text-> Target Passage Name]]
[[Link Text| Target Passage Name]]
[[ Target Passage Name <- Link Text]]

<!-- GOOD Markup based Links. -->
[[Link Text->Target Passage Name]]
[[Link Text|Target Passage Name]]
[[Target Passage Name<-Link Text]]