Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

CptMercury

Members
  • Content Count

    50
  • Joined

  • Last visited

  • Days Won

    3

CptMercury last won the day on August 11

CptMercury had the most liked content!

1 Follower

About CptMercury

  • Rank
    Junior Member

Recent Profile Visitors

453 profile views
  1. Ok, as promised, here is a more advanced function. Instead of giving it one string and specify its color, you mark parts of the string and specify foreground (and also background) color by using a xml/html like syntax. If you want to change on part of the string, put it between <color fg=hex, bg=hex>your string goes here</color>. Hex is the color code starting with 0x (like 0xFFFFFF). You don't have to specify both, background and foreground, just set the color you like to change; if you set both, use a comma (,) as delimiter. local component = require "component" local term = require "term" ------------------------------------------------------------------------------- local gpu = component.gpu local adWrite = {} function adWrite.write(s) local cbg, cfg = gpu.getBackground(), gpu.getForeground() local i = 1 s:gsub('()<color(.-)>(.-)</color>()', function(i1, tag, content, i2) local bg, fg if not i1 then return end term.write(s:sub(i, i1-1)) tag = tag:gsub('%s', "") -- remove whites paces for colortype, color in tag:gmatch '([bfg][bfg])=(0[xX]%x+)' do if colortype == "bg" and color then bg = tonumber(color) elseif colortype == "fg" and color then fg = tonumber(color) end end if bg and bg ~= cbg then gpu.setBackground(bg) end if fg and fg ~= color then gpu.setForeground(fg) end term.write(content) gpu.setBackground(cbg) gpu.setForeground(cfg) i = i2 end) if i <= #s then term.write(s:sub(i, #s)) end end ------------------------------------------------------------------------------- return adWrite Here is an example:
  2. I assume you are currently using the term lib for writing stuff on the screen? For full control over the screen, you need to interact with the gnu component directly. You then need to also specify the x and y coordinate where your text starts. But it's easy to write a function that works exactly like term.write but allows you to specify the colors of each part of the string. local component = require "component" local term = require "term" local unicode = require "unicode" local gpu = component.gpu local function advancedWrite(s, c) -- s is the string, c is its color local x, y = term.getCursor() local max_x, max_y = gpu.getResolution local len = unicode.len(s) local old_fg = gpu.setForeground(c) gpu.set(x, y, s) gpu.setForeground(old_fg) if x + len >= max_x then x = 1 y = y + 1 else x = x + len end term.setCursor(x, y) if x + len >= max_x then return advancedWrite(unicode.sub(s, max_x-x), c) end end This is a really simple and inefficient approach. I haven't tested it yet but I will once I'm back at my computer. I will also post a proper function later, if that is the type of solution you're looking for.
  3. Well, first of all, if you only need the message to contain one string, then you are better off by just sending the string as the message, so no need to make a table with that string, serialize the table transforming it into a string which is then send via the modem, once received, transformed back into a table which is then indexed to get the string you want to send... But anyways, I would assume the error with the serialization comes from trying to serialize a nil value. You're using a timeout with your event.pull, that means, event.pull returns nil if no modem_message was received within that 239 seconds. So either you simply remove the number specifying the timeout, or you add an if-statement checking whether you actually received a message and skip the serialization part when the message is nil. -- without the timeout, if this is possible, but it looks like you want your robot to execute some stuff every 239 seconds function loopWait() loopOff = false db.clear(1) me.store({name = "minecraft:record_wait"}, db.address, 1) selectEmpty() me.requestItems(db.address, 1, 1) ic.equip() robot.useUp() repeat _, _, _, _, _, serialized_message = event.pull("modem_message") received_table = require("serialization").unserialize(serialized_message) if recieved_table.loopSwitch == "off" then loopOff = true end robot.useUp() selectFull() ic.equip() robot.useUp() until loopOff == true robot.useUp() selectFull() me.sendItems() end -------------------------------- -- with an if statement verifying there actually was a message received function loopWait() loopOff = false db.clear(1) me.store({name = "minecraft:record_wait"}, db.address, 1) selectEmpty() me.requestItems(db.address, 1, 1) ic.equip() robot.useUp() repeat _, _, _, _, _, serialized_message = event.pull(239, "modem_message") if serialized_message then received_table = require("serialization").unserialize(serialized_message) if recieved_table.loopSwitch == "off" then loopOff = true end end robot.useUp() selectFull() ic.equip() robot.useUp() until loopOff == true robot.useUp() selectFull() me.sendItems() end But the easiest and best way would be to send your string directly as the message -- the computer sending the message modem.send(address, port, "off") -- receiving computer function loopWait() loopOff = false db.clear(1) me.store({name = "minecraft:record_wait"}, db.address, 1) selectEmpty() me.requestItems(db.address, 1, 1) ic.equip() robot.useUp() repeat _, _, _, _, _, message = event.pull(239, "modem_message") if message == "off" then loopOff = true end robot.useUp() selectFull() ic.equip() robot.useUp() until loopOff == true robot.useUp() selectFull() me.sendItems() end
  4. Can you post your code and a screenshot of the error message you are getting? This would help alot. I don‘t know exactly what you mean by serialization and why you have problems with the time expiring, but when I had the chance looking at the code I might be able to tell.
  5. Like Molinko said, you need a custom program that will allow you to manipulate another computer. And using network cards might be the best option. There are several ways to write programs that allow sending commands to a second computer; a very naive implementation would use the function load. When passed a string, the string is loaded as a chunk of Lua code and returns a function, that, when called, does whatever was coded in the string. And yes, you need to use event.pull or register a listener via event.listen, but your code needs to "pause" at least every 5 seconds anyways, via event.pull or os.sleep (which is essentially the same as event.pull), so that shouldn't be an issue. So a simple code would look like this: The computer receiving the commands: local event = require "event" while true do local _, _, from, _, _, message = event.pull("modem_message") local res, err_msg = load(message) if not res then -- an error occured while loading the string, so here you can do error management -- like throwing an error and ending the program, printing the error message or write it to a log file, -- ignore the error and continue running the main loop etc print(err_msg) else res() -- on success, load returns a funtion, so call it end end --------------------------------------------------------------------------------- -- if you want to throw an error on failure, using assert would be the way to go --------------------------------------------------------------------------------- local event = require "event" while true do local _, _, from, _, _, message = event.pull("modem_message") assert(load(message))() -- if load returns the function, i.e. loading the string was successfull, the function is called -- when an exception was catched, an error with the error message is thrown end So then you can send a message containing "io.write('test')", and the second computer will execute this task. You can also open files etc, so basically you can do everything remotely. But as I said, this is not a very optimized program since load is quite heavy on the machine since it has to compile the code, but it is probably the most versatile approach. (keep in mind, when you want to use strings inside your code, you need to use the correct quotes, if you wrap your string in ", you can't use " for strings inside, so you need to use ' for example, or you wrap your main string in [[..your code goes here..]] these brackets).
  6. In what piece of code you have 3 ends? I only find 3 ends in the last program I posted. There you have one end for closing the main function (2nd end), one for closing the if-statement (1st end) and the last end is for closing the while loop. And for the error: First it would be good if you could post the actual screenshot. Second, could you post the code of the program you were running? From what I currently see, there‘s propably a typo in line 18, but I can‘t tell exactly, what is wrong until I see the actual code.
  7. Hey, in these if statements, you need to use relational operators. Since you want to see if you're variable is equal to a certain string, you need the '==' (two equal signs). So you're code would look like this -- local require commands start local component= require (“component”) local sides = require(“sides”) local rs = component.redstone local event = require(“event”) -- local os = require(“os”) remove this, the os lib does not need to be required, I think -- local require commands end -- Main function start local function main() local username, message = event.pull(“chat_message”) -- you head a period (.) between both variables -- problematic loop start if username == “Hakz_Studios” and message == “ Alice Refuel” then component.speech_box.say(“Refueling”) component.chat_box.say(“Refueling”) repeat local username,message = event.pull(“chat_message”) rs.setoutput(sides.bottom, 15) -- you need to give the redstone output a value, otherwise it wont turn on -- also, by putting it into a loop, the redstone output will be set a ton of times -- it helps putting the statement before the repeat until loop until username == “Hakz_Studios” and message == “Stop Refueling” -- restarting function function main() -- idk what is this line about, but i dont think it belongs here elseif username == “Hakz_Studios” and message == “Stop Refuel Systems” os.execute(“Shutdown”) -- it will look for a program called 'Shutdown' with a capital S else function main() -- also, dont know what you want to do here, do you want to start the function again (to have the code repeated endlessly) --problematic loop end end -- main function end end Some small info: you don't have to put brackets around your condition in the if-statements, you can, but it's not necessary. Also, here is a program that repeats the main loop over and over again, as I think that is what you want to do in your original code, if I'm wrong tho and misinterpreting you're code, just ignore my suggestion -- require libs local component = require("component") local rs = component.redstone local sides = require("sides") local event = require("event") -- main function local function main() local username, message = event.pull("chat_message") if username == "Hakz_Studios" and message == "Alice Refuel" then component.speech_box.say("Refueling") component.chat_box.say("Refueling") -- this time I set the redstone output once, and then wait for the message 'Stop refueling' then deactivate the redstoneoutput again rs.setOutput(sides.bottom, 15) repeat username, message = event.pull("chat_message") -- you dont have to use 'local' in front of username and message here, since you already created these variables at the top of the main function -- it will override these values but it actually doesnt matter since from this part you will skip to the end and these initial values for both variables -- wont be needed anymore until username == "Hakz_Studios" and message == "Stop Refueling" rs.setOutput(sides.bottom, 0) -- I assume you want to deactivate the redstone after you're done refueling elseif username == "Hakz_Studios" and message == "Stop Refuel System" then os.execute("Shutdown") -- again, this will start the program "Shutdown" with a capital "S" end -- as you can see, we skip the last else statement, as it will call the main function recursively, resulting in a overflow error pretty fast -- you could get away with returning a call to the main function, but this wouldnt be good practice eiter, I guess end -- we add a last while loop, which will repeat endlessly calling the main function while true do main() end I hope this helps. Also you did great for your first shot at programming!
  8. I‘m not 100% sure, what causes the error, but it seems the installer doesn‘t handle the http request user data properly. You could try running the following command: wget https://raw.githubusercontent.com/zenith391/Fuchas/master/Installers/openos.lua installer installer Sadly I can‘t test this right now, but it might be worth trying. Edit: Ok, i figured out what is causing the error. The colon (:) in function call "data = con:read(math.huge)" in line 11 must be replaced with a period (.). So what definitely works is running pastebin get s2YZJ0T6 installer.lua replacing ":" with "." in line 11, and then run the installer. But I get an unrecoverable error on restarting the computer after successful installation...
  9. You can also use event timers. Then you need a function to check and send your stuff. local event = require "event" local function dostuff() -- this is ur function that is doing stuff end local interval = 20 -- time in seconds between the runs of the function event.timer(interval, dostuff, math.huge) -- math.huge for infinite repeats Or if you want to keep Skript as it is, you can use Molinko's approach with os.execute Then your code would be: event.timer(interval, function() os.execute("/path"), math.huge)
  10. Ok, I forgot the program doesn‘t always run in the executor thread. Too bad there are only ways to have blocking high precision sleeps and timers and no non-blocking alternatives... But anyways, thanks alot
  11. @payonel Hey, I was wondering if there is any chance to see a high precision computer.pull function in OpenComputers, allowing to have timeouts below one tick (I believe the currently used computer.uptime only returns time with .05 s precision). With that in hand, non-blocking sleeps and timers for small time intervals should be realizable. I was trying to implement this in openOS by adding a computer.pull function using os.clock instead of computer.uptime and changing some other libs accordingly, but it didn't work out. So I'm asking if there is any reason against adding a higher precision version of computer.pull to "machine"? Thanks:)
  12. Hey, you are correct, string metatables are protected, so you can‘t change or add functions. I assume, unicode.len(string) is not what you want, or is it? In case you want to have an object, you could interact with, you could build one. local unicode = require"unicode" local ucode = {} local mt = { __len = function(self) return unicode.len(self.string) end } function ucode.new(str) local obj = { string = str } return setmetatable(obj, mt) end return ucode Sorry for the code being just plane text, I’m on my mobile and dont know how to insert some code properly so i‘ll will make a proper one as soon as i get to my pc. You then add all the missing functions of the unicode or string lib that you want to the metatable, and then you are good to go. Btw, with the __len function, you should be able to call #objname, and it should return the correct length.
  13. Ok, I see. With the colors, I would use your custom table, it should be fine, so you don't need to require colors. Sadly I am really busy right now, so I can't have a look at the code for like 2 days. It would be great if you could try to do as many tests and improvements as possible, and then I will have a look at your new results.
  14. I‘m glad that I could help. You‘re welcome! Could you post the error message?
  15. Ok, so the issue with locals you had is the following. When using local, it's important to have the right order of variable/function definitions, let me give an example: local function func_x() print("X") end -- that is some random function local function func_xy() func_x() func_y() end -- a function that will call func_x amd func_y -- this will throw an error, because func_y is defined after it is called by func_xy local function func_y() print("Y") end -- you have to ensure the right order! Ok, so I did some rearrangement of your functions, I hope it works. local API = require("buttonAPI") -- On appelle l'API "buttonAPI" local component = require("component") -- On appelle l'API "component" local term = require("term") -- On appelle l'API "term" local event = require("event") -- On appelle l'API "event" local colors = require("colors") -- On appelle l'API "colors" -- you are overwriting the colors api later, do you actually need that api? local mon = component.gpu local trm = term local egy = component.energy_device local brR = component.br_reactor local brT = component.br_turbine local steamReactor = brR.isActivelyCooled() local menuType = "Reactor" local numCapacitors = 36 local turnOnAt = 50 local turnOffAt = 90 local targetSpeed = 1840 local energy = 0 local energyStored = 0 local energyMax = 0 local energyStoredPercent = 0 local timerCode local mode = "Automatic" local RFProduction = 0 local fuelUse = 0 local coreTemp = 0 local reactorOnline = false local rodLevel = 0 local turbineOnline = false local turbineRotorSpeed = 0 local turbineRFGen = 0 local turbineFluidRate = 0 local turbineInductor = false local OptFuelRodLevel = 0 -- COLORS -- here are you overwriting colors. If you only need this table, you can remove 'require("colors")' above. local colors = {} colors.white = 0xFFFFFF colors.orange = 0xFFA500 colors.magenta = 0xFF00FF colors.lightblue = 0x00AEEF colors.yellow = 0xFFFF00 colors.lime = 0x00FF00 colors.pink = 0xFFC0CB colors.gray = 0x555555 colors.lightGray = 0xD3D3D3 colors.grey = 0x555555 colors.silver = 0xAAAAAA colors.cyan = 0x00FFFF colors.purple = 0x800080 colors.blue = 0x0000FF colors.brown = 0x603913 colors.green = 0x008000 colors.red = 0xFF0000 colors.black = 0x000000 local function checkMode() API.toggleButton(mode) end local function menuMode() if steamReactor then if menuType == "Reactor" then API.setButton("Reactor", true) API.setButton("Turbine", false) else API.setButton("Reactor", false) API.setButton("Turbine", true) end end end local function online() brR.setActive(true) --API.flash("Online") end local function offline() brR.setActive(false) --API.flash("Offline") end local function setTurbineOnline() brT.setActive(true) --API.flash("Online") end local function setTurbineOffline() brT.setActive(false) --API.flash("Offline") end local function reactorOnOff() API.setButton("Online", brR.getActive()) API.setButton("Offline", not brR.getActive()) end local function turbineOnOff() API.setButton("Online", brT.getActive()) API.setButton("Offline", not brT.getActive()) end local function coilsOnOff() API.setButton("Coils On", brT.getInductorEngaged()) API.setButton("Coils Off", not brT.getInductorEngaged()) end local function coilsOn() brT.setInductorEngaged(true) end local function coilsOff() brT.setInductorEngaged(false) end local function fuelRodLevel() rodLevel = brR.getControlRodLevel(0) --print(rodLevel) trm.setCursor(30,5) trm.write(tostring(rodLevel).."%") mon.setBackground(colors.white) trm.setCursor(28,6) trm.write(" ") for i = 1,10 do trm.setCursor(28,i+6) mon.setBackground(colors.white) trm.write(" ") mon.setBackground(colors.yellow) trm.write(" ") if rodLevel/10 >= i then mon.setBackground(colors.red) else mon.setBackground(colors.yellow) end trm.write(" ") mon.setBackground(colors.yellow) trm.write(" ") mon.setBackground(colors.white) trm.write(" ") end trm.setCursor(28,17) trm.write(" ") mon.setBackground(colors.black) end local function turbineInductorDisplay() turbineInductor = brT.getInductorEngaged() trm.setCursor(30,5) if turbineInductor then trm.write("On") else trm.write("Off") end mon.setBackground(colors.gray) trm.setCursor(28,6) trm.write(" ") for i = 1,7 do trm.setCursor(28,i+6) mon.setBackground(colors.gray) trm.write(" ") mon.setBackground(colors.lightGray) trm.write(" ") if i % 2 == 0 then mon.setBackground(colors.gray) end trm.write(" ") mon.setBackground(colors.gray) trm.write(" ") if i % 2 ~= 0 then mon.setBackground(colors.lightGray) end trm.write(" ") mon.setBackground(colors.lightGray) trm.write(" ") mon.setBackground(colors.gray) trm.write(" ") end for i = 8,10 do trm.setCursor(28,i+6) mon.setBackground(colors.gray) trm.write(" ") mon.setBackground(colors.lightGray) trm.write(" ") if turbineInductor then mon.setBackground(colors.red) else mon.setBackground(colors.blue) end trm.write(" ") mon.setBackground(colors.gray) trm.write(" ") if turbineInductor then mon.setBackground(colors.red) else mon.setBackground(colors.blue) end trm.write(" ") mon.setBackground(colors.lightGray) trm.write(" ") mon.setBackground(colors.gray) trm.write(" ") end trm.setCursor(28,17) trm.write(" ") mon.setBackground(colors.black) end local function getClick() local event, side, x, y = event.pull(1,"touch") -- This should be the string "touch" as you want to look for a touch event, right? if x == nil or y == nil then local h, w = mon.getResolution() mon.set(h, w, ".") mon.set(h, w, " ") else API.checkxy(x,y) end end local function comma_value(amount) local formatted = amount local swap = false if formatted < 0 then formatted = formatted*-1 swap = true end while true do formatted, k = string.gsub(tostring(formatted), "^(%d+)(%d%d%d)", '%1,%2') if k == 0 then break end end if swap then formatted = "-"..formatted end return formatted end local function displayEn() trm.clear() trm.setCursor(1,1) --print("Energy Use: "..energy) trm.write("Energy Use: ") if energy < 0 then mon.setForeground(colors.red) else mon.setForeground(colors.green) end trm.write(comma_value(math.floor(energy)).. "RF/t") mon.setForeground(colors.white) trm.setCursor(1,2) trm.write("Energy Stored: "..energyStoredPercent.."%") if menuType == "Reactor" then trm.setCursor(1,3) trm.write("Reactor is: ") if reactorOnline then mon.setForeground(colors.green) trm.write("Online") else mon.setForeground(colors.red) trm.write("Offline") end mon.setForeground(colors.white) trm.setCursor(22,1) if steamReactor then trm.write("Steam: ") mon.setForeground(colors.green) trm.write(comma_value(math.floor(RFProduction)).."MB/t") else trm.write("RF Gen: ") mon.setForeground(colors.green) trm.write(comma_value(math.floor(RFProduction)).."RF/t") end mon.setForeground(colors.white) trm.setCursor(22,2) trm.write("Core Temp: "..math.floor(coreTemp).."c") trm.setCursor(22,3) trm.write("Fuel Use: "..fuelUse.."MB/t") else trm.setCursor(1,3) trm.write("Turbine is: ") if turbineOnline then mon.setForeground(colors.green) trm.write("Online") else mon.setForeground(colors.red) trm.write("Offline") end trm.setCursor(1,4) mon.setForeground(colors.white) trm.write("Reactor is: ") if reactorOnline then mon.setForeground(colors.green) trm.write("Online") else mon.setForeground(colors.red) trm.write("Offline") end mon.setForeground(colors.white) trm.setCursor(22,1) trm.write("RFGen: ") mon.setForeground(colors.green) trm.write(comma_value(math.floor(turbineRFGen)).."RF/t") mon.setForeground(colors.white) trm.setCursor(22,2) trm.write("Rotor: "..comma_value(math.floor(turbineRotorSpeed)).." RPM") trm.setCursor(22,3) trm.write("Steam: "..comma_value(turbineFluidRate).."MB/t") end end local function checkEn() local tempEnergy = 0 energyStored = egy.getEnergyStored() energyMax = egy.getMaxEnergyStored() energyStoredPercent = math.floor((energyStored/energyMax)*100) RFProduction = brR.getEnergyProducedLastTick() fuelUse = brR.getFuelConsumedLastTick() fuelUse = math.floor(fuelUse*100) fuelUse = fuelUse/100 coreTemp = brR.getFuelTemperature() reactorOnline = brR.getActive() tempEnergy = egy.getEnergyStored() os.sleep(0.1) energy = (egy.getEnergyStored()-tempEnergy)/2 energy = energy*numCapacitors if steamReactor then turbineOnline = brT.getActive() turbineRotorSpeed = brT.getRotorSpeed() turbineRFGen = brT.getEnergyProducedLastTick() turbineFluidRate = brT.getFluidFlowRate() end end local function findOptFuelRods() trm.clear() brR.setActive(false) checkEn() displayEn() fuelRodLevel() while brR.getFuelTemperature() > 99 do for i= 1,3 do checkEn() displayEn() fuelRodLevel() trm.setCursor(3,6) trm.write("Finding Optimal Rod Level") trm.setCursor(3,7) trm.write("Core Temp: "..brR.getFuelTemperature()) trm.setCursor(3,8) trm.write("Waiting for 99c") os.sleep(1) end end while brR.getHotFluidAmount() > 10000 do for i = 1,3 do checkEn() displayEn() fuelRodLevel() trm.setCursor(3,6) trm.write("Finding Optimal Rod Level, please wait ....") trm.setCursor(3,7) trm.write("Fluid Amount: "..comma_value(brR.getHotFluidAmount()).."mb") trm.setCursor(3,8) trm.write("Waiting for 10,000mb") os.sleep(1) end end brR.setAllControlRodLevels(99) brR.setActive(true) while brR.getFuelTemperature() < 100 do for i = 1,5 do checkEn() displayEn() fuelRodLevel() trm.setCursor(3,6) trm.write("Set all rod levels to 99") trm.setCursor(3,7) trm.write("Waiting 5 seconds...") os.sleep(1) end end for i = 1,5 do checkEn() displayEn() fuelRodLevel() trm.setCursor(3,6) trm.write("Set all rod levels to 99") trm.setCursor(3,7) trm.write("Waiting 5 seconds...") os.sleep(1) end local tempMB = brR.getEnergyProducedLastTick() print(tempMB.."MB/t of steam") local tempRodLevels = math.floor(2000/tempMB) print("2000/"..tempMB.." = "..tempRodLevels) tempRodLevels = 100-tempRodLevels+5 print("Adding 5 to Rod Levels: "..math.floor(tempRodLevels)) brR.setAllControlRodLevels(math.floor(tempRodLevels)) print("Waiting 10 seconds to confirm...") for i = 1,10 do checkEn() displayEn() fuelRodLevel() trm.setCursor(3,6) trm.write("Estimated Level: "..tempRodLevels) trm.setCursor(3,7) trm.write("Waiting 10 seconds...") os.sleep(1) end tempMB = brR.getEnergyProducedLastTick() while tempMB > 2000 do tempRodLevels = tempRodLevels+1 brR.setAllControlRodLevels(math.floor(tempRodLevels)) print("Setting Rod Levels to: "..tempRodLevels) for i = 1,5 do checkEn() displayEn() fuelRodLevel() trm.setCursor(3,6) trm.write("Getting below 2000mb/t") trm.setCursor(3,7) trm.write("Currently at: "..tempMB) os.sleep(1) end tempMB = brR.getEnergyProducedLastTick() end while tempMB < 2000 do tempRodLevels = tempRodLevels -1 brR.setAllControlRodLevels(math.floor(tempRodLevels)) print("Setting Rod Levels to: "..tempRodLevels) for i = 1,5 do checkEn() displayEn() fuelRodLevel() trm.setCursor(3,6) trm.write("Getting Above 2000mb/t") trm.setCursor(3,7) trm.write("Currently at: "..tempMB) os.sleep(1) end tempMB = brR.getEnergyProducedLastTick() end OptFuelRodLevel = tempRodLevels end local function setRods(setLevel) print("Setting Rod Level: "..setLevel) API.flash(tostring(setLevel)) brR.setAllControlRodLevels(setLevel) fuelRodLevel() end local function rodPlus() API.flash("+") brR.setAllControlRodLevels(rodLevel+1) fuelRodLevel() end local function rodMinus() API.flash("-") brR.setAllControlRodLevels(rodLevel-1) fuelRodLevel() end local function autoReactor() if not steamReactor then brR.setAllControlRodLevels(0) if energyStoredPercent < turnOnAt then if not reactorOnline then online() end end if energyStoredPercent > turnOffAt then if reactorOnline then offline() end end else brR.setAllControlRodLevels(OptFuelRodLevel) if energyStoredPercent < turnOnAt then --online() setTurbineOnline() coilsOn() end if energyStoredPercent > turnOffAt then --if turbineRotorSpeed > 1800 then -- offline() --else -- online() --end setTurbineOnline() coilsOff() end if turbineRotorSpeed > targetSpeed then offline() else online() end end end local displayScreen -- some of your functions calle ach other, that makes it hard to find a correct order -- so I just define displayScreen, so the function can be defined later local manualMode local function autoMode() local mode = "Automatic" displayScreen() end local function reactorMenu() local menuType = "Reactor" displayScreen() end local function turbineMenu() local menuType = "Turbine" displayScreen() end local function manualMenu() API.clearTable() API.setTable("Automatic", autoMode, "", 3, 13, 6, 6) API.setTable("Manual", manualMode, "", 15, 25, 6, 6) API.setTable("Online", online, "", 3, 13, 8, 8) API.setTable("Offline", offline, "", 15, 25, 8, 8) API.setTable("0", setRods, 0, 11,14, 10, 10) API.setTable("10", setRods, 10, 5,8, 12, 12) API.setTable("20", setRods, 20, 11,14, 12, 12) API.setTable("30", setRods, 30, 17,20, 12, 12) API.setTable("40", setRods, 40, 5,8, 14, 14) API.setTable("50", setRods, 50, 11,14, 14, 14) API.setTable("60", setRods, 60, 17,20, 14, 14) API.setTable("70", setRods, 70, 5,8, 16, 16) API.setTable("80", setRods, 80, 11,14, 16, 16) API.setTable("90", setRods, 90, 17,20, 16, 16) API.setTable("+", rodPlus, "", 23, 25, 12, 12) API.setTable("-", rodMinus, "", 23, 25, 16, 16) if steamReactor then API.setTable("Reactor", reactorMenu, "", 5, 18, 19, 19) API.setTable("Turbine", turbineMenu, "", 22, 35, 19, 19) end API.screen() checkMode() reactorOnOff() menuMode() end function manualMode() local mode = "Manual" manualMenu() end local function autoMenu() API.clearTable() API.setTable("Automatic", autoMode, "", 3, 13, 6, 6) API.setTable("Manual", manualMode, "", 15, 25, 6, 6) if steamReactor then API.setTable("Reactor", reactorMenu, "", 5, 18, 19, 19) API.setTable("Turbine", turbineMenu, "", 22, 35, 19, 19) end API.screen() checkMode() menuMode() end local function turbineAutoMenu() API.clearTable() API.setTable("Automatic", autoMode, "", 3, 13, 6, 6) API.setTable("Manual", manualMode, "", 15, 25, 6, 6) API.setTable("Reactor", reactorMenu, "", 5, 18, 19, 19) API.setTable("Turbine", turbineMenu, "", 22, 35, 19, 19) API.screen() checkMode() menuMode() end local function turbineManualMenu() API.clearTable() API.setTable("Automatic", autoMode, "", 3, 13, 6, 6) API.setTable("Manual", manualMode, "", 15, 25, 6, 6) API.setTable("Reactor", reactorMenu, "", 5, 18, 19, 19) API.setTable("Turbine", turbineMenu, "", 22, 35, 19, 19) API.setTable("Online", setTurbineOnline, "", 3, 13, 8, 8) API.setTable("Offline", setTurbineOffline, "", 15, 25, 8, 8) API.setTable("Coils On", coilsOn, "", 3, 13, 10, 10) API.setTable("Coils Off", coilsOff, "", 15, 25, 10, 10) API.screen() checkMode() turbineOnOff() coilsOnOff() menuMode() end function displayScreen() -- repeat checkEn() displayEn() if menuType == "Reactor" then fuelRodLevel() if mode == "Automatic" then autoMenu() autoReactor() else manualMenu() end else turbineInductorDisplay() if mode == "Automatic" then turbineAutoMenu() autoReactor() else turbineManualMenu() end end getClick() end if steamReactor then findOptFuelRods() end while true do displayScreen() os.sleep(1) end
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.