Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- com = require("component")
- ev = require("event")
- sides = require("sides")
- str = require("string")
- e = {
- com.proxy("c3b899b6-07a2-4a34-a820-88fd23aeefa4"), -- 1 right
- com.proxy("104a0488-280e-40e4-b261-d7ae0197d926"), -- 2 front
- com.proxy("88c30270-3298-4e0b-abd3-b6ce9d4691a1"), -- 3 back
- com.proxy("f1808099-8678-4a2d-9f67-1c151a39f861") -- 4 left
- }
- e_sd = {sides.right,sides.front,sides.back,sides.left}
- bb = com.gt_machine --com.gt_batterybuffer
- op = com.openperipheral_bridge
- cb = com.chat_box
- red = com.redstone
- gpu = com.gpu
- state = "auto"
- hpe = {1,1,1,1}
- recst = {"","","",""}
- cb.setName("Горячий Мексиканец")
- works = false
- function setEB(state)
- for i=1,4,1 do
- if hpe[i] < 80 then red.setOutput(e_sd[i],state) end
- end
- end
- function getEnrg()
- now,total = 0,0
- for i=1,16,1 do
- if bb.getBatteryCharge(i) ~= nil then
- now = now + bb.getBatteryCharge(i)
- total = total + bb.getMaxBatteryCharge(i)
- end
- end
- total = total + bb.getEUMaxStored()
- now = now + bb.getStoredEU()
- return now,total
- end
- function glcc(_,_,nick,_,command)
- print("Got command. Nick: "..nick.."; Command: $$"..command)
- if nick == "Andronio" or nick == "Orlin" then
- if command:sub(1,3) == "say" then cb.say("* "..command:sub(5)) -- Просто сказать
- elseif command:sub(1,7) == "setmode" then -- Управление режимами реакторного блока
- if command:sub(9) == "auto" or command:sub(9) == "forceon" or command:sub(9) == "forceoff" then state = command:sub(9) cb.say("Mode has been set to '"..state.."'!")
- else cb.say("Incorrect value: ".."'"..command:sub(9).."'!") end
- elseif command == "help" then
- cb.say("Help:\n$$setmode auto/forceon/forceoff - Sets reactor control mode.\n$$say *text* - Just says your text.\n$$stop - Closes this program(Reboots PC).\n$$status - Says everything about system.\n(C) Andronio")
- elseif command == "stop" then cb.say("Bye-bye! <3") op.clear() op.sync() os.execute("reboot")
- elseif command == "status" then
- ct = "Status:\nEnergy Buffers:\n #1: "..enstr.."\n"
- --for i=1,16 do if bb.getBatteryCharge(i) ~= nil then ct = ct.." Crystal #"..i..": "..bb.getBatteryCharge(i).."/"..bb.getMaxBatteryCharge(i).." EU\n" end end
- --ct = ct.." Internal Buffer: "..bb.getStoredEU().."/"..bb.getEUMaxStored().." EU\n"
- ct = ct.."Generators:\n Energy Block #1("..stt.."):\n"
- for i=1,4 do
- ct = ct.." Reactor #"..i..": "..e[i].getReactorEUOutput().." EU/t Heat: "..hpe[i].."% Status: "
- if e[i].isActive() then ct = ct.."On\n"
- else ct = ct.."Off\n" end
- end
- ct = ct.."'SOSI PISOS' - Palindrom"
- cb.say(ct)
- else cb.say("Incorrect command!") end
- else cb.say("You are not allowed to use that!") end
- end
- setEB(0)
- cc_eve = ev.listen("glasses_chat_command",glcc)
- while true do
- cure,maxe = bb.getEUStored(),bb.getEUMaxStored()--getEnrg()
- enstr = cure.."/"..maxe.." EU"
- ain,aon = bb.getAverageElectricInput(),bb.getAverageElectricOutput()
- if math.floor(cure/maxe*100) < 75 and state == "auto" and not works then
- cb.say("Energy level is below 75%. Turning on reactors...")
- setEB(255)
- works = true
- elseif math.floor(cure/maxe*100) > 95 and state == "auto" and works then
- cb.say("Energy level is above 95%. Turning off reactors...")
- setEB(0)
- works = false
- end
- if state == "forceon" then setEB(255) works = true end
- if state == "forceoff" then setEB(0) works = false end
- for i=1,4,1 do
- hpe[i] = math.floor(e[i].getHeat()/e[i].getMaxHeat()*100)
- if e[i].isActive() then recst[i] = "§2On"
- else recst[i] = "§4Off" end
- if hpe[i] >= 80 then
- red.setOutput(e_sd[i],0) end
- end
- if state == "auto" then stt = "§9Auto"
- elseif state == "forceon" then stt = "§2Force On"
- elseif state == "forceoff" then stt = "§4Force Off" end
- op.clear()
- op.addText(1,12,"Energy Buffers")
- op.addIcon(1,22,"gregtech:gt.blockmachines",812) --op.addIcon(1,22,"gregtech:gt.blockmachines",165)
- op.addText(3,27,math.floor(cure/maxe*100).." ",0x0000FF)
- op.addText(19,23,enstr)--.." §2In: "..ain.." EU/t §cOut: "..aon.." EU/t")
- op.addBox(19,33,100,3,0xFF0000)
- op.addBox(19,33,math.floor(cure/maxe*100+0.5),3,0x00FF00)
- op.addText(1,44,"Reactors")
- for i=1,4,1 do
- op.addIcon(1,55+17*(i-1),"IC2:blockReactorChamber")
- if e[i].isActive() and e[i].getReactorEUOutput() == 0 then
- op.addBox(4,55+17*(i-1),10,3,0x0000FF)
- end
- if hpe[i] >= 80 then
- op.addBox(4,68+17*(i-1),10,3,0xFF0000)
- end
- op.addText(19,56+17*(i-1),"Output: "..math.floor(e[i].getReactorEUOutput()).." EU/t, Heat: "..hpe[i].."% "..recst[i])
- op.addBox(19,66+17*(i-1),100,3,0xFF0000)
- op.addBox(19,66+17*(i-1),hpe[i],3,0x00FF00)
- end
- op.addText(1,124,"Total Output: "..math.floor(e[1].getReactorEUOutput()+e[2].getReactorEUOutput()+e[3].getReactorEUOutput()+e[4].getReactorEUOutput()).." EU/t")
- op.addText(1,135,"Work Mode: "..stt)
- op.sync()
- os.sleep(0.01)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement