Prevent equipment pickup of mined Entity
Posted: Mon Mar 28, 2016 5:00 pm
Hello all,
I am busy attempting to create a mod that I need to prevent the player from picking up an item after it has been mined. I've left the appropriate code below to give some context.
Please bare in mind that I know I need to make it multiplayer friendly. Will get there eventually.
I am busy attempting to create a mod that I need to prevent the player from picking up an item after it has been mined. I've left the appropriate code below to give some context.
Code: Select all
-- 1. Check if the player mined a lamp
-- 2. Check if lamp is in combined table
-- 3. If so, destroy pole entity and prevent lamp from being added to inventory
-- 4. Add electric pole to inventory
game.on_event(defines.events.on_preplayer_mined_item, function(event)
if (event.entity.name == "small-lamp") then
for k,v in pairs(global.combined) do
if (event.entity == v.light) then
v.light.destroy()
v.pole.destroy()
game.get_player(1).character.insert({name="small-electric-pole", count =1})
end
end
end
end)