Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local side = "left"
- local funcState = {}
- funcState.step = 0
- funcState.func = runLeft
- local rsDelay = 0.1
- function funcDo()
- print("CALL")
- local res = funcState.func()
- print("CALL")
- if res == "#END" then
- end
- delay(rsDelay)
- end
- local funcCo = coroutine.create(funcDo)
- local colMap = {
- headSliderBreaker = { color = colors.magenta, delay = 2 },
- headSliderLeft = { color = colors.orange, delay = 5 }
- }
- function redclear()
- rs.setBundledOutput(side,0)
- end
- function redset(color)
- rs.setBundledOutput(side,color)
- end
- function redadd(color)
- --print("add " .. color )
- local nCol = colors.combine( rs.getBundledOutput( side ), color )
- rs.setBundledOutput(side,nCol)
- end
- function reddel(color)
- --print("sub " .. color )
- local nCol = colors.subtract( rs.getBundledOutput( side ), color )
- rs.setBundledOutput(side,nCol)
- end
- function redtest(color)
- return colors.test( rs.getBundledInput( side ), color )
- end
- function delay(delayt)
- funcState.timer = os.startTimer( delayt )
- coroutine.yield()
- end
- function redpulse(opts)
- redadd(opts.color)
- delay( opts.delay )
- reddel(opts.color)
- delay(rsDelay)
- end
- function mineHeadLeft()
- print("left")
- redpulse(colMap.headSliderBreaker)
- redpulse(colMap.headSliderLeft)
- print("leftEnd")
- end
- redclear()
- function runLeft()
- print("tt")
- while not redtest(colors.white) do
- mineHeadLeft()
- end
- return "#END"
- end
- funcState.func = runLeft
- function timerCallback(ev,p1)
- if p1 == funcState.timer then
- funcState.timer = nil
- print("resuming")
- coroutine.resume(funcCo)
- if funcState.func() == "#END" then
- funcEnd()
- end
- end
- end
- events.registerEvent("timer",timerCallback)
- coroutine.resume(funcCo)
- while true do
- coroutine.yield()
- end
Advertisement
Add Comment
Please, Sign In to add comment