Advertisement
Quant

Send

Jan 15th, 2016
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1. _G.side=5 --лево
  2. _G.delay=0.05
  3. _G.Qdebug=nil
  4. r=require('component').redstone
  5. arg={...}
  6. function wiew(n)
  7.  return Qdebug and print(n)
  8. end
  9.  
  10. function sendNum(n)
  11.  n=tostring(n)
  12.  wiew(n)
  13.  for i=1,n:len() do
  14.   pulse(tonumber(n:sub(i,i))+1)
  15.  end
  16. end
  17.  
  18. function pulse(n)
  19.  r.setOutput(side,n)
  20.  os.sleep(delay)
  21.  r.setOutput(side,0)
  22. end
  23.  
  24. if arg[1] then
  25.  local f=io.open(arg[1])
  26.  local l=f:lines()
  27.  for c in l do
  28.   for i=1,c:len() do
  29.    local char=c:sub(i,i)
  30.    sendNum(string.byte(char))
  31.    pulse(12)
  32.   end
  33.  end
  34. f:close()
  35. else
  36. print([[Использование:send <Имя файла>]])
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement