I'm working on a small bit of code that reads from a IC2 power storage block and displays it's current and maximum storage. I also want it to toggle a Reactor based on either a keypress or a CLI menu option.
As the code has to refresh a LOT, I think a keypress option is the easiest way, but I can't, for the life of me, figure it out. Here's what I have so far...
os.execute("cls")--Hook the component
local component =require("component")local term =require("term")local side =require("sides")local keyboard =require("keyboard")localevent=require("event")local rs = component.redstone
local batbox = component.cesu
local board = component.keyboard
function toggleBox()if rs.getOutput(side.top)==18then
rs.setOutput(side.top,0)else
rs.setOutput(side.top,18)endendlocalfunction keyCheck()whiletruedo
e =event.pull(1,"key_up")if e =="enter"then
toggleBox()
elseif e =="back"then
running =falseendendend
keyChecker = coroutine.create(keyCheck)function main()
running =truewhiletruedo--Get the tank information, results are in table format
local tInfo = batbox
local cap = tonumber(batbox.getCapacity())local fill = tonumber(batbox.getStored())--Outputas you want... a very simple way:print("CESU Power Levels and Controls")print("Energy Stored : "..fill)print("CESU Capacity : "..cap)print("\n Press Enter to toggle reactor.")print("Press Back to return to OpenOS.")
term.setCursor(1,1)endend
main()
And yes, I now see the redundancy of having "cls" there, when I have 'term.setCursor(1,1)' there...
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
I'm working on a small bit of code that reads from a IC2 power storage block and displays it's current and maximum storage. I also want it to toggle a Reactor based on either a keypress or a CLI menu option.
As the code has to refresh a LOT, I think a keypress option is the easiest way, but I can't, for the life of me, figure it out. Here's what I have so far...
And yes, I now see the redundancy of having "cls" there, when I have 'term.setCursor(1,1)' there...
What is it that I am missing?
Link to post
Share on other sites