Skip to content

Instantly share code, notes, and snippets.

@wolfgangmeyers
Last active August 29, 2015 14:17
Show Gist options
  • Save wolfgangmeyers/2c928af7b30f8b6e4660 to your computer and use it in GitHub Desktop.
Save wolfgangmeyers/2c928af7b30f8b6e4660 to your computer and use it in GitHub Desktop.
Computercraft turtle remote control script
-- remote listener
os.loadAPI("inventory")
os.loadAPI("path")
running = true
-- this should be configurable somehow
modem = peripheral.wrap("right")
modem.open(0)
while running do
local event, modemSide, senderChannel,
replyChannel, message, senderDistance = os.pullEvent("modem_message")
print(message)
print(replyChannel)
if message == "quit" then
running = false
modem.transmit(1, 0, "quit")
elseif message == "ping" then
modem.transmit(1, 0, senderDistance)
else
local success, result = pcall(function() return loadstring(message)() end)
modem.transmit(1, 0, textutils.serialize(result)) -- very secure
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment