mirror of
https://github.com/damp11113-software/ccIDE.git
synced 2025-06-16 13:16:55 +00:00
update code for turtle
This commit is contained in:
parent
770efd438f
commit
2f3a37e5e4
32
turtleremote.lua
Normal file
32
turtleremote.lua
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
local ws = assert(http.websocket("ws://127.0.0.1:5133"))
|
||||||
|
print("connected to server")
|
||||||
|
|
||||||
|
local id
|
||||||
|
|
||||||
|
while true do
|
||||||
|
print("ready")
|
||||||
|
local message, error = ws.receive()
|
||||||
|
if message then
|
||||||
|
print("Received message:", message)
|
||||||
|
if message == "ping" then
|
||||||
|
ws.send("pong")
|
||||||
|
elseif message == "sendcode" then
|
||||||
|
local file = io.open("main.lua", "w")
|
||||||
|
print("waiting for code")
|
||||||
|
local filedata, error = ws.receive()
|
||||||
|
file:write(filedata)
|
||||||
|
file:close()
|
||||||
|
elseif message == "runcode" then
|
||||||
|
shell.run("main")
|
||||||
|
elseif message == "exit" then
|
||||||
|
print("Exiting...")
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
print("WebSocket error:", error)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ws.close()
|
Loading…
x
Reference in New Issue
Block a user