Advertisement
guitarplayer616

FarmGen

Jun 1st, 2015
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. --[[required materials
  2.     scan inventory for
  3.     #dirt
  4.     #water
  5.     #hoe
  6.     #ingredients
  7. ]]--
  8. local dirt = {}
  9. local farm = {}
  10. farm.__index = farm
  11.  
  12. setmetatable(farm, {
  13.     __call = function(cls,...)
  14.         local self = setmetatable({},cls)
  15.         self:_init({...})
  16.         return self
  17.     end
  18. })
  19.  
  20. function farm:_init(init)
  21.     --if init == "clear" then
  22.         self.inventory = {}
  23.         self.plants = {}
  24.     --end
  25. end
  26.  
  27.  
  28. function farm:scanInventory()
  29.     for i=1,16 do
  30.         turtle.select(i)
  31.         local temp = turtle.getItemDetail()
  32.         if temp then
  33.             local s,_ = temp.name:find(":")
  34.             self.inventory[i] = temp.name:sub( s + 1)
  35.         end
  36.         if temp.name:find("seed") then
  37.             self.plants:insert(temp.name)
  38.         end
  39.     end
  40. end
  41.  
  42. function farm:dirt()
  43.     for i,v in ipairs(self.inventory) do
  44.         if v == "dirt" then
  45.             dirt:insert(i)
  46.         end
  47.     end
  48.     for _,v in ipairs(dirt) do
  49.         if v then
  50.             return v
  51.             break
  52.         end
  53.     end
  54. end
  55.  
  56. function farm:place(item)
  57.     turtle.select(item)
  58.     turtle.placeDown()
  59. end
  60.  
  61. function createFarm(plants)
  62.    
  63.    
  64. function farm:farmWater()
  65.     for i=1,3 do
  66.         turtle.up()
  67.     end
  68.     self:place(dirt)
  69.     shell.run("go up fd rt")
  70.     for i=1,4 do
  71.       self:place(dirt)
  72.       shell.run("go fd rt fd")
  73.     end
  74.     shell.run("rt fd")
  75.     self:place(water)
  76. end
  77.  
  78. function farm:createTiles()
  79.     for i=1,#self.plants do
  80.         turtle.forward()
  81.         for i=1,something do
  82.             turtle.forward()
  83.             self:place(dirt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement