22 posts
Posted 07 November 2012 - 06:23 PM
print("Loading…")
write "choose Option…"
print("Empty")
print("Power")
x = Empty
y = Power
input = read()
if x == Empty then
rs.setBundledOutput( "right!, colors.lime)
input = read()
if y == Power then
rs.setBundledOutput( "right", colors.white)
sleep(1)
else
printed("incorrect answer")
sleep(2)
os.shutdown()
end
its got bbundled cables going to a lime and a white cable that im testing with pistons, i want the green to be powered when i haave typed 'empty' and i want the white to go when i have typed 'Power' the problem is is that the pistons change no matter what i type :P/>/> any ideas? sorry if its not clear
122 posts
Location
New Zealand
Posted 07 November 2012 - 06:25 PM
Go and look at your other thread and try the code I posted there. See if that works or not.
22 posts
Posted 07 November 2012 - 06:33 PM
i have tried it, it didnt work when i typed power and empty is said incorrect answer :/
122 posts
Location
New Zealand
Posted 07 November 2012 - 06:37 PM
Oh right. Give me a few mins and i'll add it to the code.
59 posts
Location
Norway
Posted 07 November 2012 - 06:38 PM
print("Loading...")
write "choose Option..."
print("Empty")
print("Power")
input = read()
if input == "x" then
rs.setBundledOutput( "right", colors.lime)
elseif input == "y" then
rs.setBundledOutput( "right", colors.white)
os.sleep(1)
else
printed("incorrect answer")
os.sleep(2)
os.shutdown()
end
Im not completly sure what you want to be the inputs. but just change the stuff in the input == "" to get something else that y and x
122 posts
Location
New Zealand
Posted 07 November 2012 - 06:43 PM
Yeah, sjonky you made the same error or overlooked mine.
Theres "s on the x and y when theres not meant to. Also you got rid of the variables.
print("Loading...")
print("choose Option...")
print("Empty")
print("Power")
local x = "Empty"
local y = "Power"
input = read()
if input == x then
rs.setBundledOutput( "right", colors.lime)
elseif input == y then
rs.setBundledOutput( "right", colors.white)
sleep(1)
else
print("incorrect answer")
sleep(2)
os.reboot()
end
59 posts
Location
Norway
Posted 07 November 2012 - 06:46 PM
Ah, yeah wasn't sure exactly what he wanted :P/>/> but seems good there, although i think you need os.sleep(x) and not just sleep(x) too.
122 posts
Location
New Zealand
Posted 07 November 2012 - 06:48 PM
No, sleep(x) works. I never knew it was os.sleep(x). Its like I never knew the proper way to use 'write' was term.write(), but you can use the short version of it, write()
59 posts
Location
Norway
Posted 07 November 2012 - 06:52 PM
Oh really? :D/>/> i've always used os.sleep and term.write :P/>/> But good to know that i can shorten them down
122 posts
Location
New Zealand
Posted 07 November 2012 - 06:54 PM
I would also suggest, just for self use, creating a clear() and monclear() api so you dont have to type the shell.run or the whole term.clear() command. Its quite useful in my opinion
818 posts
Posted 07 November 2012 - 07:01 PM
hmm, creating a function to make 2 lines to 1… seems like a timewaste to me actually, and you dont completely clear the screen that often
122 posts
Location
New Zealand
Posted 07 November 2012 - 07:04 PM
A lot of programs do actually require you to clear the screen often. and its actually shortening it from 36 characters to 7. Its way simpler and its not like its a hard function.
2217 posts
Location
3232235883
Posted 07 November 2012 - 07:05 PM
No, sleep(x) works. I never knew it was os.sleep(x). Its like I never knew the proper way to use 'write' was term.write(), but you can use the short version of it, write()
incorrect, the write function is implemented in bios.lua and is different from term.write
write supports newline and wraps text around the screen, term.write is the raw term function and i usually only use it when im working with GUIs so they dont make the screen glitch up ;_;
122 posts
Location
New Zealand
Posted 07 November 2012 - 07:07 PM
You learn something new everyday. Now that I did not actually know. That could be very useful to know. Thank you Pixel