Advertisement
FNCxPro

TurtleAPI

May 30th, 2015
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. --[[
  2. *
  3. * TurtleAPI :: For bypassing blocked methods
  4. * Found method by /u/BOOMBOOMTHEHACKER
  5. * THANKS!
  6. *
  7. ]]--
  8. if not turtle then
  9. error( "Cannot load turtle API on computer", 2 )
  10. end
  11. native = turtle.native or turtle
  12.  
  13. local function addCraftMethod( object )
  14. if peripheral.getType( "left" ) == "workbench" then
  15. object.craft = function( ... )
  16. return peripheral.call( "left", "craft", ... )
  17. end
  18. elseif peripheral.getType( "right" ) == "workbench" then
  19. object.craft = function( ... )
  20. return peripheral.call( "right", "craft", ... )
  21. end
  22. else
  23. object.craft = nil
  24. end
  25. end
  26.  
  27. -- Put commands into environment table
  28. local env = _ENV
  29. for k,v in pairs( native ) do
  30. if k == "equipLeft" or k == "equipRight" then
  31. env[k] = function( ... )
  32. local result, err = v( ... )
  33. addCraftMethod( turtle )
  34. return result, err
  35. end
  36. else
  37. env[k] = v
  38. end
  39. end
  40. addCraftMethod( env )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement