Hello, I’m very confused about an issue I’m currently having. I had it so the enemies were spawned randomly around the map using this function:
function init(self)
self.count = 51
num = math.random(20,40)
spawnx = 0
spawny = 0
spawnPos = vmath.vector3(0,0,0)
for i=0,50 do
spawnx = math.random(-1700,2800)
spawny = math.random(-1050,1400)
spawnPos = vmath.vector3(spawnx, spawny, 0)
enemy_id = factory.create("#enemy_factory", spawnPos, nil)
--pprint(enemy_id)
end
end
This works absolutely fine.
I then copied this code and moved it into a different function within the same script and now for some reason it no longer works.
if message_id == hash("difficulty") then
self.diff = message.difficulty
for i=0,50 do
spawnx = math.random(-1700,2800)
spawny = math.random(-1050,1400)
spawnPos = vmath.vector3(spawnx, spawny, 0)
enemy_id = factory.create("#enemy_factory", spawnPos, nil, {difficulty = self.diff}, nil)
end
end
The only difference here is that I pass data as a property to the factory objects.
These are the errors I am getting.