I am trying to create a simple creature kill counter to start learning the scripting language however, I cannot seem to access the index of my map - it always returns false on assignment.
Below is the code:
# Load player profile and give weapons
OnPlayerSpawn(InPlayer : agent) : void =
if (set PlayerKillCounts[InPlayer] = PlayerStruct { CreatureEliminations := 0 }):
if(SpawnItemGranter:item_granter_device := ItemGranters[0]):
SpawnItemGranter.GrantItem(InPlayer)
# Increase kill count
OnCreatureElimination(InPlayer : ?agent) : void =
if (InPlayer?):
if (Player:PlayerStruct := PlayerKillCounts[InPlayer]):
if (set PlayerKillCounts[InPlayer?] = PlayerStruct { CreatureEliminations := Player.CreatureEliminations +1 }):
# TODO: Spawn another
else:
Print("Could not find player")
# Holds player data
var PlayerKillCounts : [agent]PlayerStruct = map{}
# Configure game
OnBegin<override>()<suspends>:void=
for (Spawner : PlayerSpawners):
Spawner.SpawnedEvent.Subscribe(OnPlayerSpawn)
if(CreaturePlacer:creature_placer_device := CreaturePlacers[0]):
CreaturePlacer.EliminatedEvent.Subscribe(OnCreatureElimination)
I always receieve “Could not find player” in the “LOG” tab when in session (start game) after a kill. I can’t figure out how to debug what is inside of the “InPlayer” object other than the fact it is an agent (that I would expect is the same as I got on the player spawner)
Any help appreciated, my struct looks like this:
PlayerStruct := struct:
CreatureEliminations : int