Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- для работы нужен реактор с 6-ю реакторными камерами и сундук, поставленный вплотную
- к той камере, к которой подключен адаптер, нельзя допускать, чтобы адаптер был подк-
- лючен сразу к двум камерам, это дает 50%-й шанс, что программа не увидит сундук.
- Я загрузил сюда несколько основных схем на уране и на MOX (возможно будут добавлены еще схемы),
- также есть встроенный "нагреватель", но с ним есть нюансы, пользоваться им можно, но осторожно.
- Программа сама расскажет чего не хватает в сундуке, для выбранной вами схемы.
- Штука удобная, всем рекомендую :)
- --]]
- local com = require("component")
- local os = require("os")
- local red = com.redstone
- local term = require("term")
- local reactor = com.getPrimary("reactor_chamber")
- local rmaxslot = reactor.getInventorySize()
- local sides = {}
- sides[1] = "DOWN"
- sides[2] = "UP"
- sides[3] = "NORTH"
- sides[4] = "SOUTH"
- sides[5] = "WEST"
- sides[6] = "EAST"
- local chests = {}
- chests[1] = "chest"
- chests[2] = "diamond"
- chests[3] = "crystal"
- chests[4] = "gold"
- chests[5] = "iron"
- chests[6] = "obsidian"
- local uran = {}
- uran["eu420"] = "4oxtxxox oxxoxx4x x4xx4xxooxxoxxox x4xx4xx4x xo xo xo"
- uran["eu230"] = "1111oxsxt1111 oxok1111oxoxs o oxoxoxoxoxoxoxs o oxsxsx"
- local mox = {}
- mox["eu12001"] = "oddopoddod22dpd22doddopoddooddopoddod22dpd22doddopoddo"
- mox["eu12002"] = "4ddoodd4 dttddttd oddooddo oddooddo dttddttd 4ddoodd4 "
- local function getChest()
- local ch = 0
- for i=1,#chests do
- if pcall(com.getPrimary,chests[i]) then
- ch = chests[i]
- return ch
- end
- end
- if ch == 0 then
- print("Где сундук?")
- end
- end
- local chest = com.getPrimary(getChest())
- local maxslot = chest.getInventorySize()
- local function choose()
- local choice = 0
- print("Выберите тип реактора\n1.Уран\n2.MOX")
- local typ = tonumber(term.read())
- if typ == 1 then
- print("Выберите схему\n1. На счетверенных стержнях, выдает 420 EU/t\n2. на одинарных стержнях, выдает 230 EU/t")
- while choice == 0 do
- choice = tonumber(term.read())
- if choice == 1 then
- return uran["eu420"], true
- elseif choice == 2 then
- return uran["eu230"], true
- else
- choice = 0
- print("Ошибка ввода, повторите попытку")
- end
- end
- elseif typ == 2 then
- print("Выберите схему\n1. с теплоёмкими реакт. пластинами, выдает примерно 1200 EU/t\n2. на четверных стержнях, выдает примерно 1200 EU/t")
- while choice == 0 do
- choice = tonumber(term.read())
- if choice == 1 then
- return mox["eu12001"], false
- elseif choice == 2 then
- return mox["eu12002"], false
- else
- choice = 0
- print("Ошибка ввода, повторите попытку")
- end
- end
- end
- end
- local function reactorIsEmpty()
- local s = reactor.getAllStacks()
- local c = 0
- for k,v in pairs(s) do
- c=c+1
- end
- if c == 0 then
- return true
- else
- return false
- end
- end
- local function scheme (side,uran,str)
- local rvso = {}
- local rvsoc=0
- local rvgx = {}
- local rvgxc=0
- local ruq4 = {}
- local ruq4c=0
- local rhss = {}
- local rhssc=0
- local rph = {}
- local rphc=0
- local rvd = {}
- local rvdc=0
- local rv = {}
- local rvc=0
- local rvk = {}
- local rvkc=0
- local rhs = {}
- local rhsc=0
- local rhsk = {}
- local rhskc=0
- local rus1 = {}
- local rus1c=0
- local rud2 = {}
- local rud2c=0
- --"oddopoddod22dpd22doddopoddooddopoddod22dpd22doddopoddo"
- --"4ddoodd4 dttddttd oddooddo oddooddo dttddttd 4ddoodd4 "
- --reactorMOXSimple reactorMOXDual reactorMOXQuad reactorPlatingHeat
- --[[ o = reactorVentSpread(Компонентный ТВод); x = reactorVentGold(Разогнанный ТВод); 4 = reactorUraniumQuad;
- t = reactorHeatSwitchSpread(Компонентный ТОбм); 1 = reactorUraniumSimple; 2 = reactorUraniumDual;
- v = reactorVent (Теплоотвод rv); c = reactorVentCore(Реакт ТВод rvk); s = reactorHeatSwitch(ТОбм rhs)
- k = reactorHeatSwitchCore(Реакт ТОбм rhsk); p = reactorPlatingHeat(Теполёмк реакт пластина); d = reactorVentDiamond(улучш твод)--]]
- for i=1,maxslot do
- local slot = chest.getStackInSlot(i)
- if slot ~= nil then
- --print(i.." = "..slot.name.." ("..slot.qty..")")
- if slot.name == "reactorVentSpread" then
- rvsoc = rvsoc+1
- rvso[rvsoc]=i
- elseif slot.name == "reactorVentGold" then
- rvgxc = rvgxc+1
- rvgx[rvgxc]=i
- elseif slot.name == "reactorHeatSwitchSpread" then
- rhssc = rhssc+1
- rhss[rhssc]=i
- elseif slot.name == "reactorPlatingHeat" then
- rphc = rphc+1
- rph[rphc]=i
- elseif slot.name == "reactorVentDiamond" then
- rvdc = rvdc+1
- rvd[rvdc]=i
- elseif slot.name == "reactorVent" then
- rvc = rvc+1
- rv[rvc]=i
- elseif slot.name == "reactorVentCore" then
- rvkc = rvkc+1
- rvk[rvkc]=i
- elseif slot.name == "reactorHeatSwitch" then
- rhsc = rhsc+1
- rhs[rhsc]=i
- elseif slot.name == "reactorHeatSwitchCore" then
- rhskc = rhskc+1
- rhsk[rhskc]=i
- end
- if uran then
- if slot.name == "reactorUraniumSimple" then
- rus1c = rus1c+1
- rus1[rus1c]=i
- elseif slot.name == "reactorUraniumDual" then
- rud2c = rud2c+1
- rud2[rud2c]=i
- elseif slot.name == "reactorUraniumQuad" then
- ruq4c = ruq4c+1
- ruq4[ruq4c]=i
- end
- else
- if slot.name == "reactorMOXSimple" then
- rus1c = rus1c+1
- rus1[rus1c]=i
- elseif slot.name == "reactorMOXDual" then
- rud2c = rud2c+1
- rud2[rud2c]=i
- elseif slot.name == "reactorMOXQuad" then
- ruq4c = ruq4c+1
- ruq4[ruq4c]=i
- end
- end
- end
- end
- rvsoc=1
- rvgxc=1
- ruq4c=1
- rhssc=1
- rphc=1
- rvdc=1
- rvc=1
- rvkc=1
- rhsc=1
- rhskc=1
- rus1c=1
- rud2c=1
- for i=1,rmaxslot do
- if string.sub(str,i,i) == "o" then
- reactor.pullItem(side,rvso[rvsoc],1,i)
- rvsoc=rvsoc+1
- elseif string.sub(str,i,i) == "x" then
- reactor.pullItem(side,rvgx[rvgxc],1,i)
- rvgxc=rvgxc+1
- elseif string.sub(str,i,i) == "4" then
- reactor.pullItem(side,ruq4[ruq4c],1,i)
- if ruq4[2] ~= nil then
- if chest.getStackInSlot(ruq4[ruq4c]) == nil then
- ruq4c=ruq4c+1
- end
- end
- elseif string.sub(str,i,i) == "t" then
- reactor.pullItem(side,rhss[rhssc],1,i)
- rhssc=rhssc+1
- elseif string.sub(str,i,i) == "p" then
- reactor.pullItem(side,rph[rphc],1,i)
- if rph[2] ~= nil then
- if chest.getStackInSlot(rph[rphc]) == nil then
- rphc=rphc+1
- end
- end
- elseif string.sub(str,i,i) == "d" then
- reactor.pullItem(side,rvd[rvdc],1,i)
- rvdc=rvdc+1
- elseif string.sub(str,i,i) == "v" then
- reactor.pullItem(side,rv[rvc],1,i)
- rvc=rvc+1
- elseif string.sub(str,i,i) == "c" then
- reactor.pullItem(side,rvk[rvkc],1,i)
- rvkc=rvkc+1
- elseif string.sub(str,i,i) == "s" then
- reactor.pullItem(side,rhs[rhsc],1,i)
- rhsc=rhsc+1
- elseif string.sub(str,i,i) == "k" then
- reactor.pullItem(side,rhsk[rhskc],1,i)
- rhskc=rhskc+1
- elseif string.sub(str,i,i) == "1" then
- reactor.pullItem(side,rus1[rus1c],1,i)
- if rus1[2] ~= nil then
- if chest.getStackInSlot(rus1[rus1c]) == nil then
- rus1c=rus1c+1
- end
- end
- elseif string.sub(str,i,i) == "2" then
- reactor.pullItem(side,rud2[rud2c],1,i)
- if rud2[2] ~= nil then
- if chest.getStackInSlot(rud2[rud2c]) == nil then
- rud2c=rud2c+1
- end
- end
- end
- end
- end
- --[[local function chestShow()
- for i=1,maxslot do
- local slot = chest.getStackInSlot(i)
- if slot ~= nil then
- print(i.." = "..slot.name.." ("..slot.qty..")")
- end
- end
- end]]--
- local function dCount(str,d)
- local c = 0
- for i=1,string.len(str) do
- if string.sub(str,i,i) == d then
- c=c+1
- end
- end
- return c
- end
- local function chestCheck(str,uran)
- --ox4tvcskl2
- local enough = true
- local on=dCount(str,"o")
- local xn=dCount(str,"x")
- local tn=dCount(str,"t")
- local pn=dCount(str,"p")
- local dn=dCount(str,"d")
- local vn=dCount(str,"v")
- local cn=dCount(str,"c")
- local sn=dCount(str,"s")
- local kn=dCount(str,"k")
- local u1n=dCount(str,"1")
- local u2n=dCount(str,"2")
- local u4n=dCount(str,"4")
- local oh=0
- local xh=0
- local u4h=0
- local th=0
- local ph=0
- local dh=0
- local vh=0
- local ch=0
- local sh=0
- local kh=0
- local u1h=0
- local u2h=0
- for i=1,maxslot do
- local slot = chest.getStackInSlot(i)
- if slot ~= nil then
- --print(i.." = "..slot.name.." ("..slot.qty..")")
- if slot.name == "reactorVentSpread" then
- oh=oh+1
- elseif slot.name == "reactorVentGold" then
- xh=xh+1
- elseif slot.name == "reactorHeatSwitchSpread" then
- th=th+1
- elseif slot.name == "reactorPlatingHeat" then
- ph=ph+slot.qty
- elseif slot.name == "reactorVentDiamond" then
- dh=dh+1
- elseif slot.name == "reactorVent" then
- vh=vh+1
- elseif slot.name == "reactorVentCore" then
- ch=ch+1
- elseif slot.name == "reactorHeatSwitch" then
- sh=sh+1
- elseif slot.name == "reactorHeatSwitchCore" then
- kh=kh+1
- end
- if uran then
- if slot.name == "reactorUraniumSimple" then
- u1h=u1h+slot.qty
- elseif slot.name == "reactorUraniumDual" then
- u2h=u2h+slot.qty
- elseif slot.name == "reactorUraniumQuad" then
- u4h=u4h+slot.qty
- end
- else
- if slot.name == "reactorMOXSimple" then
- u1h=u1h+slot.qty
- elseif slot.name == "reactorMOXDual" then
- u2h=u2h+slot.qty
- elseif slot.name == "reactorMOXQuad" then
- u4h=u4h+slot.qty
- end
- end
- end
- end
- if on > oh then
- print("нехватает компонента 'Компонентный Теплоотвод' "..on-oh.." шт")
- enough = false
- end
- if xn > xh then
- print("нехватает компонента 'Разогнанный Теплоотвод' "..xn-xh.." шт")
- enough = false
- end
- if tn > th then
- print("нехватает компонента 'Компонентный Теплообменник' "..tn-th.." шт")
- enough = false
- end
- if pn > ph then
- print("нехватает компонента 'Теплоёмкая реакторная пластина' "..pn-ph.." шт")
- enough = false
- end
- if dn > dh then
- print("нехватает компонента 'Улучшенный Теплоотвод' "..dn-dh.." шт")
- enough = false
- end
- if vn > vh then
- print("нехватает компонента 'Теплоотвод' "..vn-vh.." шт")
- enough = false
- end
- if cn > ch then
- print("нехватает компонента 'Реакторный Теплоотвод' "..cn-ch.." шт")
- enough = false
- end
- if sn > sh then
- print("нехватает компонента 'Теплообменник' "..sn-sh.." шт")
- enough = false
- end
- if kn > kh then
- print("нехватает компонента 'Реакторный Теплообменник' "..kn-kh.." шт")
- enough = false
- end
- if uran then
- if u1n > u1h then
- print("нехватает компонента 'Одинарный урановый стержень' "..u1n-u1h.." шт")
- enough = false
- end
- if u2n > u2h then
- print("нехватает компонента 'Сдвоенный урановый стержень' "..u2n-u2h.." шт")
- enough = false
- end
- if u4n > u4h then
- print("нехватает компонента 'Счетверенный урановый стержень' "..u4n-u4h.." шт")
- enough = false
- end
- else
- if u1n > u1h then
- print("нехватает компонента 'Одинарный MOX стержень' "..u1n-u1h.." шт")
- enough = false
- end
- if u2n > u2h then
- print("нехватает компонента 'Сдвоенный MOX стержень' "..u2n-u2h.." шт")
- enough = false
- end
- if u4n > u4h then
- print("нехватает компонента 'Счетверенный MOX стержень' "..u4n-u4h.." шт")
- enough = false
- end
- end
- return enough
- end
- local function sideCheck()
- local side = 0
- for i=1,#sides do
- if pcall(reactor.pullItem,sides[i],1,1,1) then
- --print(sides[i])
- side=sides[i]
- reactor.pushItem(side,1,1,1)
- return side
- end
- end
- if side == 0 then
- print("где сундук?")
- return false
- end
- end
- local function heat()
- print("Ваш реактор нагрет не до максимума. Запустить программу безопасного нагрева реактора?\n1. Да\n2. Нет")
- local yn = tonumber(term.read())
- if yn == 1 then
- print("Для работы программы, проведите сигнал красного камня от лицевой части системного блока к реактору\nДля безопасности рекомендуется убрать из реактора все лишнее и оставить одинарный урановый стержень\nНажмите ENTER, чтобы продолжить")
- term.read()
- local maxheat = reactor.getMaxHeat()
- local curheat = reactor.getHeat()
- local aimheat = maxheat-20
- red.setOutput(3,255)
- while curheat<aimheat do
- print("Температура: "..curheat.." / "..maxheat)
- curheat = reactor.getHeat()
- term.clear()
- end
- red.setOutput(3,0)
- print("Процесс нагрева завершен, очистите реактор, чтобы начать процесс заполнения схемы")
- while not reactorIsEmpty() do
- os.sleep(0)
- end
- else
- print("Программа нагрева отменена")
- return
- end
- end
- local function heatCheck()
- local c = (reactor.getHeat()/reactor.getMaxHeat())*100
- if c < 99 then
- return false
- else
- return true
- end
- end
- if reactorIsEmpty() then
- local side = sideCheck()
- if side then
- local schm,uran = choose()
- if chestCheck(schm,uran) then
- if not uran and not heatCheck() then
- heat()
- end
- scheme(side,uran,schm)
- end
- end
- else
- print("Очистите реактор")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement