Hey, losing my mind on arrays with verse, I think there’s something big i’m missing.
Let’s use the following code :
var Array1 : []int = array{}
if(set Array1[0] = 5){}
Print(ToString(Array1.Length))
This will print “0”, where I would have expected the value to be 1.
The documentation is not clear as it only build arrays from contructors directly, and doesn’t dynamically assing a value to an Index which doesn’t exist yet.
The end goal is to be able to dynamically set arrays.
I’m especially confused as in the doc, there’s this 4. Tracking Players Using Maps
it’s using this code :
var PlayerMap : [player]int = map{}
AllPlayers := GetPlayspace().GetPlayers()
for (Agent : AllPlayers, TeamPlayer := player[Agent], FortCharacter := TeamPlayer.GetFortCharacter[]):
if(set PlayerMap[TeamPlayer] = 0, WeaponTier := PlayerMap[TeamPlayer]):
Print("Assigned Player to PlayerMap with Tier {WeaponTier}")
FortCharacter.EliminatedEvent().Subscribe(OnPlayerEliminated)
To me, it looks liek it’s assigning a value to an index that doesn’t yet exist, but I must be missing something.
If someone could help me figure it out, would be much appreciated