It looks like you're new here. If you want to get involved, click one of these buttons!
We're splitting this population: Prime: <<print $units[$unit]>> <<set $original = $units[$unit] ; $split = $units[$unit] ; $original[3] = Math.ceil($original[3]/2) ; $split[3] = Math.floor($split[3]/2) >> Original: <<print $original>> New Pop: <<print $split>> UNIT: <<print $units[$unit]>> [[Dashboard]]
We're splitting this population: Prime: Hoafolk Clan, 34, 27, 28, 910, 0, 100, 20, 20, 71,44,91,63,62, 0,0,0, 0,0,14 Original: Hoafolk Clan, 34, 27, 7, 910, 0, 100, 20, 20, 71,44,91,63,62, 0,0,0, 0,0,14 New Pop: Hoafolk Clan, 34, 27, 7, 910, 0, 100, 20, 20, 71,44,91,63,62, 0,0,0, 0,0,14 UNIT: Hoafolk Clan, 34, 27, 7, 910, 0, 100, 20, 20, 71,44,91,63,62, 0,0,0, 0,0,14
Comments
I'm thinking this would be consistent if copying these arrays copies not the values within the arrays themselves but references to variables elsewhere. So using the simple declaration quoted above, I'm not copying values, I'm copying references. Then whenever I try to modify $split, I'm actually modifying the floating variables floating out there which $units[$unit] also references.
So if that is all correct, the question becomes: how do I copy the actual values and not references?
The answer, for those playing at home, is: