slylycan

build_waterwheel

Jun 3rd, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.28 KB | None | 0 0
  1. FuelLevel = turtle.getFuelLevel()
  2. FuelSlot = 1
  3.  
  4. --Clear the terminal for start of execution
  5. term.clear()
  6. print("Starting 'build_waterwheel' Press any key to continue...")
  7. os.pullEvent("key")
  8. term.clear()
  9.  
  10. --Check that fuel is at least the limit
  11. function fuelMaint(limit)
  12.   print("Checking to see if fuel level is at least " .. limit)
  13.   turtle.select(FuelSlot)
  14.   print("Switching to the fuel slot...")
  15.   if FuelLevel < limit then
  16.     while( FuelLevel < limit ) do
  17.       print("Current fuel level is " .. FuelLevel)
  18.       print("Refueling with " .. turtle.getItemDetail().name)
  19.       turtle.refuel(1)
  20.     end
  21.     print("Refueled to a fuel level of " .. FuelLevel)
  22.   else
  23.     print("Fuel Level check passed!")
  24.   end
  25.   print("Press any key to continue...")
  26.   os.pullEvent("key")
  27.   term.clear()
  28. end
  29.  
  30. --select inventory slot based on item name and metadata
  31. function selectSpecific(itemName, metaData)
  32.   --Begin search at slot 1
  33.   print("Beginning search for " .. itemName .. " with metadata of " .. metaData .. " at inventory slot 1")
  34.   turtle.select(1)
  35.   for i=1,16,1 do
  36.     if turtle.getItemCount(i) > 0 then
  37.       print("Slot " .. i .. " contains " .. turtle.getItemDetail(i).name .. " with metadata of " .. turtle.getItemDetail(i).damage)
  38.       if turtle.getItemDetail(i).name == itemName and turtle.getItemDetail(i).damage == metaData then
  39.         print("Item was found!")
  40.         turtle.select(i)
  41.         return 1  
  42.       end
  43.     else
  44.       print("There was nothing in slot " .. i)
  45.     end
  46.     if i==16 then
  47.       print(itemName .. " with metadata of " .. metaData .. " could not be found!")
  48.       print("Press any key to end...")
  49.       os.pullEvent("key")
  50.       term.clear()
  51.       return 0
  52.     end
  53.   end
  54. end
  55.  
  56. --place block below
  57. function placeD(itemName, metaData)
  58. print("attempting to place " .. itemName .. " with metadata of " .. metaData .. "...")
  59.   if selectSpecific(itemName,metaData) == 0 then
  60.     print("Item could not be placed")
  61.   else
  62.     turtle.placeDown()
  63.     print("Item was placed.")
  64.   end
  65. end
  66.  
  67. --[[Test calls--]]
  68. --fuelMaint(500)  
  69. --selectSpecific("minecraft:planks", 2)
  70. --[[--]]
  71.  
  72. placeD("minecraft:planks", 2)
  73.  
  74. --End the program and clear the screen
  75. print("End of Program. Press any key to continue...")
  76. os.pullEvent("key")
  77. term.clear()
Add Comment
Please, Sign In to add comment