Hello all its my first time here but i have a problem that i cannot solve.
I need to make a program that runs all the time, and it needs to first check if its getting a redstone signal, then it needs to choose a random integer between 1-3 and output a redstone signal in one of three ways. Sorry for the bad description and grammar, tell me if you need me to get a picture of what i am trying to do....
0
2 replies to this topic
#1
Posted 17 September 2014 - 12:05 AM
#2
Posted 17 September 2014 - 01:47 AM
local inputSide = "back" -- Or whatever. local outputSide = {"front","right","left"} -- Or whatever. local outputPulseDuration = 1 -- Or whatever. while true do -- Start a loop that repeats indefinitely. if rs.getInput(inputSide) then -- If we're getting input, local currentOutput = math.random(#outputSide) -- ... choose a random number between one and the number of entries in outputSide... rs.setOutput(outputSide[currentOutput],true) -- ... enable the output which corresponds to that number in the outputSide table... sleep(outputPulseDuration) -- ... wait a while... rs.setOutput(outputSide[currentOutput],false) -- ... then turn it off again. while rs.getInput(inputSide) do -- Then, so long as we're STILL getting input, os.pullEvent("redstone") -- ... wait for changes in redstone input. end end os.pullEvent("redstone") -- Wait for any change in input (eg the signal turning back on). end -- Go back up and repeat the loop.
Edited by Bomb Bloke, 17 September 2014 - 01:50 AM.
#3
Posted 17 September 2014 - 09:31 PM
name the program startup, so it would automatically start if you open the computer and stay on until minecraft restart.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users