Advertisement
IMarvinTPA

Transposer

Jan 30th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.56 KB | None | 0 0
  1. --pastebin get UyVNUFKU startup
  2. --pastebin get UyVNUFKU transposer
  3.  
  4. --shell.run("transposer f b")
  5. --shell.run("transposer t b")
  6. --shell.run("transposer t rf")
  7.  
  8. local tArgs = { ... }
  9. local sInput, sOutput, nDelay = tArgs[1], tArgs[2], tArgs[3]
  10. local nSlots = tArgs[4]
  11. local filename = shell.getRunningProgram()
  12.  
  13. if not trans then
  14.     os.loadAPI("trans")
  15.     if not trans then
  16.         shell.run("pastebin get 68xNzDAV trans")
  17.         os.loadAPI("trans")
  18.         if not trans then
  19.             error("Unable to load 'trans' API")
  20.         end
  21.     end
  22. end
  23.  
  24. sInput = trans.fixSide(sInput)
  25. sOutput = trans.fixSide(sOutput)
  26.  
  27. if sInput == nil or sOutput == nil then
  28.     print( "Usage: " .. filename .. " <input side> <output side> [Delay Time]" )
  29.     print( "Side values are Top, Bottom, Front, and None" )
  30.     print( "The turtle will pull from the input side and push into the output side." )
  31.     print( "None can be specified if the turtle is expected to deal with items moving on their own." )
  32.     print( "Slots: Maximum number of stacks to pull at one time.")
  33.     return
  34. end
  35.  
  36. if nDelay ~= nil then
  37.     nDelay = tonumber(nDelay)
  38. end
  39.  
  40. if nDelay == nil then
  41.     nDelay = 0.5
  42. end
  43.  
  44. if nSlots ~= nil then
  45.     nSlots = tonumber(nSlots)
  46. end
  47.  
  48. if nSlots == nil then
  49.     nSlots = 15
  50. end
  51.  
  52. if nSlots < 1 or nSlots > 16 then
  53.     nSlots = 15
  54. end
  55.  
  56. print( "Transposing from " .. trans.displaySide(sInput) .. " to " .. trans.displaySide(sOutput) .. " with a delay of " .. nDelay .. " seconds and loading up to " .. nSlots .. " slots." )
  57.  
  58.  
  59. while true do
  60.     trans.load(sInput, 1, nSlots)
  61.     trans.unload(sOutput, "n")
  62.     sleep(nDelay)
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement