Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(20 ,10)
- print("Running ...")
- mouseWidth = 0
- mouseHeight = 0
- ------
- local area = 512
- local keyCommand = "##"
- local refreshTime = 1
- local modemSide = "right"
- local chatBoxSide = "top"
- local databaseName = "owner"
- local monitor = "monitor_45"
- local mfsu = {"mfsu_2", "mfsu_3"}
- local capbank = "tile_blockcapacitorbank_name_1"
- local reator = {"BigReactors-Reactor_6", "BigReactors-Reactor?7"}
- local turbine = {"BigReactors-Turbine_13", "BigReactors-Turbine_14"}
- ------
- local chatbox = peripheral.wrap(chatBoxSide)
- local modem = peripheral.wrap(modemSide)
- local owner = sql.load (databaseName)
- local event, player, command
- stored1 = modem.callRemote(mfsu, "getEnergyStored")
- total1 = modem.callRemote(mfsu, "getEUCapacity")
- stored2 = modem.callRemote(mfsu[2], "getEUStored")
- total2 = modem.callRemote(mfsu[2], "getEUCapacity")
- stored = stored1 + stored2
- total = total1 + total2
- stored3 = modem.callRemote(capbank, "getEnergyStored")
- total3 = modem.callRemote(capbank, "getMaxEnergyStored")
- modem.callRemote(monitor, "clear")
- modem.callRemote(monitor, "setCursorPos" ,1 ,1)
- w,h = modem.callRemote(monitor, "getSize")
- rawPer = stored/total
- rawPer2 = stored2/total2
- epercent = math.floor((rawPer*100)+0.5)
- epercent2 = math.floor((rawPer2*100)+0.5)
- modem.callRemote(monitor, "setTextColor" , colors.yellow)
- modem.callRemote(monitor, "write" , "HexOs 1.0")
- modem.callRemote(monitor, "setTextColor" , colors.red)
- modem.callRemote(monitor, "setCursorPos" ,10 ,3)
- modem.callRemote(monitor, "write" , "Reactor 1")
- modem.callRemote(monitor, "setCursorPos" ,10 ,4)
- modem.callRemote(monitor, "write" , "Turbina 1")
- modem.callRemote(monitor, "setCursorPos" ,10 ,5)
- modem.callRemote(monitor, "write" , "Reactor 2")
- modem.callRemote(monitor, "setCursorPos" ,10 ,6)
- modem.callRemote(monitor, "write" , "Turbina 2")
- modem.callRemote(monitor, "setCursorPos" ,6 ,8)
- modem.callRemote(monitor, "setTextColor" , colors.lightBlue)
- while true do
- modem.callRemote(monitor, "write" , "EU: " .. stored .. "/" .. total)
- modem.callRemote(monitor, "setCursorPos" ,10 ,10)
- modem.callRemote(monitor, "setTextColor" , colors.lime)
- modem.callRemote(monitor, "write" , epercent.."% energie",6)
- local p = (w-8) * stored / total
- modem.callRemote(monitor, "setBackgroundColour" , colours.lightGrey)
- modem.callRemote(monitor, "setCursorPos" ,5 ,12)
- modem.callRemote(monitor, "write" , string.rep(" ", w-8))
- modem.callRemote(monitor, "setBackgroundColour" , colours.grey)
- modem.callRemote(monitor, "setCursorPos" ,5 ,12)
- modem.callRemote(monitor, "write" , string.rep(" ", p))
- modem.callRemote(monitor, "setBackgroundColour" , colours.black)
- modem.callRemote(monitor, "setCursorPos" ,4 ,14)
- modem.callRemote(monitor, "setTextColor" , colors.lightBlue)
- modem.callRemote(monitor, "write" ,"RF: " .. stored3 .. "/" .. total3)
- modem.callRemote(monitor, "setCursorPos" ,10 ,16)
- modem.callRemote(monitor, "setTextColor" , colors.lime)
- modem.callRemote(monitor, "write" , epercent2.."% energie",6)
- modem.callRemote(monitor, "setTextColor" , colors.black)
- local p2 = (w-8) * stored2 / total
- modem.callRemote(monitor, "setBackgroundColour" , colours.lightGrey)
- modem.callRemote(monitor, "setCursorPos" ,5 ,17)
- modem.callRemote(monitor, "write" , string.rep(" ", w-8))
- modem.callRemote(monitor, "setBackgroundColour" , colours.grey)
- modem.callRemote(monitor, "setCursorPos" ,5 ,17)
- modem.callRemote(monitor, "write" , string.rep(" ", p2))
- modem.callRemote(monitor, "setBackgroundColour" , colours.black)
- end
- function autoRun()
- controds1 = modem.callRemote (reactor[1], "getControlRodLevel",0)
- perc1 = controlrods1
- if perc1 == nil then perc1 = controds1 end
- controds2 = modem.callRemote (reactor[2], "getControlRodLevel",0)
- perc2 = controlrods2
- if perc2 == nil then perc1 = controds2 end
- flowrate1 = modem.callRemote (turbine[1], "getFluidFlowRateMax")
- turc1 = fluidflowrate1
- if turc1 == nil then turc1 = flowrate1 end
- flowrate2 = modem.callRemote (turbine[2], "getFluidFlowRateMax")
- turc2 = fluidflowrate1
- if turc2 == nil then turc2 = flowrate2 end
- end
- local function start()
- fueltemp1 = modem.callRemote (reactor[1], "getFuelTemperature")
- fueltemp2 = modem.callRemote (reactor[2], "getFuelTemperature")
- rpm1 = modem.callRemote (turbine[1], "getRotorSpeed")
- rpm2 = modem.callRemote (turbine[2], "getRotorSpeed")
- if fueltemp1 > 1200 then
- perc1 = perc1 + 1
- modem.callRemote (reactor[1], "setAllControlRodLevels", perc1)
- elseif fueltemp1 < 1000 then
- perc1 = perc1 - 1
- modem.callRemote (reactor[1], "setAllControlRodLevels", perc1)
- end
- if fueltemp2 > 1200 then
- perc2 = perc2 + 1
- modem.callRemote (reactor[2], "setAllControlRodLevels", perc2)
- elseif fueltemp2 < 1000 then
- perc2 = perc2 - 1
- modem.callRemote (reactor[2], "setAllControlRodLevels", perc2)
- end
- if rpm1 < 1830 then
- turc1 = turc1 + 1
- modem.callRemote (turbine[1], "setFluidFlowRateMax", turc1)
- elseif rpm1 > 1850 then
- turc1 = turc1 - 1
- modem.callRemote (turbine[1], "setFluidFlowRateMax", turc1)
- end
- if rpm2 < 1850 then
- turc2 = turc2 + 1
- modem.callRemote (turbine[2], "setFluidFlowRateMax", turc2)
- elseif rmp2 > 1870 then
- turc2 = turc2 - 1
- modem.callRemote (turbine[2], "setFluidFlowRateMax", turc2)
- end
- end
- function checkClickPosition()
- if mouseWidth > 9 and mouseWidth < 19 and mouseHeight == 3 then
- active = modem.callRemote (reactor[1], "getActive")
- fuel = modem.callRemote (reactor[1], "getFuelAmount")
- fuelmax = modem.callRemote (reactor[1], "getFuelAmountMax")
- fueltemp = modem.callRemote (reactor[1], "getFuelTemperature")
- eatfuel = modem.callRemote (reactor[1], "getFuelConsumedLastTick")
- controds = modem.callRemote (reactor[1], "getControlRodLevel",0)
- waste = modem.callRemote (reactor[1], "getWasteAmmount")
- rods = modem.callRemote (reactor[1], "getNumberOfControlRods")
- modem.callRemote(monitor, "clear")
- modem.callRemote(monitor, "setCursorPos" ,1 ,1)
- modem.callRemote(monitor, "write" , "Reactor 1:")
- if active == true then
- modem.callRemote(monitor, "setCursorPos" ,1 ,3)
- modem.callRemote (monitor, "setTextColor", colors.lime)
- modem.callRemote (monitor, "write", "Reaktor je zapnuty")
- else
- modem.callRemote(monitor, "setCursorPos" ,1 ,3)
- modem.callRemote (monitor, "setTextColor", colors.red)
- modem.callRemote (monitor, "write", "Reaktor je vypnuty")
- end
- modem.callRemote (monitor, "setCursorPos", 1, 5)
- modem.callRemote (monitor, "setTextColor", colors.cyan)
- modem.callRemote (monitor, "setCursorPos", 1, 6)
- modem.callRemote (monitor, "write", "Odpad: " .. waste)
- modem.callRemote (monitor, "setCursorPos", 1, 7)
- modem.callRemote (monitor, "write", "Palivo: " .. fuel .. "/" .. fuelmax)
- modem.callRemote (monitor, "write", "Teplota: " .. fueltemp1)
- modem.callRemote (monitor, "setCursorPos", 1, 8)
- modem.callRemote (monitor, "write", "Spotreba: " .. eatfuel .."/T")
- modem.callRemote (monitor, "setCursorPos", 1, 9)
- modem.callRemote (monitor, "write", "Pocet rodov: " .. rods)
- modem.callRemote (monitor, "setCursorPos", 1, 10)
- modem.callRemote (monitor, "write", "Rody vsunute: " .. controds)
- elseif mouseWidth > 9 and mouseWidth < 19 and mouseHeight == 4 then
- energy = modem.callRemote (turbine[1], "getEnergyStored")
- rpm = modem.callRemote (turbine[1], "getRotorSpeed")
- rft = modem.callRemote (turbine[1], "getEnergyProducedLastTick")
- flowrate = modem.callRemote (turbine[1], "getFluidFlowRateMax")
- rotorspd = modem.callRemote (turbine[1], "getRotorSpeed")
- stemin = modem.callRemote (turbine[1], "getInputAmmount")
- modem.callRemote(monitor, "clear")
- modem.callRemote(monitor, "setCursorPos" ,1 ,1)
- modem.callRemote(monitor, "write" , "Turbina 2:")
- if turbactive == true then
- modem.callRemote(monitor, "setCursorPos" ,1 ,3)
- modem.callRemote (monitor, "setTextColor", colors.lime)
- modem.callRemote (monitor, "write", "Turbina je zapnuta")
- else
- modem.callRemote (monitor, "setCursorPos" ,1 ,3)
- modem.callRemote (monitor, "setTextColor", colors.red)
- modem.callRemote (monitor, "write", "Turbina je vypnuta")
- end
- modem.callRemote (monitor, "setCursorPos", 1, 5)
- modem.callRemote (monitor, "write", "RPM: " .. rpm1)
- modem.callRemote (monitor, "setCursorPos" ,1 ,6)
- modem.callRemote (monitor, "write", "RF/t: " .. rft1)
- modem.callRemote (monitor, "setCursorPos" ,1 ,7)
- modem.callRemote (monitor, "write", "Steam/t: " .. flowrate)
- modem.callRemote (monitor, "setCursorPos" ,1 ,8)
- modem.callRemote (monitor, "write", "Energia: " .. energy1 .. "RF/10m RF")
- modem.callRemote (monitor, "setCursorPos" ,1 ,9)
- modem.callRemote (monitor, "write", "Rotor Speed: " .. rotorspd)
- modem.callRemote (monitor, "setCursorPos" ,1 ,10)
- modem.callRemote (monitor, "write", "Steam v turbine: " .. stemin)
- elseif mouseWidth > 9 and mouseWidth < 19 and mouseHeight == 5 then
- active = modem.callRemote (reactor[2], "getActive")
- fuel = modem.callRemote (reactor[2], "getFuelAmount")
- fuelmax = modem.callRemote (reactor[2], "getFuelAmountMax")
- fueltemp = modem.callRemote (reactor[2], "getFuelTemperature")
- eatfuel = modem.callRemote (reactor[2], "getFuelConsumedLastTick")
- controds = modem.callRemote (reactor[2], "getControlRodLevel",0)
- waste = modem.callRemote (reactor[2], "getWasteAmmount")
- rods = modem.callRemote (reactor[2], "getNumberOfControlRods")
- modem.callRemote(monitor, "clear")
- modem.callRemote(monitor, "setCursorPos" ,1 ,1)
- modem.callRemote(monitor, "write" , "Reactor 2:")
- if active == true then
- modem.callRemote(monitor, "setCursorPos" ,1 ,3)
- modem.callRemote (monitor, "setTextColor", colors.lime)
- modem.callRemote (monitor, "write", "Reaktor je zapnuty")
- else
- modem.callRemote(monitor, "setCursorPos" ,1 ,3)
- modem.callRemote (monitor, "setTextColor", colors.red)
- modem.callRemote (monitor, "write", "Reaktor je vypnuty")
- end
- modem.callRemote (monitor, "setCursorPos", 1, 5)
- modem.callRemote (monitor, "setTextColor", colors.cyan)
- modem.callRemote (monitor, "setCursorPos", 1, 6)
- modem.callRemote (monitor, "write", "Odpad: " .. waste)
- modem.callRemote (monitor, "setCursorPos", 1, 7)
- modem.callRemote (monitor, "write", "Palivo: " .. fuel .. "/" .. fuelmax)
- modem.callRemote (monitor, "write", "Teplota: " .. fueltemp1)
- modem.callRemote (monitor, "setCursorPos", 1, 8)
- modem.callRemote (monitor, "write", "Spotreba: " .. eatfuel .."/T")
- modem.callRemote (monitor, "setCursorPos", 1, 9)
- modem.callRemote (monitor, "write", "Pocet rodov: " .. rods)
- modem.callRemote (monitor, "setCursorPos", 1, 10)
- modem.callRemote (monitor, "write", "Rody vsunute: " .. controds)
- elseif mouseWidth > 9 and mouseWidth < 19 and mouseHeight == 6 then
- energy = modem.callRemote (turbine[1], "getEnergyStored")
- rpm = modem.callRemote (turbine[1], "getRotorSpeed")
- rft = modem.callRemote (turbine[1], "getEnergyProducedLastTick")
- flowrate = modem.callRemote (turbine[1], "getFluidFlowRateMax")
- rotorspd = modem.callRemote (turbine[1], "getRotorSpeed")
- stemin = modem.callRemote (turbine[1], "getInputAmmount")
- modem.callRemote (monitor, "clear")
- modem.callRemote (monitor, "setCursorPos" ,1 ,1)
- modem.callRemote (monitor, "write" , "Turbina 2:")
- if turbactive == true then
- modem.callRemote (monitor, "setCursorPos" ,1 ,3)
- modem.callRemote (monitor, "setTextColor", colors.lime)
- modem.callRemote (monitor, "write", "Turbina je zapnuta")
- else
- modem.callRemote (monitor, "setCursorPos" ,1 ,3)
- modem.callRemote (monitor, "setTextColor", colors.red)
- modem.callRemote (monitor, "write", "Turbina je vypnuta")
- end
- modem.callRemote (monitor, "setCursorPos", 1, 5)
- modem.callRemote (monitor, "write", "RPM: " .. rpm1)
- modem.callRemote (monitor, "setCursorPos" ,1 ,6)
- modem.callRemote (monitor, "write", "RF/t: " .. rft1)
- modem.callRemote (monitor, "setCursorPos" ,1 ,7)
- modem.callRemote (monitor, "write", "Steam/t: " .. flowrate)
- modem.callRemote (monitor, "setCursorPos" ,1 ,8)
- modem.callRemote (monitor, "write", "Energia: " .. energy1 .. "RF/10m RF")
- modem.callRemote (monitor, "setCursorPos" ,1 ,9)
- modem.callRemote (monitor, "write", "Rotor Speed: " .. rotorspd)
- modem.callRemote (monitor, "setCursorPos" ,1 ,10)
- modem.callRemote (monitor, "write", "Steam v turbine: " .. stemin)
- end
- end
- function rsInfo()
- chatbox.tell(player, ":======= Stav motorov =======:", area)
- if modem.callRemote (reactor[1], "getActive") then
- chatbox.tell(player, " Reactor: 1 on", area)
- else
- chatbox.tell(player, " Reactor: 1 off", area)
- end
- if modem.callRemote (reactor[2], "getActive") then
- chatbox.tell(player, " Reactor: 2 on", area)
- else
- chatbox.tell(player, " Reactor: 2 off", area)
- end
- if modem.callRemote (turbine[1], "getActive") then
- chatbox.tell(player, " Turbina: 1 on", area)
- else
- chatbox.tell(player, " Turbina: 1 off", area)
- end
- if modem.callRemote (turbine[2], "getActive") then
- chatbox.tell(player, " Turbine: 2 on", area)
- else
- chatbox.tell(player, " Turbina: 2 off", area)
- end
- chatbox.tell(player, ":============================:", area)
- end
- local function mine()
- -- iTime = os.startTimer(.1)
- while true do
- event, player, command = os.pullEvent()
- if event == "chat" then
- commandLine = {}
- comandPos = 1
- part = ""
- if owner.getContent (player) then
- for i = 1, string.len(command) do
- char = command:sub(i,i)
- if char == " " then
- commandLine[comandPos] = part
- comandPos = comandPos + 1
- part = ""
- else
- part = part .. char
- end
- end
- commandLine[comandPos] = part
- if commandLine[1] == keyCommand then
- if commandLine[2] == "help" then
- chatbox.tell(player, "=========== HELP ===========", area)
- chatbox.tell(player, keyCommand .. " help", area)
- chatbox.tell(player, keyCommand .. " add <nick>", area)
- chatbox.tell(player, keyCommand .. " remove <nick>", area)
- chatbox.tell(player, keyCommand .. " owners", area)
- chatbox.tell(player, keyCommand .. " reactor on/off <poradie>", area)
- chatbox.tell(player, keyCommand .. " turbine on/off <poradie>", area)
- chatbox.tell(player, keyCommand .. " info", area)
- elseif commandLine[2] == "add" then
- if owner.getContent (commandLine[3]) then
- chatbox.tell(player, "Hrac: " .. commandLine[3] .. " uz je pridany. - Owner: " .. player, area)
- else
- owner.addContent ("a", commandLine[3])
- chatbox.tell(player, "Uspesne si pridal hraca: " .. commandLine[3] .. " - Owner: " .. player, area)
- end
- elseif commandLine[2] == "remove" then
- if owner.getContent (commandLine[3]) then
- owner.delContent (commandLine[3])
- chatbox.tell(player, "Uspesne si odobral hraca: " .. commandLine[3] .. " - Owner: " .. player, area)
- else
- chatbox.tell(player, "Hrac: " .. commandLine[3] .. " nie je pridany. - Owner: " .. player, area)
- end
- elseif commandLine[2] == "owners" then
- fileO = fs.open("owner", "r")
- charO = 1
- chatbox.tell(player, "========== OWNERS ==========", area)
- while charO ~= nil do
- charO = fileO.readLine()
- if charO and charO ~= "" then
- chatbox.tell(player, " " .. charO, area)
- end
- end
- fileO.close()
- elseif commandLine[2] == "reactor" then
- if commandLine[3] == "on" then
- if tonumber(commandLine[4]) > 2 and tonumber(commandLine[4]) == 0 then
- chatbox.tell(player, "Existuju iba 2 reaktori ! - Owner: " .. player, area)
- else
- chatbox.tell(player, "Zapol si: Reactor " .. commandLine[4] .. ". - Owner: " .. player, area)
- modem.callRemote (reactor[tonumber (commandLine[4])], "setActive", true)
- end
- elseif commandLine[3] == "off" then
- if tonumber(commandLine[4]) > 2 or tonumber(commandLine[4]) == 0 then
- chatbox.tell(player, "Existuju iba 2 reaktori ! - Owner: " .. player, area)
- else
- chatbox.tell(player, "Vypol si: Reactor " .. commandLine[4] .. " . - Owner: " .. player, area)
- modem.callRemote (reactor[tonumber (commandLine[4])], "setActive", false)
- end
- end
- elseif commandLine[2] == "turbine" then
- if commandLine[3] == "on" then
- if tonumber(commandLine[4]) > 2 or tonumber(commandLine[4]) == 0 then
- chatbox.tell(player, "Existuju iba 2 turbiny ! - Owner: " .. player, area)
- else
- chatbox.tell(player, "Zapol si: Turbinu " .. commandLine[4] .. " . - Owner: " .. player, area)
- modem.callRemote (turbine[tonumber (commandLine[4])], "setActive", true)
- end
- elseif commandLine[3] == "off" then
- if tonumber(commandLine[4]) > 2 or tonumber(commandLine[4]) == 0 then
- chatbox.tell(player, "Existuju iba 2 turbiny ! - Owner: " .. player, area)
- else
- chatbox.tell(player, "Vypol si: Turbinu " .. commandLine[4] .. " . - Owner: " .. player, area)
- modem.callRemote (turbine[tonumber (commandLine[4])], "setActive", false)
- end
- end
- elseif commandLine[2] == "info" then
- rsInfo()
- end
- end
- end
- elseif event == "timer" and player == iTime then
- event,p1,p2,p3 = os.pullEvent()
- if event=="monitor_touch" then
- mouseWidth = p2
- mouseHeight = p3
- checkClickPosition()
- end
- end
- end
- end
- mine()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement