I'm not understaning my table return value.
Under initiate I have:
Code: Select all
if global.deployed_mine == nil then
global.deployed_mine = {}
end
Code: Select all
script.on_event(defines.events.on_trigger_created_entity, function(event)
local entity = event.entity
if entity.valid and NELandmine(entity) == "landmine" then
global.deployed_mine[entity.unit_number] = {mine=entity, time=event.tick}
writeDebug(#global.deployed_mine) -- print value
end
end
Why dies it not start at "1" on the first read, since it happens after the first add and then goes to 2, 3, 4...?

I guess the next question is, how do I add to the table each time the conditions are true and how do I remove.
With remove I was using:
Code: Select all
local function On_Death(event)
local entity = event.entity
if entity.valid and NELandmine(entity) == "landmine" then
if global.deployed_mine[entity.unit_number] then
global.deployed_mine[entity.unit_number] = nil
end
writeDebug(#global.deployed_mine) -- print table count
end
end

Not sure what I'm doing wrong here.
Thanks.