Twine Version: 2.8.1.0, Sugarcube
Hi everyone - I’m making a game in which the player pulls a random painting from an array, then gets a random memory from an a mood-specific memory array based on the painting’s mood property. Example of one of those arrays:
<<set $joyMemoryBank to [
{
id: 0,
description: "first memory text goes here yada yada yada"
},
{
id: 1,
description: "second memory text goes here yada yada yada"
},
{
id: 2,
description: "third memory text goes here yada yada yada"
}
]>>
The object’s properties are put in a temporary value and the description is printed, and then the game deletes the object from the memory array based on the id value. Or at least, it’s supposed to. My code is correctly figuring out which index to delete at, but no matter what I try, it just deletes the last object in the array. So, after printing the text of the temp variable’s description property, it doesn’t actually delete the memory I want and may repeat it later (plus, the final memory in the array will never get selected).
Here’s what I got, along with my debug text:
<<if $currentPaintingPull.mood is "joy">>
<<set _currentMemory to either($joyMemoryBank)>>
I should delete at index position _currentMemory.id.
<<set $joyMemoryBank.deleteAt($joyMemoryBank.indexOf(_currentMemory.id))>>I deleted the memory from joyMemoryBank. It should no longer appear.
<</if>>
And then, no matter what the selection actually is, my $joyMemoryBank looks like this:
<<set $joyMemoryBank to [
{
id: 0,
description: "first memory text goes here yada yada yada"
},
{
id: 1,
description: "second memory text goes here yada yada yada"
}
]>>
Why is it doing this?
Hoping this doesn’t replicate any other questions - none of the other responses I read seemed right. Also hoping the answer isn’t contained in the last question I asked about this project, and I just couldn’t figure it out…