(history: where) error message

Twine Version: Harlowe 3.2.2

Could someone please explain to me what to do when Twine gives me this “The (passage:) macro’s 1st value is a passage datamap, but should be (optional) a string.”? Thanks!

Ideally when you’re asking why specific code is throwing an error you would include an example of the code that is causing that error.
eg. This code prints the name of the ‘current’ Passage.

Name of current Passage: (print: (passage:)'s name)

Without an example of the code that produced the error message you mentioned I had to guess what you might be trying to do to cause it.

Based on the wording of the error message it appears you are trying to pass a Datamap value, instead of a String value, as the 1st parameter to your (passage:) macro call.
eg. You’re trying to do something like this…

<!-- Try using a Datamap variable to obtain specific Passage datamap instance -->
(set: _datamap to (dm: "propertyname", "value"))
(set: _erroneous to (passage: _datamap))

…instead of doing something like…

<!-- Use a String variable to obtain specific Passage datamap instance -->
(set: _string to "Other")
(set: _other to (passage: _string))

note: Obviously the names of your variables are likely to be different to the ones I used in the above examples.

My code currently looks like this:
(if:(history: where (passage:it)'s tags contains “hallie”)'s length >= 1)[And then whatever text I want to put here]

And this is what’s causing that message. I’m not sure what I need to change.

I suggest looking at the 3rd example mentioned in the (history:) macro’s documentation, you are using the it keyword operator where the examples use the its keyword operator.

hey, i have the same problem.

My code is: (unless:(history: where (passage:it)'s tags contains “Week_01”)'s length % 7 is 0)

I get the same error message. putting in “its” doesnt work, its not a valid code and returns the error message “its” is not defined when used in a passage macro.
I dont get the error message when i use the string name of a specific passage instead of it, which is what the passage macro expects to be there. it seems the macro gets confused by trying to reference EVERY passage in the history. I have also found no way to instead just manually add every single passage in the history to be counted, because it doesnt seem to support just adding multiple passage macros inside of a history macro.
All this is REALLY confusing to me, because the code that isnt working is one of the default code templates you just fill out with the checkboxes of the editor.

If anyone finds a solution or workaround i would be really grateful.

For reference, i am trying to build a system where you go through a choice of three different events in a loop until you have done so seven times, which is supposed to trigger an event that is contextual on which kinds of event were visited how often in the previous cycle.

Like you visited the event “work” seven times in a row without visiting something different aswell triggers the event “overworked”, causing the option “work” to be unavailable for the next choice.

Looks like (history:) gives a list of actual passages, not passage names. So it will be a passage object, not a string name of a passage.

I suspect you want this? At least that should fix the syntax error.

(unless: (history: where its tags contains "Week_01")'s length % 7 is 0)

Ah yes it works it works it works!!!


1 Like