Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Kino Script Uploader
- local component = require("component")
- local event = require("event")
- local modem = component.modem
- local file = io.open("kino.lua", "r") -- Kino script file
- if not file then
- print("Error: kino.lua not found.")
- return
- end
- local kino_code = file:read("*all")
- file:close()
- modem.open(123) -- Open channel
- modem.broadcast(123, "upload")
- -- Send the Kino script in chunks
- for i = 1, #kino_code, 256 do
- modem.broadcast(123, kino_code:sub(i, i + 255))
- os.sleep(0.1)
- end
- modem.broadcast(123, "end") -- End transmission
- print("Kino script uploaded. Awaiting confirmation...")
- -- Listen for confirmation
- local function receive(_, _, sender, _, _, message)
- if message == "kino_update_success" then
- print("Kino successfully updated and running!")
- return true
- elseif message == "kino_update_error" then
- print("Error: Kino failed to execute script!")
- return true
- end
- end
- local timeout = 10
- local start_time = os.time()
- while os.time() - start_time < timeout do
- local _, _, sender, _, _, message = event.pull(2, "modem_message")
- if message then
- if receive(nil, nil, sender, nil, nil, message) then
- break
- end
- end
- end
- print("Upload process finished.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement