- e.png (41.09 KiB) Viewed 4835 times
Thanks,
Vulcan
Code: Select all
require "util"
require "defines"
if event.createdentity.name == "salt-extractor" then --[[Salt extractor build]]--
if glob.saltextractors==nil then
glob.saltextractors={}
glob.saltextractorscount=0
end
glob.saltextractorscount=glob.saltextractorscount+1
glob.saltextractors[glob.saltextractorscount]={}
glob.saltextractors[glob.saltextractorscount].entity=event.createdentity
end
if glob.saltextractors~=nil and event.tick%180==0 then --[[Salt extractor]]--
for i,_ in pairs(glob.saltextractors) do
if glob.saltextractors[i].entity.valid then
local pumps=game.findentities{{glob.saltextractors[i].entity.position.x-2,glob.saltextractors[i].entity.position.y-2,},{glob.saltextractors[i].entity.position.x+2,glob.saltextractors[i].entity.position.y+2}}
pumpnear=false
for y,_ in pairs(pumps) do
if pumps[y].name=="pipe-to-ground" then
liquid=pumps[y].getliquid()
if liquid ~= nil and liquid.amount~=0 then
pumpnear=true
break
end
end
end
if pumpnear==true then
glob.saltextractors[i].entity.insert{name="salt",count=1}
end
else
table.remove(glob.saltextractors,i)
end
end
end