Last active
August 29, 2015 14:17
-
-
Save wolfgangmeyers/2c928af7b30f8b6e4660 to your computer and use it in GitHub Desktop.
Computercraft turtle remote control script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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