Twine Version: 2.6.0
Story Format: Sugarcube 2.36.1
Hey - hoping someone can help me with something I’m having trouble getting my head around. This is my first time working with datamaps and I may be missing something extremely obvious! The code below isn’t for a specific project, I’m just modelling examples to try and understand how it all works, so very open to suggestions for changes.
I’m setting up the datamap as follows in StoryInit:
<<set $NPCs to {
"NPC1":
{
name: "",
description: "",
location: "",
},
"NPC2":
{
name: "",
description: "",
location: "",
},
"NPC3":
{
name: "",
description: "",
location: "",
}
}>>
I’m then using a widget to allocate random values to name/description/location. So far so good - this all seems to be working fine.
Where I’m getting stuck is trying to figure out how to pull out an entry from the datamap based on a specific value. For example, one of the possible values for “location” is “beach”. How could I identify all the entries in the datamap that have “beach” as a location? And then how could I, for example, print the names of everyone who lives at the beach?
I’ve been Googling this and testing different stuff for hours with no luck whatsoever, so any help would be appreciated. An explanation in simple terms doubly so - I’m not a programmer at all and struggle to grasp this stuff sometimes!
Thanks in advance and sorry if this is a stupid question!