Jump to content




end while by rs input


  • You cannot reply to this topic
7 replies to this topic

#1 darcline

  • Members
  • 33 posts

Posted 29 January 2013 - 06:15 AM

hello the title is all :D

but i have here sme code, because i will that when redstone input comes that a while will end but it´s not working, and sorry for bad english

while true do
x = redstone.setBundledOutput("right", colors.blue)
local x = false

while x == false do
term.clear()
local w, h = term.getSize()
for i=0, w, 1 do
term.setCursorPos(1+i,1)
print("#")
end
for i=0, w, 1 do
term.setCursorPos(1+i,h)
print("#")
end
for i=0, h, 1 do
term.setCursorPos(1,1+i)
print("#")
end
for i=0, h, 1 do
term.setCursorPos(w,1+i)
print("#")
end

term.setCursorPos(2,2)
print("Waehlen sie bitte ein Option:")
term.setCursorPos(3,3)
print("<U> Fahrstuhl hochfahren")
term.setCursorPos(3,4)
print("<D> Fahrstuhl runterfahren")
term.setCursorPos(3,6)
local eingabe = read()

if (eingabe == "U" or eingabe == "u" and redstone.testBundledInput("right", colors.white+colors.orange)) == true then
for i=0,13 do
redstone.setBundledOutput("right", colors.green)
sleep(0.5)
redstone.setBundledOutput("right", 0)
sleep(0.5)
end
end


if (eingabe == "D" or eingabe == "d" and redstone.testBundledInput("right", colors.white+colors.orange)) == true then
for i=0,13 do
redstone.setBundledOutput("right", colors.brown)
sleep(0.5)
redstone.setBundledOutput("right", 0)
sleep(0.5)
end
else
os.reboot()
end
end
end

please helpt me and it must a bundled cable input with color blue

#2 bjornir90

  • Members
  • 378 posts
  • LocationFrance

Posted 29 January 2013 - 07:16 AM

You need to use
if redstone input then --put any condition here
 break
end


#3 darcline

  • Members
  • 33 posts

Posted 29 January 2013 - 08:51 AM

ahm its not working the program starts and stops.

can you write it in the full script ?

#4 OmegaVest

  • Members
  • 436 posts

Posted 29 January 2013 - 09:10 AM

Okay, soa question first:

Does anything other than the computer turn the blue line on? If not, the computer will ignore this line as an input for the purposes of testBundledInput.

However, once you have rectified that, you will simply need to do this:

Spoiler

Like bjornir90 said.



Also, testBundledInput I think only works with one color. To test for multiple inputs, you will either need multiple rs tests or use colors.test, which will take a set of colors as opposed to a single color. You could also use colors.combine(), but I can't test that functionality at the moment.



EDIT: Thanks Orwell.

#5 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 29 January 2013 - 09:17 AM

View PostOmegaVest, on 29 January 2013 - 09:10 AM, said:

Also, testBundledInput I think only works with one color. To test for multiple inputs, you will either need multiple rs tests or use colors.test, which will take a set of colors as opposed to a single color. You could also use colors.combine(), but I can't test that functionality at the moment.
You have a typo in the spoiler and yes, testBundledInput does take the sum of color values as a parameter and reacts as expected. However, simply taking the sum of colors will only work if none of the colors are used more than once. Keep that in mind. ;) xor'ing them or using colors.combine() is indeed a better method.

#6 darcline

  • Members
  • 33 posts

Posted 29 January 2013 - 10:18 AM

i need only one color ;) but when i start the program he says me that he want a do at line 2

#7 OmegaVest

  • Members
  • 436 posts

Posted 29 January 2013 - 10:22 AM

My error. It should be a do instead of then. My fingers are often quicker than my brain.

#8 darcline

  • Members
  • 33 posts

Posted 29 January 2013 - 10:42 AM

i changed to do the program start and stops quickly heres the code now

local x = false
while rs.testBundledInput("right", colors.blue) do
term.clear()
local w, h = term.getSize()
for i=0, w, 1 do
term.setCursorPos(1+i,1)
print("#")
end
for i=0, w, 1 do
term.setCursorPos(1+i,h)
print("#")
end
for i=0, h, 1 do
term.setCursorPos(1,1+i)
print("#")
end
for i=0, h, 1 do
term.setCursorPos(w,1+i)
print("#")
end

term.setCursorPos(2,2)
print("Waehlen sie bitte ein Option:")
term.setCursorPos(3,3)
print("<U> Fahrstuhl hochfahren")
term.setCursorPos(3,4)
print("<D> Fahrstuhl runterfahren")
term.setCursorPos(3,6)
local eingabe = read()

if (eingabe == "U" or eingabe == "u" and redstone.testBundledInput("right", colors.white+colors.orange)) == true then
for i=0,13 do
redstone.setBundledOutput("right", colors.green)
sleep(0.5)
redstone.setBundledOutput("right", 0)
sleep(0.5)
end
end


if (eingabe == "D" or eingabe == "d" and redstone.testBundledInput("right", colors.white+colors.orange)) == true then
for i=0,13 do
redstone.setBundledOutput("right", colors.brown)
sleep(0.5)
redstone.setBundledOutput("right", 0)
sleep(0.5)
end
else
os.reboot()
end
break
end





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users