scripts.on_event not working
Posted: Sat Jul 02, 2016 7:50 am
im trying to set up a script that will upon an entity's death create an entity at that position. i think im close to getting it to work but im having issues with factorio telling me (attempt to index gobal 'script' a nil value). im not sure what is wrong with it as any references to script.on_event look the same as what i did.
here is the code
here is the code
Code: Select all
local oretest = {}
script.on_event(defines.events.on_entity_died, function(event)
if event.entity.name == "small-biter" then
local smallbiter = event.entity
local targetpos = smallbiter.surface.find_non_colliding_position("copper-ore", smallbiter.position, 10, 1)
end
local tore = player.surface.create_entity({
name = "copper-ore",
position = targetPos
})
end)