Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[required materials
- scan inventory for
- #dirt
- #water
- #hoe
- #ingredients
- ]]--
- local dirt = {}
- local farm = {}
- farm.__index = farm
- setmetatable(farm, {
- __call = function(cls,...)
- local self = setmetatable({},cls)
- self:_init({...})
- return self
- end
- })
- function farm:_init(init)
- --if init == "clear" then
- self.inventory = {}
- self.plants = {}
- --end
- end
- function farm:scanInventory()
- for i=1,16 do
- turtle.select(i)
- local temp = turtle.getItemDetail()
- if temp then
- local s,_ = temp.name:find(":")
- self.inventory[i] = temp.name:sub( s + 1)
- end
- if temp.name:find("seed") then
- self.plants:insert(temp.name)
- end
- end
- end
- function farm:dirt()
- for i,v in ipairs(self.inventory) do
- if v == "dirt" then
- dirt:insert(i)
- end
- end
- for _,v in ipairs(dirt) do
- if v then
- return v
- break
- end
- end
- end
- function farm:place(item)
- turtle.select(item)
- turtle.placeDown()
- end
- function createFarm(plants)
- function farm:farmWater()
- for i=1,3 do
- turtle.up()
- end
- self:place(dirt)
- shell.run("go up fd rt")
- for i=1,4 do
- self:place(dirt)
- shell.run("go fd rt fd")
- end
- shell.run("rt fd")
- self:place(water)
- end
- function farm:createTiles()
- for i=1,#self.plants do
- turtle.forward()
- for i=1,something do
- turtle.forward()
- self:place(dirt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement