Posted 18 May 2014 - 07:09 PM
I'm stepping up my game a bit now, and I'm writing a control rod program for my BigReactors reactor! I'm trying to figure out how to set up the program so that it only accepts one number between 0 and 100 as its argument. So far I've got it set to check that the amount of arguments is exactly one (so that it only accepts one argument):
That's how I want the code to work, in theory, but any advice on what I should do to make sure it accepts the argument and passes it on would be appreciated!
mon=peripheral.wrap('top')
reactor=peripheral.wrap('BigReactors-Reactor_0')
args = {...}
if #args == 1 and (is a number between 0 and 100) then
reactor.setControlRodLevel(0, (arg))
sleep(0.2)
crn=reactor.getControlRodName(0)
crl=reactor.getControlRodLevel(0)
mon.clear()
mon.setCursorPos(1,1)
mon.write(crn.." now at "..crl.." percent.")
sleep(5)
mon.clear()
else
mon.clear()
mon.setCursorPos(1,1)
mon.write("Must be a number between 0 and 100")
sleep(5)
mon.clear()
end
That's how I want the code to work, in theory, but any advice on what I should do to make sure it accepts the argument and passes it on would be appreciated!
Edited on 18 May 2014 - 05:17 PM