Advertisement
Lupino

plant1.lua

Jun 29th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.95 KB | None | 0 0
  1. local robot = require('robot')
  2. local component = require('component')
  3. local craft = require('craft')
  4.  
  5. local dye = 'minecraft:dye'
  6. local bone = 'minecraft:bone'
  7. local boneBlock = 'minecraft:bone_block'
  8. local fruitBone = 'croparia:fruit_bone'
  9. local currentDyeSlot = 2
  10. local currentSeedSlot = 1
  11.  
  12. local seed = craft.getItemName(1)
  13.  
  14. function placeItem(slot)
  15.     print('placeItem', slot)
  16.     local count = robot.count(slot)
  17.  
  18.     robot.select(slot)
  19.     robot.placeDown()
  20.  
  21.     if robot.count(slot) < count then
  22.         return true
  23.     else
  24.         return false
  25.     end
  26. end
  27.  
  28. function placeSeed()
  29.     if craft.isItem(currentSeedSlot, seed) then
  30.         return placeItem(currentSeedSlot)
  31.     end
  32.     local slot = craft.findItem(seed, 1)
  33.     if slot == 0 then
  34.         return false
  35.     end
  36.     currentSeedSlot = slot
  37.     return placeSeed()
  38. end
  39.  
  40. function placeDye()
  41.     if craft.isItem(currentDyeSlot, dye) then
  42.         if placeItem(currentDyeSlot) then
  43.             return 1
  44.         else
  45.             return 0
  46.         end
  47.     end
  48.     local slot = craft.findItem(dye, 1)
  49.     if slot == 0 then
  50.         return 2
  51.     end
  52.     currentDyeSlot = slot
  53.     return placeDye()
  54. end
  55.  
  56. function runPlaceDye()
  57.     local ret = placeDye()
  58.     if ret == 2 then
  59.         craft.mergeItems()
  60.         if not craft.crafting1(boneBlock) then
  61.             if not craft.crafting1(bone) then
  62.                 if not craft.crafting1(fruitBone) then
  63.                     return false
  64.                 end
  65.             end
  66.         end
  67.     elseif ret == 0 then
  68.         return true
  69.     end
  70.     return runPlaceDye()
  71. end
  72.  
  73. function main()
  74.     robot.swingDown()
  75.     local running = true
  76.     if seed == '' then
  77.         print('Error: seed not found.')
  78.         return
  79.     end
  80.     while running do
  81.         if not placeSeed() then
  82.             break
  83.         end
  84.         if not runPlaceDye() then
  85.             break
  86.         end
  87.         robot.swingDown()
  88.     end
  89. end
  90.  
  91. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement