daily pastebin goal
88%
SHARE
TWEET

CC: exercise10_3_send

hevohevo May 21st, 2016 (edited) 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- exercise10_3_send (「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.   print("dig: Space")
  15.   print("place: p")
  16. end
  17.  
  18. -- Condition Table
  19. local cond = {}
  20. cond["w"] = "go_forward"
  21. cond["a"] = "strafe_left"
  22. cond["d"] = "strafe_right"
  23. cond["s"] = "go_back"
  24. cond[" "] = "dig"
  25. cond["p"] = "place"
  26.  
  27. -- Main
  28. rednet.open("back")  -- ポケットコンピュータは後ろ側にモデムがある
  29.  
  30. while true do
  31.   init()
  32.   local event, moji = os.pullEvent("char")
  33.   print(moji)
  34.  
  35.   if cond[moji] then  -- もし送信メッセージを取り出すことができたら、
  36.     rednet.send(id, cond[moji])
  37.   else  -- そうでなければ、
  38.     print("wrong moji")
  39.   end
  40.  
  41.   os.sleep(2)
  42. 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