Advertisement
samuelask

Kino Uploader

Mar 8th, 2025
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. -- Kino Script Uploader
  2. local component = require("component")
  3. local event = require("event")
  4. local modem = component.modem
  5.  
  6. local file = io.open("kino.lua", "r")  -- Kino script file
  7. if not file then
  8.     print("Error: kino.lua not found.")
  9.     return
  10. end
  11.  
  12. local kino_code = file:read("*all")
  13. file:close()
  14.  
  15. modem.open(123)  -- Open channel
  16. modem.broadcast(123, "upload")
  17.  
  18. -- Send the Kino script in chunks
  19. for i = 1, #kino_code, 256 do
  20.     modem.broadcast(123, kino_code:sub(i, i + 255))
  21.     os.sleep(0.1)
  22. end
  23.  
  24. modem.broadcast(123, "end")  -- End transmission
  25. print("Kino script uploaded. Awaiting confirmation...")
  26.  
  27. -- Listen for confirmation
  28. local function receive(_, _, sender, _, _, message)
  29.     if message == "kino_update_success" then
  30.         print("Kino successfully updated and running!")
  31.         return true
  32.     elseif message == "kino_update_error" then
  33.         print("Error: Kino failed to execute script!")
  34.         return true
  35.     end
  36. end
  37.  
  38. local timeout = 10
  39. local start_time = os.time()
  40. while os.time() - start_time < timeout do
  41.     local _, _, sender, _, _, message = event.pull(2, "modem_message")
  42.     if message then
  43.         if receive(nil, nil, sender, nil, nil, message) then
  44.             break
  45.         end
  46.     end
  47. end
  48.  
  49. print("Upload process finished.")
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement