Advertisement
BruceWplays

Farm Launcher V3

Sep 11th, 2022 (edited)
714
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local update_name = "updateV5"
  2.  
  3.  
  4.  
  5. local gui_url = "0UkEdCjY"
  6. local farm_url = "ZW6q8wWs"
  7. local goto_url = "a3GBewNp"
  8. if fs.exists("AndysPrograms/api"..update_name) == false then
  9.     fs.makeDir("AndysPrograms/api")
  10.     shell.run("cd","AndysPrograms/api")
  11.     shell.run("pastebin","get","uBa2UnVT",update_name)
  12.     shell.run("cd","..")
  13.     shell.run("cd","..")
  14. end
  15. shell.run("AndysPrograms/api/"..update_name, "gui", gui_url, "AndysPrograms/api/gui", "none", "none")
  16. if fs.exists("AndysPrograms/api/pastebin_silent/ps") == false then
  17.     fs.makeDir("AndysPrograms/api/pastebin_silent")
  18.     shell.run("cd","AndysPrograms/api/pastebin_silent")
  19.     shell.run("pastebin","get","Zp2CC5qM","ps")
  20.     shell.run("cd","..")
  21.     shell.run("cd","..")
  22.     shell.run("cd","..")
  23. end
  24.  
  25. launcherargs = {...}
  26. local farm_prog_progress = "init"
  27. while loadedguilib ~= 1 do
  28.     if os.loadAPI("AndysPrograms/api/gui/gui") then
  29.         --print("loaded gui lib")
  30.         loadedguilib = 1
  31.     else
  32.         print(" NOTloaded gui lib")
  33.     end
  34. end
  35.  
  36. function get_running()
  37.     return andy_farm_program_running
  38. end
  39. function set_running(n)
  40.     andy_farm_program_running = n
  41. end
  42.  
  43.  
  44. fudargs = "sleep(5)\nshell.run(\"farm\", \"noset\")"
  45. --print (fudargs)
  46. --sleep (5)
  47. farmlauncherloop = 1
  48. stopfarm = 0
  49. errhnd = 0
  50. function call_farm()
  51.     farm.startfarm(launcherargs)
  52. end
  53. function running_check()
  54.     while _G.andy_farm_program_running == 1 do
  55.         sleep(0.03)
  56.     end
  57. end
  58. function para_farm()
  59.     parallel.waitForAny(call_farm,running_check)
  60. end
  61.  
  62. function errhndlr(err)
  63.     if err == "Terminated" then
  64.         stopfarm = 1
  65.     else
  66.         local dot = 0
  67.         -- term.setCursorPos(1, 1)
  68.         -- term.clear()
  69.         -- print("Error, Retrying"..dot)
  70.         -- term.setCursorPos(1, 3)
  71.         -- print( "Error:",err)
  72.         -- term.setCursorPos(1, 4)
  73.         -- errhnd = 1
  74.         --sleep(2 / 3)
  75.         sleep(0)
  76.     end
  77. end
  78.  
  79.  
  80. local function ud()
  81.     shell.run("AndysPrograms/api/"..update_name, "gt", goto_url, "AndysPrograms/api", "none", "none")
  82.     shell.run("AndysPrograms/api/"..update_name, "farm", farm_url, "AndysPrograms/farm", "none", "no", unpack(launcherargs))
  83. end
  84. ud()
  85.  
  86.  
  87.  
  88. function update_start_farm()
  89.     loadedguilib = 0
  90.     while loadedguilib ~= 1 do
  91.         if os.loadAPI("AndysPrograms/api/gui/gui") then
  92.             --print("loaded gui lib")
  93.             loadedguilib = 1
  94.         else
  95.             print(" NOTloaded gui lib")
  96.         end
  97.     end
  98.     farm_prog_progress = "not not even start"
  99.     print(farm_prog_progress)
  100.     while stopfarm == 0 do
  101.         if _G.andy_farm_program_running == 0 then
  102.             sleep(0)
  103.             farm_prog_progress = "not even start"
  104.             --print(farm_prog_progress)
  105.             --print(get_running())
  106.             -- while _G.init_gui ~= 1 do
  107.                
  108.             --     sleep(0.1)
  109.             -- end
  110.         end
  111.         while _G.andy_farm_program_running == 1 do
  112.             farm_prog_progress = "little even start"
  113.             --print(farm_prog_progress)
  114.             if stopfarm == 0 then
  115.                 farm_prog_progress = "little more start"
  116.                 --print(farm_prog_progress)
  117.                 local stu = fs.open("startup.lua", "w")
  118.                 stu.write(fudargs)
  119.                 stu.close()
  120.                 if errhnd == 0 then
  121.  
  122.                 end
  123.                 os.loadAPI("AndysPrograms/farm/farm")
  124.                 if farmlauncherloop > 1 then
  125.                     launcherargs = {"noset"}
  126.                 end
  127.                
  128.                 if xpcall(para_farm,errhndlr) then
  129.                     ud()
  130.                 else
  131.                     -- sleep(2)
  132.                     sleep(0)
  133.                     errhnd = 0
  134.                     ud()
  135.                 end
  136.  
  137.                
  138.                 if errhnd ~= 0 then
  139.                     sleep(0)
  140.                     errhnd = 0
  141.                 end
  142.                 sleep(0)
  143.                 if farmlauncherloop < 10000 then
  144.                     farmlauncherloop = farmlauncherloop + 1
  145.                 end
  146.             else
  147.                 break
  148.             end
  149.         end
  150.     end
  151. end
  152.  
  153.  
  154.  
  155. local function farm_gui_lau()
  156.     gui.start_farm_gui(launcherargs)
  157. end
  158.  
  159. local function start_farm_lau()
  160.     farm_prog_progress = "not not not(3) even start"
  161.     --print(farm_prog_progress)
  162.     update_start_farm()
  163. end
  164. local function start_para_lau()
  165.     farm_prog_progress = "not not not not(4) even start"
  166.     --print(farm_prog_progress)
  167.     parallel.waitForAny(farm_gui_lau, start_farm_lau)
  168. end
  169.  
  170.  
  171. while stopfarm == 0 do
  172.     --update_start_farm()
  173.     _G.andy_farm_program_running = 0
  174.     if launcherargs[1] == "noset" then
  175.         _G.andy_farm_program_running = 1
  176.     end
  177.  
  178.  
  179.     start_para_lau()
  180.     stopfarm = 1
  181.     --parallel.waitForAny(farm_gui_lau, start_farm_lau)
  182. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement