Twine Version: web, version 2.3.15
Story Format: Harlowe 3.2.3
tl;dr: i call a passage via the (display:) function with a temporary variable and the passage that is doing the displaying yells at me.
the long version:
Sorry if this is a duplicate question but I’ve been searching for a day and haven’t found the answer ^^;
So, in the story I’m writing, every so often, an event happens and the character gets a random item. I made a passage called “item generator” and call it with the display function at random intervals throughout the story game.
The code in “item generator” looks like this:
{
(set: _fullItemNames to (datanames: $allItems))
(set: _fullItemDeets to (datavalues: $allItems))
(set: _randItem to (random: 1,_fullItemNames's length))
(set: _itemKey to _fullItemNames's (_randItem))
(set: _itemValue to _fullItemDeets's (_randItem))
(if:$invo does not contain _itemKey)
[
=><=
(b4r-color:blue)+(b4r:"ridge")[You acquired the item "_itemKey".]
(set: $invo to it + (dm:_itemKey,_itemValue))
]
}
This works fine!
But whenever a passage calls the “item generator” it will create the item and add it to the inventory and display the information as intended, but I also get the error “There isn’t a temp variable named _itemKey in this place.”
A sample passage (called “Test”) that it gets called on looks like this:
The road was (either: "long", "gloomy", "dark", "quiet", "bustling") and you weren't sure what to do.
(display:"item generation")
Maybe you should head into [[the city->City 1]] or [[the complex->Complex 1]]. Or maybe [[just walk|Test]]?
And every time the “You acquired _itemKey” message appears, so does the error.
I don’t understand why Test is looking for _itemKey when it was:
- created in “item generation” and
- isn’t referenced in the code for “Test” at all.
I don’t want to have to replicate the code in “item generation” every time I use the function (especially since it’s uh… much larger than this but I’m parring it down so y’all don’t need to read several dozen lines of case uses) but I also don’t want to deal with this error every time so… help?