Bonkie

Computercraft Turtle Send File or Command

Apr 5th, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. args = {...}
  2. local m = peripheral.wrap("right")
  3. if (#args ~= 0) then
  4.   if (args[1] == "file") then
  5.     print("Bestand verzenden op kanaal 99")
  6.     print("Naam: ".. args[2])
  7.     f = fs.open(args[2],"r")
  8.     m.transmit(99,99,"file|".. args[2] .."|".. f.readAll())
  9.     print("Bestand verstuurd")
  10.   elseif (args[1] == "shell") then
  11.     print("Shell commando verzenden op kanaal 99")
  12.     print("Commando: ".. args[2])
  13.     if (args[3]~=nil) then
  14.       print("Arguments: ".. args[3])
  15.       m.transmit(99,99,"shell|".. args[2] .."|".. args[3])
  16.     else
  17.       m.transmit(99,99,"shell|".. args[2])
  18.     end
  19.     print("Commando verstuurd")
  20.   end
  21. else
  22.   print("gebruik: send99 [actie] [naam] <argument>")
  23.   print("actie = file OF shell")
  24.   print("naam = file om te verzenden OF shell commando om uit te voeren (zoals een verzonden file)")
  25.   print("argument = optioneel bij het versturen van een shell commando om 1 variabel mee te geven.")
  26. end
Advertisement
Add Comment
Please, Sign In to add comment