Flaghacker

waitForGolem

Jun 2nd, 2014
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1. local function waitForGolem(rsSide, lenght)
  2.     local sleeping = true
  3.     while sleeping do
  4.         --waiting for redstone on
  5.         local waiting = true
  6.         while waiting do
  7.             if rs.getInput(rsSide) then
  8.                 waiting = false
  9.             else
  10.                 os.pullEvent("redstone")
  11.             end
  12.         end
  13.         --waiting for timer or redstone off
  14.         local waiting = true
  15.         local id = os.startTimer(lenght)
  16.         while waiting do
  17.             local event, param = os.pullEvent()
  18.             if event == "timer" and param == id then
  19.                 waiting = false
  20.                 sleeping = false
  21.             elseif event == "redstone" and not rs.getInput(rsSide) then
  22.                 waiting = false
  23.             end
  24.         end
  25.     end
  26. end
Advertisement
Add Comment
Please, Sign In to add comment