Advertisement
nauseant

S.T.U.P.I.D.

May 3rd, 2024 (edited)
1,009
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.98 KB | None | 0 0
  1. function updateProgram(pastebinCode, programFile, isLua)
  2.     local response = http.get("https://pastebin.com/raw/" .. pastebinCode)
  3.     if isLua == "lua" then
  4.         programFile = programFile .. ".lua"
  5.     end
  6.     if response then
  7.       local programCode = response.readAll()
  8.       response.close()
  9.       local file = fs.open(programFile, "w")
  10.       file.write(programCode)
  11.       file.close()
  12.       print("Program updated successfully!")
  13.     else
  14.       print("Failed to update program.")
  15.     end
  16.   end
  17.  
  18.   -- Main program
  19.   local args = {...}
  20.   local isLua = args[3]
  21.   local programToUpdate = args[1]
  22.   local pastebinCode = args[2]
  23.  
  24.   print("Note: to update a program ending in .lua please add the extra argument 'lua' when using this program")
  25.   print("otherwise there will be a new program NOT ending in .lua")
  26.   print("Example: update example.lua AbCd1234 lua")
  27.   print("Updating " .. programToUpdate .. "...")
  28.  
  29.   updateProgram(pastebinCode, programToUpdate, isLua)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement