daily pastebin goal
41%
SHARE
TWEET

CC: rc_send1

hevohevo May 2nd, 2016 (edited) 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- rc_send1
  2. -- タートルをラジコンにするプログラム(リモコン側)
  3.  
  4. -- Config
  5. local id = 65535  -- 送信先ID
  6.  
  7. -- Functions
  8. function init()
  9.   term.clear()
  10.   term.setCursorPos(1,1)
  11.   print("  w  ")
  12.   print("a   d")
  13.   print("  s  ")
  14. end
  15.  
  16. -- Condition Table
  17. local cond = {}
  18. cond["w"] = "go_forward"
  19. cond["a"] = "strafe_left"
  20. cond["d"] = "strafe_right"
  21. cond["s"] = "go_back"
  22.  
  23. -- Main
  24. rednet.open("back")  -- ポケットコンピュータは後ろ側にモデムがある
  25.  
  26. while true do
  27.   init()
  28.   local event, moji = os.pullEvent("char")
  29.   print(moji)
  30.  
  31.   if cond[moji] then  -- もし送信メッセージを取り出すことができたら、
  32.     rednet.send(id, cond[moji])
  33.   else  -- そうでなければ、
  34.     print("wrong moji")
  35.   end
  36.  
  37.   os.sleep(2)
  38. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top