This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
TheKief's profile picture

Loop programming: I am lost. (Tekkit v1.2.5)

Started by TheKief, 31 August 2017 - 10:41 PM
TheKief #1
Posted 01 September 2017 - 12:41 AM
So me and my buds just got into Tekkit again and I only just found out about the beauty that is computercraft. Been looking at guides all over the place, youtube, off-site (https://www.tutorialspoint.com/lua/lua_loops.htm), the original wiki.

Overall I'd just like to be able to code time-able loops, or atleast have a way to put a delay on my commands. (sleep(?))
This is what I've got so far but it just keeps returning the same error, I've tried pretty much every variant I can think off.

a = 1
while a = 0 do
redpulse left 1 5
sleep(3)
end

I'd love for it to go back to the beginning and execute the redpulse command again. Planning to use this method to keep a truckload of redstone engines on 24/7. Overall any guidance on things I need to watch out for is greatly appreciated. I see programming as my one and only hobby and this has been making me pull my hair out, all I can think off is that you can't put the redpulse command in a program?
Dave-ee Jones #2
Posted 01 September 2017 - 05:02 AM
Redpulse doesn't exist. To emit redstone you use

rs.setOutput(side,true) -- side replaced with a string of the side ("left","right","top" etc.)

Try something like this:

local a = 1
while a == 1 do -- If a == 1 then do this until it is not
  rs.setOutput("left",true) -- Makes the left side of the computer emit redstone
  sleep(1) -- Waits 1 second
  rs.setOutput("left",false) -- Makes the left side stop emitting a redstone signal
  sleep(3) -- Waits 3 second
end
Edited on 01 September 2017 - 03:02 AM
Bomb Bloke #3
Posted 01 September 2017 - 05:47 AM
Redpulse doesn't exist.

It's a command line tool available in ComputerCraft builds prior to 1.6. Technically TheKief could shell.run() it, though it's obviously better to call rs.setOutput() instead.