24 posts
Posted 26 January 2013 - 08:03 PM
I am trying to make a computer flash a redstone signal for as many times as typed. So i want the computer to sit there not doing anything until some one types any number like 64 then i want the computer to flash a redstone signal 64 times im not sure how to do this can any one help me?
537 posts
Location
Copenhagen, Denmark
Posted 26 January 2013 - 09:46 PM
First of all, this should be in the "Ask a Pro" section.
But here, this would suffice, I believe:
local arg = {...} -- Get CML arguments
arg[1] = arg[1] or 1
for i = 1, tonumber(arg[1]) do
redstone.setOutput("back", true) -- Change "back" to whichever side you prefer
sleep(0.5)
redstone.setOutput("back", false) -- As above
sleep(0.5)
end
That would flash a signal the specified amount of flashes on the back for half a second.
24 posts
Posted 27 January 2013 - 09:42 AM
Ok cool the arg = { … } is a new one to me ill have to read up on it. New to programming if you couldn't tell lol. Thanks!
24 posts
Posted 27 January 2013 - 10:31 AM
Actually is how would i modify that to accept a rednet input for the number?
2088 posts
Location
South Africa
Posted 27 January 2013 - 11:09 AM
id = 5 -- this is the id for the computer that sends the number
repeat senderID, msg = rednet.receive() until senderID = id
for i = 1, tonumber(msg) do
redstone.setOutput("back", true) -- Change "back" to whichever side you prefer
sleep(0.5)
redstone.setOutput("back", false) -- As above
sleep(0.5)
end