Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local lb,ub=0,4095
- local delay=1
- if lb<0 then lb=0 end
- if ub>4095 then ub=4095 end
- local cmp=component or require"component"
- local comp=computer or require"computer"
- local interrupt
- local ut=comp.uptime
- local sleep=function(secs) dl=ut()+secs;while ut()<dl do local s=comp.pullSignal(dl-ut()); if s=="interrupted" then interrupt(); dl=0 end end end
- local et=cmp.proxy(cmp.list("ender_tank")())
- local ga=function() return et.getTankInfo()[1].contents.amount end
- local gc=function() return et.getTankInfo()[1].capacity end
- local gf=function() return et.getFrequency() end
- local sf=function(nf) et.setFrequency(nf) end
- local chf=function(d) local cf=gf();local nf=cf+d;if nf>=lb and nf<=ub then sf(nf) end end
- running=true
- interrupt=function() running=false end
- while running do
- if ga()<=0 then chf(-1)
- elseif ga()>=gc() then chf(1)
- end
- sleep(delay)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement