domian844

[OpenComputers] mcc reactor

Jan 19th, 2021 (edited)
1,085
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local a,b=component.proxy(component.list('redstone')()),component.proxy(component.list('transposer')())local c,d,e=0,0.2,96;local f={'MOX','Naq','Thor','Ura','MNqC','Fuel'}function sleep(d)checkArg(1,d,"number","nil")local g=computer.uptime()+(d or 0)repeat computer.pullSignal(g-computer.uptime())until computer.uptime()>=g end;function cS(h,i)return string.match(h or'',i)~=nil end;function cRS(h,j)return re(j,function(k,l)if cS(h,l)or k then return true end end,false)end;function map(m,n)local o={}for p,l in pairs(m)do table.insert(o,n(l,p,m))end;return o end;function fl(m,n,q)local o={}if q then for p,l in pairs(m)do if n(l,p,m)then o[p+1]=l end end else for p,l in ipairs(m)do if n(l,p,m)then table.insert(o,l)end end end;return o end;function re(m,n,r)local s;if type(r)=='boolean'or type(r)~='nil'or type(r)=='table'then s=r else s=0 end;for p,l in pairs(m)do s=n(s,l,p,m)end;return s end;function each(m,n)local o={}for p,l in pairs(m)do o[p]=n(l,p,m)or nil end;return#o>0 and o or m end;R={}function R:on()a.setOutput(self.rrS,15)return true end;function R:off()a.setOutput(self.rrS,0)sleep(0.2)return false end;function R:phCls(t)each(t,function(l,p)b.transferItem(self.bufferS,self.rrS,1,2,l)end)return true end;function R:phFuel(t)each(t,function(l,p)b.transferItem(self.fuelS,self.rrS,1,2,l)end)return true end;function R:plCls(t)each(t,function(l,p)b.transferItem(self.rrS,self.coolingS,1,l.slot)end)end;function R:plFuels(t)each(t,function(l,p)b.transferItem(self.rrS,self.coolingS,1,l.slot)end)end;function R:getClsSt()return map(fl(self.stack,function(l)return l and cS(l.label,'Coolant')end,true),function(l,p)return{label=l.label,damage=l.damage,maxDamage=l.maxDamage,slot=p}end)end;function R:getFuelSt()return map(fl(self.stack,function(l)return l and cRS(l.label,f)end,true),function(l,p)return{label=l.label,damage=l.damage,maxDamage=l.maxDamage,slot=p}end)end;function R:getHtd()return fl(self.clsSt,function(l)return l.damage>=e end)end;function R:getDepleted()return fl(self.fuelsSt,function(l)return cS(l.label,'Dep')end)end;function R:getStack()return b.getAllStacks(self.rrS).getAll()end;function R:getControlSt()local u={}for v=0,5 do u[v]=a.getInput(v)end;return re(fl(u,function(l,p)return p~=self.rrS end,true),function(k,l)return k and true or l>0 end,false)end;function R:getSt()if#self.clsSt==#self.cls and self.state then return true end;return self:off()end;function R:updateTick()self.stack=self:getStack()self.clsSt=self:getClsSt()self.state=self:getSt()if#self.clsSt<#self.cls then self.state=self:off()return self:phCls(self.cls)end;local w=self:getHtd()if#w>0 then self.state=self:off()self:plCls(w)self:phCls(map(w,function(l)return l.slot end))end;self.state=self:getSt()end;function R:init()for p=0,5 do local x=b.getInventoryName(p)if x~=_ then if cS(x,'Chamber')then self.rrS=p elseif cRS(x or'',{'Chest','barrel','Drawer'})then local y=b.getStackInSlot(p,2)if y and cS(y.label,'Coolant')then self.bufferS=p end;if y and cRS(y.label,f)then self.fuelS=p end elseif cRS(x or'',{'Chest','barrel','Drawer','chest'})then self.coolingS=p end end end;self.stack=self:getStack()self.clsSt=self:getClsSt()self.fuelsSt=self:getFuelSt()if#self.clsSt<#self.cls then self:phCls(self.cls)end;if#self.fuelsSt<#self.fuels then self:phFuel(self.fuels)end;self.state=self:getSt()return true end;local z={}setmetatable(z,{__index=R})z.cls={1,5,8,12,17,19,24,31,36,38,43,47,50,54}z.fuels={2,3,4,6,7,9,10,11,13,14,15,16,18,20,21,22,23,25,26,27,28,29,30,32,33,34,35,37,39,40,41,42,44,45,46,48,49,51,52,53}z:init()local A=function()if not z:getControlSt()then if z.state then z.state=z:off()return end;return elseif not z.state and#z.clsSt==#z.cls then z.state=z:on()end;z:updateTick()if c>=10 then z.fuelsSt=z:getFuelSt()if#z.fuelsSt<#z.fuels then z:phFuel(z.fuels)end;local B=z:getDepleted()if#B>0 then z:plFuels(B)z:phFuel(map(B,function(l)return l.slot end))end;c=0 end;c=c+d end;while true do A()sleep(d)end
  2.  
RAW Paste Data