local projectId = 214 print("Fetching install command...") local res = http.get("https://pinestore.cc/api/project/" .. projectId) if not res then error("Unable to install program. Make sure pinestore.cc is whitelisted!") end local raw = res.readAll() res.close() local data = textutils.unserialiseJSON(raw) if not data then error("Something went wrong. Raw data received:\n" .. (raw or "nil")) end if not data.success then error("Error: " .. data.error) end local project = data.project local install_command = project.install_command local run_command = project.run_command local target_file = project.target_file local function logDownload() local res = http.post("https://pinestore.cc/api/log/download", textutils.serialiseJSON({ projectId = projectId, }), {["Content-Type"] = "application/json"}) end local function run(func) local someError = nil local someErrorMessage = nil local oldPcall = _G.pcall _G.pcall = function(func, ...) local success, ret1, ret2, ret3, ret4 = oldPcall(func, ...) if not success and not someError then someError = true someErrorMessage = ret1 end return success, ret1, ret2, ret3, ret4 end func() _G.pcall = oldPcall return not someError, someErrorMessage end print("Starting...") if install_command then local success, err = run(function() shell.run(install_command) end) if not success then print("Error during installation:") print(err) else logDownload() print("Successfully installed! Have fun! :D") if target_file then print("Run " .. target_file .. " to start.") end end elseif run_command then local success, err local finished = false parallel.waitForAll(function() success, err = run(function() shell.run(run_command) end) finished = true end, function() for i = 1, 10 do if finished then break end sleep(1) end if success == nil and err == nil and not finished then logDownload() end end) end