This is more of a technical question than an actual issue.
Say i have an array filled to the brim with objects with a whole list of values, however, these values are typically actually just 0 or false. Do i have to specify them as 0 or false or will Twine just ignore that value if i attempt to actually check for it.
Example array with objects:
<<set $Inventory = [
{
ID: 01,
Name: "TestItem1",
Equipped: false,
Description: "This is an item",
Strength: 1,
Intelligence: 1,
Agility: 0
},
{
ID: 02,
Name: "TestItem2",
Equipped: false,
Description: "This is another item",
Strength: 0,
Intelligence: 0,
Agility: 1
}
]>>
Assume i would be making many "items" for this array, would i have to specify it to have Strength: 0 or Intelligence: 0 every time.
Also when pushing a new object, how would i even go about that?
Assuming i pushed/made the array like this:
<<set $Inventory = [
{
ID: 01,
Name: "TestItem1",
Equipped: false,
Description: "This is an item",
Strength: 1,
Intelligence: 1
},
{
ID: 02,
Name: "TestItem2",
Equipped: false,
Description: "This is another item",
Agility: 1
}
]>>
What would happen if i ran a for loop like this?
<<for $i to 0; $i lt $Inventory.length; $i++>>
<<if $Inventory[$i].Equipped is true>>
<<set $PlayerStrength += $Inventory[$i].Strength>>
<<set $PlayerIntelligence += $Inventory[$i].Intelligence>>
<<set $PlayerAgility += $Inventory[$i].Agility>>
<</if>>
<</for>>
Since the value wouldn't exist for the object im assuming it would break the variable right?
But is the any easier way to actually make long arrays crammed full of objects with really long lists of objects, booleans, strings without actually having to manually fill out 0's and false on all values?