Advertisement
Guest User

startup

a guest
Jul 17th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | None | 0 0
  1. function setAutoFarmInfo(farmInfo)
  2.   local infoFile = fs.open("AutoFarmInfo.txt", "w")
  3.  
  4.   infoFile.writeLine(farmInfo["width"])
  5.   infoFile.writeLine(farmInfo["length"])
  6.   infoFile.writeLine(farmInfo["x"])
  7.   infoFile.writeLine(farmInfo["y"])
  8.  
  9.   infoFile.close()
  10. end
  11.  
  12. function getAutoFarmInfo()
  13.   local infoFile = fs.open("AutoFarmInfo.txt", "r")
  14.  
  15.   infoTable = {}
  16.   infoTable["width"] = tonumber(infoFile.readLine())
  17.   infoTable["length"] = tonumber(infoFile.readLine())
  18.   infoTable["x"] = tonumber(infoFile.readLine())
  19.   infoTable["y"] = tonumber(infoFile.readLine())
  20.  
  21.   infoFile.close()
  22.  
  23.   return infoTable
  24. end  
  25.  
  26. if not fs.exists("AutoFarmInfo.txt") then
  27.   local farmInfo = {}
  28.  
  29.   print("AutoFarm Setup")
  30.  
  31.   io.write("Farm width: ")
  32.   farmInfo["width"] = tonumber(read()) - 1
  33.  
  34.   io.write("Farm length: ")
  35.   farmInfo["length"] = tonumber(read()) - 1
  36.  
  37.   farmInfo["x"] = 0
  38.   farmInfo["y"] = 0
  39.  
  40.   setAutoFarmInfo(farmInfo)
  41. end
  42.  
  43.  
  44. farmInfo = getAutoFarmInfo()
  45.  
  46. for currentY = farmInfo["y"],farmInfo["width"],1 do
  47.   farmInfo["y"] = currentY
  48.  
  49.   if farmInfo["x"] == farmInfo["length"] then
  50.     forLoopLengthFix = farmInfo["length"]
  51.     forLoopDirection = -1
  52.   else
  53.     forLoopLengthFix = 0
  54.     forLoopDirection = 1
  55.   end
  56.  
  57.   for currentX = farmInfo["x"],farmInfo["length"]-forLoopLengthFix,forLoopDirection do
  58.     farmInfo["x"] = currentX
  59.     --setAutoFarmInfo(farmInfo)
  60.    
  61.     print(currentX)
  62.   end
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement