JustJurt

wcon-standalone

Feb 23rd, 2025
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. function Write_File(path, data)
  2.     fs.delete(path)
  3.  
  4.     local file = fs.open(path, "w")
  5.  
  6.     if file then
  7.         file.write(data) -- Write content to the file
  8.         file.close() -- Close the file
  9.         -- print("File created")
  10.     else
  11.         print("File failed to create")
  12.     end
  13. end
  14.  
  15. function Github_Download(path, githubPath)
  16.     local url = "https://raw.githubusercontent.com/Jerry-Todd/Computer-Craft-Scripts/main/"
  17.     local cacheBuster = os.epoch("utc") -- Get the current timestamp
  18.     local file = http.get(url .. githubPath .. "?t=" .. cacheBuster)
  19.     if file then
  20.         file = file.readAll()
  21.         -- print("Github / Got file: " .. githubPath)
  22.         Write_File(path, file)
  23.         print(" - " .. path)
  24.     else
  25.         print("Github / Cant get file: " .. githubPath)
  26.     end
  27. end
  28.  
  29. term.clear()
  30. term.setCursorPos(1, 1)
  31.  
  32. fs.delete("wcon")
  33.  
  34. -- wcon
  35. Github_Download("wcon/client.lua", "scripts/wcon/wcon-client.lua")
  36. Github_Download("wcon/remote.lua", "scripts/wcon/wcon-remote.lua")
  37.  
  38. term.clear()
  39. term.setCursorPos(1, 1)
  40.  
  41. print("Download complete.")
  42.  
Advertisement
Add Comment
Please, Sign In to add comment