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

Frames and computercontrol whit redstone off and on function

Started by Recer75, 12 May 2013 - 03:41 AM
Recer75 #1
Posted 12 May 2013 - 05:41 AM
Hi i am new to computercraft and i need some help white the code.
I want to start the machine whit a wireless redstone signal and stop it when its off.
I don't want to have to restart the program every time i stop the signal but i have been unsuccessful in every attempt to make this happen.

The machine is mad of red power and computercraft components from the mudpack ultimate.

This is a scematic of the machine created whit world-edit
http://www.mediafire...6qa66ea96uu0i2m


y = 0
if redstone.getInput ("top",true) then
  y = 0
end
if redstone.getInput ("top",false) then
  y = x + 10
end
repeat
  redstone.setOutput ("back",true)
  sleep (0,8)
  redstone.setOutput ("back",false)
  redstone.setOutput ("right",true)
  sleep (1.0)
  redstone.setOutput ("right",false)
  sleep (1.0)
  redstone.setOutput ("bottom",true)
  sleep (1.0)
  redstone.setOutput ("bottom",false)
until y == 10


I would appreciate any help and tips that can make this work.
Lyqyd #2
Posted 12 May 2013 - 04:57 PM
Split into new topic.
KaoS #3
Posted 12 May 2013 - 06:26 PM

repeat
  redstone.setOutput ("back",true)
  sleep (0,8)
  redstone.setOutput ("back",false)
  redstone.setOutput ("right",true)
  sleep (1.0)
  redstone.setOutput ("right",false)
  sleep (1.0)
  redstone.setOutput ("bottom",true)
  sleep (1.0)
  redstone.setOutput ("bottom",false)
until not redstone.getInput ("top") and x+10==10
Recer75 #4
Posted 13 May 2013 - 01:38 PM
Nice thank you. I wonder how can i make this start when i reapply the rs.getInput ("top") signal
W00dyR #5
Posted 13 May 2013 - 01:54 PM

while true do  -- infinite loop, so you never have to restart
  waiting = os.pullEvent()  -- waits for something to happen, like a redstone update
  if redstone.getInput("top") then
	-- whatever you want to happen here
  end
end

That should work I think :P/>
KaoS #6
Posted 13 May 2013 - 03:45 PM

while true do
  if not redstone.getInput ("top") and x+10==10
    redstone.setOutput ("back",true)
    sleep (0,8)
    redstone.setOutput ("back",false)
    redstone.setOutput ("right",true)
    sleep (1.0)
    redstone.setOutput ("right",false)
    sleep (1.0)
    redstone.setOutput ("bottom",true)
    sleep (1.0)
    redstone.setOutput ("bottom",false)
  end
  os.pullEvent("redstone")
end