Himeki

Craft rsPulse

Jul 9th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. local tArgs = { ... }
  2.  
  3. --variables
  4. local strSide = "bottom"
  5. local intCount = 0
  6. local fPulseLength = 0.1
  7.  
  8. --predeclare
  9. local printUsage
  10. local rsPulse
  11. local clear
  12.  
  13. --functions--
  14. function rsPulse(length)
  15.     if length < 0.1 then
  16.         print("Error: Pulse length must be 0.1 or greater")
  17.         error()
  18.     else
  19.         redstone.setOutput(strSide, true)
  20.         sleep(length)
  21.         redstone.setOutput(strSide, false)
  22.         sleep(length)
  23.     end
  24. end
  25.  
  26. function clear()
  27.     term.clear()
  28.     term.setCursorPos(1,1)
  29. end
  30.  
  31. function printUsage()
  32.     print( "Usage: craft <# crafted>" )
  33.     return
  34. end
  35.  
  36. local intCount = tonumber(tArgs[1])
  37.  
  38. --start--
  39. if #tArgs ~= 1 then
  40.     printUsage()
  41.     return
  42. elseif intCount > 0 then
  43.     while intCount > 0 do
  44.         rsPulse(fPulseLength)
  45.         intCount = intCount - 1
  46.         clear()
  47.         print("Crafting: "..intCount.." remaining.")
  48.     end
  49.     print("Crafting Complete.")
  50.     return
  51. else
  52.     print("Error.")
  53.     printUsage()
  54. end
Add Comment
Please, Sign In to add comment