Knito

digpaste.lua

Apr 11th, 2020
301
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Dig Dense Construction Paste from Building Gadgets
  2. -- pastebin get 27YjaxJh digpaste
  3.  
  4.  
  5. function stringhas( s, pattern )
  6. local found = false
  7.     local anfang, ende = string.find( s, pattern, 1, true )
  8.     if  ( anfang ~= nil ) then
  9.         found = true
  10.     end
  11. return found
  12. end
  13.  
  14.  
  15. function Check( pattern )
  16. local found = false
  17. local detect, what = turtle.inspect()
  18. if detect then
  19.     if stringhas( what.name, pattern ) then
  20.         found = true
  21.     end
  22. end
  23. return found
  24. end
  25.  
  26.  
  27. if os.getComputerLabel() == nil then
  28.   os.setComputerLabel("ConstructionPasteDigger")
  29. end
  30.  
  31. -- copy this program to startup when its not "startup"
  32. -- to make it resistant against chunk reloads (ie return from nether)
  33.  
  34. me = fs.getName( shell.getRunningProgram() )
  35.  
  36. if( me ~=  "startup") then
  37.     print( "Overwriting startup with "..me )
  38.     if( fs.exists("startup") ) then
  39.         fs.delete("startup")
  40.     end
  41.     fs.copy( me, "startup" )
  42. end
  43.  
  44. while true do
  45.  
  46. signal = false
  47.  
  48. -- prevent "Too long without yielding error" by sleeping
  49.  
  50. sleep( 0.5 )
  51.  
  52. if signal == false then signal = rs.getInput("top") end
  53. if signal == false then signal = rs.getInput("front") end
  54. if signal == false then signal = rs.getInput("left") end
  55. if signal == false then signal = rs.getInput("right") end
  56. if signal == false then signal = rs.getInput("back") end
  57. if signal == false then signal = rs.getInput("bottom") end
  58.  
  59.  
  60. if signal == false then
  61.    
  62. if turtle.detect() then
  63.  
  64.     if Check( "construction_block_dense" ) then
  65.  
  66.  
  67.         turtle.dig()
  68.         turtle.dropUp()
  69.        
  70.     end
  71.  
  72. else
  73.  
  74. -- prevent "Too long without yielding error" by sleeping
  75.  
  76.  sleep(0.5)
  77.  
  78. end
  79. end
  80. end
RAW Paste Data