Jump to content




throw 3 switches and continue


  • You cannot reply to this topic
1 reply to this topic

#1 Xixili

  • Members
  • 65 posts
  • LocationChina

Posted 30 August 2015 - 12:43 AM

Its hard to find the right topic title but I will explain it here in more detail.

I have 3 switches connected on bundled cables.

brown, green and red.

I want that the computer wait forthe levers before it continues.

The 3 levers needs to be switched before the computer continues.

But my problem is that the computer already continues at 1 lever.

this is the code:
os.pullEvent("redstone")
if rs.testBundledInput("left", colours.brown) then
term.setTextColor(colors.red)
term.setCursorPos(38, 5)
term.write("unlocked")
end
 
os.pullEvent("redstone")
if rs.testBundledInput("left", colours.green) then
term.setTextColor(colors.red)
term.setCursorPos(38, 6)
term.write("unlocked")
end
os.pullEvent("redstone")
if rs.testBundledInput("left", colours.red) then
term.setTextColor(colors.red)
term.setCursorPos(38, 7)
term.write("unlocked")
end
sleep(3)
rs.setBundledOutput("left", colours.black+colours.pink+colours.white)
sleep(5)


And the whole code can be found here:
http://pastebin.com/6MwycAaE

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 30 August 2015 - 02:28 AM

When you want your script to process a bit of code until a certain condition occurs, you use a "while" or a "repeat" loop:

term.setTextColor(colors.red)

while not rs.testBundledInput("left", colours.combine(colours.brown, colours.green, colours.red)) do
	term.setCursorPos(38, 5)
	term.write(rs.testBundledInput("left", colours.brown) and "unlocked" or "locked  ")

	term.setCursorPos(38, 6)
	term.write(rs.testBundledInput("left", colours.green) and "unlocked" or "locked  ")

	term.setCursorPos(38, 7)
	term.write(rs.testBundledInput("left", colours.red) and "unlocked" or "locked  ")

	os.pullEvent("redstone")
end






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users