meigrafd

CraftOS: minimal Pastebin updater

Jan 18th, 2026
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. -- update.lua (minimal Pastebin updater)
  2.  
  3. local PASTEBIN_ID = "UVEGG7EK" -- <- deine ID hier
  4. local DEFAULT_FILE = "miner"   -- <- optionaler Default
  5.  
  6. local args = { ... }
  7. local target = args[1] or DEFAULT_FILE
  8.  
  9. if not target or target == "" then
  10.     print("Usage: update <filename>")
  11.     return
  12. end
  13.  
  14. if not http then
  15.     print("HTTP is disabled.")
  16.     return
  17. end
  18.  
  19. local url = "https://pastebin.com/raw/" .. PASTEBIN_ID
  20. local h = http.get(url)
  21. if not h then
  22.     print("Download failed: " .. url)
  23.     return
  24. end
  25.  
  26. local data = h.readAll()
  27. h.close()
  28.  
  29. if not data or data == "" then
  30.     print("Empty response.")
  31.     return
  32. end
  33.  
  34. local f = fs.open(target, "w")
  35. if not f then
  36.     print("Cannot write file: " .. target)
  37.     return
  38. end
  39.  
  40. f.write(data)
  41. f.close()
  42.  
  43. print("Updated: " .. target .. " (Pastebin " .. PASTEBIN_ID .. ")")
  44.  
Advertisement
Add Comment
Please, Sign In to add comment