Tjakka5

AdvancedMine

Jul 3rd, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. local function downloadUpdate(pasteURL)
  2.    fs.delete("startup.bak")
  3.    fs.copy("startup", "startup.bak")
  4.    fs.delete("startup")
  5.  
  6.    shell.run("pastebin", "get", pasteURL, "startup")
  7.    os.reboot()
  8. end
  9.  
  10. local _command, _args
  11. local function receiveCommmand()
  12.    local _, data = rednet.receive()
  13.    data = textutils.unserialize(data)
  14.  
  15.    _command = data[1]
  16.    
  17.    table.remove(data[1], 1)
  18.    _args = data
  19. end
  20.  
  21. local function runCommand(command, args)
  22.    if command == "update" then
  23.       print("Updating!")
  24.       downloadUpdate(args[1] or "ZSpt1WQH")
  25.    end
  26. end
  27.  
  28. local function run()
  29.  
  30. end
  31.  
  32. rednet.open("right")
  33.  
  34. while true do
  35.    parallel.waitForAny(run, receiveCommmand)
  36.  
  37.    if _command then
  38.       runCommand(_command, _args)
  39.      
  40.       _command = nil
  41.       _args = nil
  42.    end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment