Created
April 26, 2016 18:59
-
-
Save teodorlu/a7f0f97480311ad05c597cb6cfbdd5f7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-- Kjør på turtle | |
function main() | |
-- Hva sier pheripherals? Hvilken side er modemet på? | |
rednet.open("left") | |
while true do | |
sender, message = rednet.receive(99999) | |
print("Message from " .. sender .. " received: ") | |
print(message) | |
shell.run(unpack(message)) | |
end | |
end | |
main() |
This file contains hidden or 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
-- File! | |
remoteId = 5 | |
function toMoveCommand(keycode) | |
if keycode == keys.w then | |
return {"go", "forward"} | |
else | |
return nil | |
end | |
end | |
function remoteMove() | |
local action, keycode = os.pullEvent('key') | |
command = toMoveCommand(keycode) | |
if command == nil then | |
print("Unknown key: " .. keycode) | |
else | |
print("Sending ".. unpack(command)) | |
rednet.send(remoteId, command) | |
end | |
end | |
function main( ) | |
print("Listening for move commands ...") | |
rednet.open("back") | |
while true do | |
remoteMove() | |
end | |
end | |
main() |
This file contains hidden or 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
-- Starter jeg programmet sånn: | |
-- > ssh.lua 5 | |
arguments = ... | |
-- ... blir arguments = "5" | |
remoteId = tonumber(arguments) | |
-- ... og remoteId = 5! | |
function pack(...) | |
return arg | |
end | |
function remoteCommand() | |
io.write("ssh@" .. remoteId .. "> ") | |
local intputString = io.read() | |
local commandTable = pack(intputString) | |
print("Sending: ") | |
print(unpack(commandTable)) | |
rednet.send(remoteId, commandTable) | |
end | |
function main( ) | |
print("Listening for move commands ...") | |
rednet.open("back") | |
while true do | |
remoteCommand() | |
end | |
end | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment