Hi
Im trying to get an advanced computer to accept a redstone pulse from the bottom of the computer and then send 3 short redstone pulses out the right side of the comp I know how to use the rs.setOutput() command and the rs.getInput() however i cant get the Os.pullEvent to work can anyone help? there was a redstone basic tutorial that i used to try and get it working but it doesn't quite work the way i want it to here but that one works when there is a constant redstone signal not just a single pulse
i also want to use a loop function so i dont have to have repeated lines of code.
redstone help needed
Started by DTM450, Apr 03 2014 09:54 AM
5 replies to this topic
#1
Posted 03 April 2014 - 09:54 AM
#2
Posted 03 April 2014 - 05:33 PM
Throw up your code and we can point out what's wrong. You have to keep in mind that os.pullEvent reacts to any redstone changes, but it dosen't specify where it happened. You'll have to manually check the current state of the redstone when you get the event.
#3
Posted 04 April 2014 - 12:12 AM
ok so my code is
Im not sure if Im using the Os.pullEvent function right
I also want to loop the output true/false bit of the code so that it runs 3 times
ok so i was using Os.pullEvent instead of os.pullEvent I changed that in the code, that removed the error i was getting now i just need to loop the setOuput bit which im having trouble with
os.pullEvent("redstone") do
if rs.getInput("bottom") then
rs.setOutput("right",true)
sleep(0.3)
rs.setOutput("right",false)
end
end
I also want to loop the output true/false bit of the code so that it runs 3 times
ok so i was using Os.pullEvent instead of os.pullEvent I changed that in the code, that removed the error i was getting now i just need to loop the setOuput bit which im having trouble with
Edited by DTM450, 04 April 2014 - 02:01 AM.
#4
Posted 04 April 2014 - 04:29 AM
ok so i figured out how to get the loop working correctly here is my revised program
count = 1 -- loop condition
while (true) do
os.pullEvent("redstone")
if rs.getInput("bottom") then
for count = 1, 3, 1 do
-- print(count)
rs.setOutput("right",true)
sleep(0.2)
rs.setOutput("right",false)
sleep(0.1)
end
end
end
#5
Posted 04 April 2014 - 05:08 AM
You don't need to declare the count variable on the first line, it's declared locally when the loop starts.
#6
Posted 04 April 2014 - 05:41 AM
ok cool thanks
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











