So I have a Datamap that contains the character's statistics and the values of each statistic.
This datamap I call $Attributes.
I can access elements of this because I know what they are. $Attributes's Ferocity, for instance. At first this seemed like a convienent data management method, but now I'm running into an issue.
What I want to do is add $Attributes to another Datamap (for instance, you have reached a new level up, or something), and have the result be adding the Values of each datamap together. The thing that caught me off guard is that Harlowe's implementation for addition of datamaps just uses the values from the rightmost Datamap when they are added (if the name is in both Datamaps).
Is there a way to get this working with Datamaps, or should I rewrite all my code to use arrays?
Comments
Method to Add Datamaps 1 and 2
datamap Datamap1
datamap Datamap2
datamap Output
array Names1 = (datanames (Datamap1)
array Names2 = (datanames (Datamap2)
array Values1 = (datavalues (Datamap1)
array Values2 = (datavalues (Datamap2)
x = 0
y = 0
while (x < length of Names2)
{
if (Names1 contains Names2[x])
{
y = 0
while (y < length of Names1)
{
if( Names1[y] == Names2[x])
{
add Names1[y] to Output, add Values1[y] + Values2[x] to Output
}
y++
}
}
else
{
add Names2[x] to Output, add Values2[x] to Output
}
x++
}
x = 0
while (x < length of Names1)
{
if (Names2 does not contain Names1[x])
{
add Names1[x] to Output, add Values1[x] to Output
}
x++
}