This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ryarsh's profile picture

more help for me, im a noob

Started by ryarsh, 07 November 2012 - 05:23 PM
ryarsh #1
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
Kryptanyte #2
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.
ryarsh #3
Posted 07 November 2012 - 06:33 PM
i have tried it, it didnt work when i typed power and empty is said incorrect answer :/
Kryptanyte #4
Posted 07 November 2012 - 06:37 PM
Oh right. Give me a few mins and i'll add it to the code.
sjonky #5
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
Kryptanyte #6
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
	
	
sjonky #7
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.
Kryptanyte #8
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()
sjonky #9
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
Kryptanyte #10
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
Doyle3694 #11
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
Kryptanyte #12
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.
PixelToast #13
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 ;_;
Kryptanyte #14
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