JustDoesGames

Pumpkin Farm

Oct 18th, 2023 (edited)
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. if not fs.exists("/cfg.lua") then local f = fs.open("cfg.lua", "w") f.close() end
  2. local f = fs.open("cfg.lua","r")
  3. if f then t = textutils.unserialize(f.readAll()) f.close() end
  4.  
  5. if not t then t = {} end
  6. if not t.mined then t.mined = 0 end
  7.  
  8. term.clear()
  9. while true do
  10.     term.setCursorPos(1,1)
  11.     print("Pumpkins Harvested: "..t.mined)
  12.  
  13.     local r,i = turtle.inspect()
  14.     if r then
  15.         if i.name == "minecraft:pumpkin" then
  16.             turtle.dig()
  17.             t.mined = t.mined + 1
  18.            
  19.             local f = fs.open("cfg.lua", "w")
  20.             f.write(textutils.serialize(t)) f.close()
  21.  
  22.             turtle.dropDown()
  23.         end
  24.     end
  25.     turtle.turnRight()
  26.     sleep(.2)
  27. end
  28.  
  29.  
Advertisement
Add Comment
Please, Sign In to add comment