Thank you for pointing me in the right direction! I had to make a couple of changes to the script (I changed the > and < to >= and <= so that 0 and 100 would be accepted as values too, and I had to change args[1] to tonumber(args[1]) for the setControlRodLevel command as well), and I added in my error handling stuff as well, and everything works smoothly now. Thank you, wieselkatze!
For anyone who would like to try out my control rod program, either check out the code below or type "pastebin get 1sJAmDP3 crod" on your own computer, if you have your own BigReactors reactor you'd like to try this on! (As always, you may need to change the peripheral.wraps so that they're ready for your system setup.)
mon=peripheral.wrap('top')
reactor=peripheral.wrap('BigReactors-Reactor_0')
args = {...}
if tonumber(args[1]) then
if tonumber(args[1]) >= 0 and tonumber(args[1]) <= 100 then
reactor.setControlRodLevel(0, tonumber(args[1]))
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 between 1 and 100!")
sleep(5)
mon.clear()
end
else
mon.clear()
mon.setCursorPos(1,1)
mon.write("Must have ONE numeric value!")
sleep(5)
mon.clear()
end
(EDIT: changed the code a bit so the error reporting can fit on a 3-wide monitor!)
Edited by Chaz, 18 May 2014 - 08:12 PM.