ComputerCraftã®ç¡ç·éä¿¡ã使ãããªãã(8)ãâã¤ã³ã¿ã©ã¯ãã£ããªé éæä½ããã°ã©ã
ã¯ããã«
ãã¦ãååã¾ã§ã«ããããã®æ©è½ã¯å®ç¾ã§ãã¾ããããã¾ã ããã¤ãä¸æºãããã¾ãã
ã¾ãä¸ã¤ã¯ããã¼å ¥åã§ã¿ã¼ãã«ãèªå¨ã«åãããã®ã¯è¯ãããã©ããããããç»é²ãã¦ãããï¼ããã°ã©ã ä¸ã®å¤æãã¼ãã«ã«æ¸ãè¾¼ã¿ããï¼å½ä»¤ããå®è¡ã§ãã¾ããã
ã¡ãã£ã¨ä»ã®å½ä»¤ããããã ããªã®ã«ãããããããã°ã©ã ãç·¨éããªãã¦ã¯ãããªãã¨ããã®ã¯ãä¸ä¾¿ã§ãããã
ããã§ãã¡ãã»ã¼ã¸éä¿¡ããã°ã©ã ã次ã®ããã«ä¿®æ£ãã¦ã¿ã¾ããã ã¾ãã¯ã¤ã³ã¹ãã¼ã«ãã¦ãå®éã«ããã°ã©ã ãåããã¦ã¿ã¾ãããã
ã¤ã³ã¹ãã¼ã«ï¼å®è¡
éä¿¡ï¼ã³ã³ãã¥ã¼ã¿ï¼å´
msg_sender5ã®ã¤ã³ã¹ãã¼ã«ã
> pastebin get mV08nRTx msg_sender5
ã¤ã³ã¹ãã¼ã«ããããéä¿¡å IDãå¼æ°ã«ãã¦ãããã¾ã§ã®ããã«å®è¡ãã¦ãã ããã
åä¿¡ï¼ã¿ã¼ãã«ï¼å´
msg_receiver4ã®ã¤ã³ã¹ãã¼ã«ã ååã¨åããªã®ã§ããã§ã«ã¤ã³ã¹ãã¼ã«ãã¦ãããªããã®ã¾ã¾ã§ã
> pastebin get dEtcqCHY msg_receiver4
msg_receiver4ãå®è¡ãã¦ãå¾ ã¡ããç¶æ ã«ããªããçæã¯ãããããè£çµ¦ãã¦ãããã¨ã
ããã°ã©ã å®è¡
éä¿¡ï¼ã³ã³ãã¥ã¼ã¿ï¼å´ã®ç»é¢ã§ãã
- "space"ãã¼ã"leftShif"ãã¼ãªã©ããããããç»é²ãã¦ãããã¼ã¯åé¡ãªãåãã¾ãã
- ããã§ã"enter"ãã¼ãæ¼ãã¦ã¿ã¾ããããã¤ã³ã¿ã©ã¯ãã£ãã¢ã¼ãï¼interactive modeï¼ã«å¤ããã¾ããä¸ç»åã®ããã«ãããã³ããã>ãã表示ããã¾ãã
- 好ããªå½ä»¤ãå
¥åãã¦ã¿ã¾ããããããã§ã¯ã¿ã¼ãã«ã®é¸æã¹ããããå¤æ´ãã
turtle.select()
é¢æ°ãå ¥åãã¦ãã¾ãã - å
¥åå¾ãå度"enter"ãã¼ãæ¼ãã¨ããã®å½ä»¤ã確å®ãã¾ãã確å®ããã以ä¸ã®ç»åã®ããã«ã¤ã³ã¿ã©ã¯ãã£ãã¢ã¼ããçµäºãã¦ã
turtle.select(1)
ã¨ããã¡ãã»ã¼ã¸ãéä¿¡ãããã¨ãããã°ã©ã ããå ±åããã¾ãã - ãªãã"q"ãã¼ãæ¼ããã¨ã§ãããã°ã©ã èªä½ãçµäºãã¾ãã
ãï¼ããã®ã¤ã³ã¿ã©ã¯ãã£ãã¢ã¼ãã£ã¦ãããããã¾ããï¼
ã§ã¯ãã©ã®ããã«ãã¦ãã®æ©è½ãå®ç¾ããããå ·ä½çã«ããã°ã©ã ãè¦ã¦ã¿ã¾ãããã
ã¡ãã»ã¼ã¸éä¿¡ï¼ã³ã³ãã¥ã¼ã¿ï¼å´ããã¼ã¸ã§ã³ï¼ï¼ä¿®æ£ï¼
msg_sender5
å¤æ´ç¹ã¯ãL31-37ã ãã§ãã
- L31ï¼ã"enter"ãã¼ãå ¥åãããï¼å¤æãã¼ãã«ã«"enter"ã«é¢ããè¨è¿°ããªãããã«ï¼å¤æ°messageã®å¤ãnilã§ããã¨ãã«ä»¥ä¸ã®åä½ãè¡ãã¾ãã
- L32,33,35ï¼ããã ã®ç»é¢è¡¨ç¤ºã¡ãã»ã¼ã¸
- L34ï¼ã
io.read()
é¢æ°ã«ãããã¿ã¼ããã«ç»é¢ã§ã®1è¡ã®å ¥åãåãåããå¤æ°messageã«ä»£å ¥ã - L37ï¼ã"q"ãã¼ã®å ¥åããããã¯ã¤ã³ã¿ã©ã¯ãã£ãã¢ã¼ãã§ã"q"ã®å ¥åããã£ãã¨ãã«whileã«ã¼ããæãã¦ããã°ã©ã çµäºã
ãã¤ã³ãã¯ããio.read()
ã§ããã
io.read()
ï¼Lua5.1ãªãã¡ã¬ã³ã¹ããã¥ã¢ã«ããï¼- æ¨æºå ¥åï¼ã¿ã¼ããã«ç»é¢ä¸ã§ã®å ¥åï¼ãã1è¡ã®èªã¿è¾¼ã¿ãè¡ã
- è¿å¤ï¼æååï¼ï¼ãå ¥åããã1è¡ã®æåå
Luaã®I/Oã¢ãã«ã«é¢ãã¦ã¯ãã¾ãæéã®ããã¨ãã«ã§ã詳ãã説æãã¾ãããã
ä»ã®ã¨ããã¯ãio.read()ã ãã§ãã¿ã¼ããã«ç»é¢ä¸ã§ã®1è¡ã®å ¥åãèªã¿è¾¼ã¿ãã¨ãã§ããã¨è¦ãã¦ããã°OKã§ãã
ãããã«
ãã¦ããã¾ã§ããã¨ãå½ä»¤ãéä¿¡ããã¨ãã«ã
- ããããããã®ãããªå½ä»¤ãæå¹ãªã®ãã©ããã
- ãã¨ãã°ãå½ä»¤ããããã©ãã¹ãã«ãã¹ãªã©ã§å½ä»¤æãã®ãã®ãæå¹ã§ã¯ãªãã¨ã
- ããã®å½ä»¤ãå®è¡ãããã¨ãã¦æåãããã©ããã
- ãã¨ãã°ãturtle.up()ãå®è¡ããããã©ãé害ç©ããã£ã¦ä¸ã«ç§»åã§ããªãã£ãã¨ã
ã¨ããåå¿ãæ°ã«ãªãã¨ããã§ãã
å½ä»¤ããã¨ãã«ãå½ä»¤ã®éè¡ã«æåããã®ã失æããã®ããããã¦å¤±æããã®ãªãã©ã®ãããªåå ã§å¤±æããã®ãããããã®ã¨ã©ã¼ãè¿ã£ã¦ããã¨ãããã«ãããããã使ãããããªãã¾ãããã
次åã¯ãã®ããããæ¹é ãã¾ãããã