ComputerCraftã®ç¡ç·éä¿¡ã使ãããªãã(1)ãï¼ç¡ç·éä¿¡ã·ã¹ãã ã®æ¦è¦
ã¯ããã«
ãããããComputerCraft(以ä¸ãCC)ã®ç¡ç·éä¿¡ã«ã¤ãã¦ãã¥ã¼ããªã¢ã«ãã¯ããã¾ãã
CCã®ç¡ç·éä¿¡ã·ã¹ãã ã®æ¦è¦ã¨ãRednet APIã®å ·ä½çãªä½¿ãæ¹ã«ã¤ãã¦ããµã³ãã«ã¨ãªãã³ã¼ãã示ãã¤ã¤ã§ããã ãä¸å¯§ã«ç´¹ä»ãã¦ããã¤ããã§ãã
ç¡ç·éä¿¡ã®æ¦è¦
ç¡ç·éä¿¡ã«ã¯ãéä¿¡å´ã¨åä¿¡å´ã®ä¸¡æ¹ã«ãã¯ã¤ã¤ã¬ã¹ã¢ãã ï¼Wireless Modemï¼ã¨ãããã¼ããã¤ããCCã³ã³ãã¥ã¼ã¿ãã¿ã¼ãã«ãç¨æããå¿ è¦ãããã¾ãã
Wireless Modemã®æ©è½ã«ãããé»æ³¢ã®å±ãç¯å²ã§ããã°å¥½ããªãã£ã³ãã«ã«ã¡ãã»ã¼ã¸ï¼å¿ ãæååã§ãªããã°ããã¾ããï¼ãéä¿¡ãæ¾é¡ã好ããªãã£ã³ãã«ãèãæ¾é¡ã¨ãªãã¾ãã
ã¤ã¾ããç¾å®ã®ç¡ç·éä¿¡ã®ããã«éä¿¡å 容ã®æå·åã¨ãçè´é²æ¢ã¨ãã¯å ¨ãèãããã¦ããªãã®ã§ã注æãã ãããç¹ã«ãã«ããã¬ã¤ã¤ã¼ç°å¢ã§ã¯è¦æ³¨æã§ãã
Wireless Modemã®ã¯ã©ãã
- ã¨ã³ãã¼ãã¼ã«1åãç¼ç³8åã§å²ãã§ã¯ã©ãããâãWireless Modem
Wireless Modemãè£ ç
å³æå´ã®è£ çã¹ãã¼ã¹ã空ãã¦ããââã¿ã¼ãã«ã¨Wireless Modemãã¯ã©ãããâãã¯ã¤ã¤ã¬ã¹ââã¿ã¼ãã«
ã³ã³ãã¥ã¼ã¿ãè¨ç½®ãã¦ã好ããªé¢ã«Wireless Modemãè£ çãâãã³ã³ãã¥ã¼ã¿ãWirelessModemãå¨è¾ºæ©å¨ã¨ãã¦å©ç¨ã§ãã
ï¼ä¸ã«ã¢ãã è£ çï¼
ï¼å ¨é¢ã¢ãã ï½ãç¹ã«æå³ã¯ããã¾ããï½ï¼
é»æ³¢ãå±ãç¯å²
é»æ³¢ãå±ãç¯å²ã¯ããã®ã³ã³ãã¥ã¼ã¿ï¼ã¿ã¼ãã«ï¼ãè¨ç½®ããé«åº¦ï¼Y座æ¨ï¼ã«ãã£ã¦æ±ºã¾ã£ã¦ãã¾ãã
- Y=1ï½96ã¯ãç¯å²64ï¼æ´ããæ¥ï¼
- é·é¨ã®æ¥ã¯ãç¯å²16
- Y座æ¨ã大ããï¼é«ãï¼ãªãã»ã©ç¯å²ã¯åºãã
- Y=256ãæ大ç¯å²ã§ã384ã¨ãªãã
- é·é¨ã®æ¥ã¯ãç¯å²96
ç´°ããæ°å¤ã¯ã¨ãããã¨ãã¦ã以ä¸ã®ããã«è¦ãã¦ããã°åé¡ãªãã§ãããã
- ä¸è¬çãªé«åº¦ã§ã¯64ãããã¯(ã¡ã¼ãã«)é¢ããã¨ããã¾ã§å±ãã
- é·é¨ã®æ¥ã¯16ãããã¯(ã¡ã¼ãã«)ã«ãªãã®ã§æ³¨æã
- é«åº¦ãããã100ãè¶ ããã¨ãé«ããã°é«ãã»ã©é ãã¾ã§å±ãããã«ãªãã
ç¡ç·éä¿¡ã§ä½¿ããã£ã³ãã«
ç¡ç·éä¿¡ã®ãã£ã³ãã«ã¯1-65535ã¾ã§åå¨ãã¦ãããã©ã®ãã£ã³ãã«ã§ã使ããã¨æãã°èªç±ã«ä½¿ããã¨ãã§ãã¾ãã
ãã ãRednet APIã®ä»æ§ã¨ãã¦ãèªåã®IDã¨åããã£ã³ãã«ãèªåå°ç¨ã®åä¿¡ãã£ã³ãã«ã¨ãã¦ä½¿ããã¨ã«ãªã£ã¦ãã¾ãã ãã®ãããComputerIDã1ã®ã³ã³ãã¥ã¼ã¿ã«ã¡ãã»ã¼ã¸ãéãã¨ãã«ã¯ããã£ã³ãã«1ã使ãã¾ãã
ã¾ãBROADCASTï¼ããã¼ããã£ã¹ããå ¨CCã³ã³ãã¥ã¼ã¿ã¸ã®ä¸æåæéä¿¡ï¼ç¨ã®ãã£ã³ãã«ã¨ãã¦ã65535ãäºç´ããã¦ãã¾ãããGPS APIã«ãã£ã¦GPSéä¿¡ç¨ã«65534ãäºç´ããã¦ãã¾ãããããã¯ç¹æ®ãªç¨éã§ä½¿ãã®ã§ããã以å¤ã®æã«ã¯ä½¿ããªãããã«ãã¾ãããã
ã¤ã¾ãã¾ã¨ããã¨ã以ä¸ã®ããã«ãªãã¾ãã
- Computer IDã¨åãçªå·ã®ãã£ã³ãã«ããã®ã³ã³ãã¥ã¼ã¿ã®åä¿¡ç¨ãã£ã³ãã«ã
- ãã£ã³ãã«65535ã«ã¡ãã»ã¼ã¸ãæµãã¨ããã¼ããã£ã¹ãï¼å ¨ã³ã³ãã¥ã¼ã¿ã«åæéä¿¡ï¼
- ãã£ã³ãã«65534ã¯ãGPSå°ç¨ãªã®ã§ä½¿ããªããã¨ã
ãªããã³ã³ãã¥ã¼ã¿ãã¿ã¼ãã«ã®IDã調ã¹ãã«ã¯ä»¥ä¸ã®ããã«ãã¾ãï¼ãã¡ãããsaveãã©ã«ãéãã¦ããlabels.txtããã¡ã¤ã«ãããã®ã³ã³ãã¥ã¼ã¿ã®IDã調ã¹ã¦ããããã§ããã©ãï¼ã
# ã³ã³ãã¥ã¼ã¿ã®ã¿ã¼ããã«ç»é¢ã§ã以ä¸ã®ããã°ã©ã ãå©ç¨ > id
-- ããã°ã©ã ã®ä¸ã§ãèªåã®IDã調ã¹ããªã以ä¸ã®ããã«ãå¤æ°myIdã«ä»£å ¥ãã¦ãã¾ãã local myId = os.getComputerID()
ç¡ç·éä¿¡ãå©ç¨ããããã®API
ç¡ç·éä¿¡ããããã®APIã¯ãRednet APIã¨ãPeripheral APIãããã¾ãã
- Rednet APIï¼ãæç·ã»ç¡ç·åããéä¿¡ç³»ãå¸ãAPIã§ãããã¦ãã®ãã¨ã¯ãã¡ãã使ãã°åé¡ããã¾ãããä»åã®é£è¼ã§ã¯ãã¡ãã説æãã¾ããã¡ãªã¿ã«ãMFR2ã®RedNet-Cableã¨ã¯ä¸åé¢ä¿ããã¾ããã
- Peripheral APIã使ã£ã¦Wireless Modemãç´æ¥æä½ï¼ãç´æ¥æä½ããã®ã§ã¨ã¦ãé«æ©è½ã§ããã¡ãã»ã¼ã¸ãéåä¿¡ãããã£ã³ãã«ãèªç±ã«é¸ã¶ãã¨ãã§ããä»ã®ãã£ã³ãã«ãçè´ãããã¨ãå¯è½ã§ãããã¡ãã®æ¹æ³ã«ã¤ãã¦ã¯èª¬æãã¾ããã
åºæ¬çã«ãRednet APIã®ä½¿ãæ¹ãè¦ããã ãã§å¤§ä¸å¤«ã§ãã 次åã¯ãã®APIã®ä½¿ãæ¹ãç´¹ä»ãã¾ãããã
è£è¶³ï¼CCã®ãã£ã³ãã«ã®ä½¿ãæ¹ã«ã¤ãã¦ãã¨ã話
è¹ãæ½æ°´è¦ã®æ ç»ãªã©ã§ä¼å£°ç®¡ã使ãããã·ã¼ã³ãè¦ããã¨ãããã¾ããããCCã®ç¡ç·éä¿¡ã·ã¹ãã ã¯ãã®ã¤ã¡ã¼ã¸ã«è¿ãããã«æããã¾ãã
ã³ã³ãã¥ã¼ã¿ï¼ID1ï¼ã®ç®ã®åã«ã¯65535æ¬ã®ä¼å£°ç®¡ã並ãã§ãã¾ãï¼å¤ãï½ï¼ã ã¿ã¼ãã«ï¼ID2ï¼ã®ç®ã®åã«ã65535æ¬ã®ä¼å£°ç®¡ã並ãã§ãã¾ãã ä¼å£°ç®¡ã«ã¯ããããIDãå²ãæ¯ããã¦ãããã³ã³ãã¥ã¼ã¿ãã¿ã¼ãã«ãããããèªç±ã«ä½¿ã£ã¦ãã¡ãã»ã¼ã¸ã®ããåããã§ãã¾ãã
ãã ãããã¾ãã«ãããªã¼ãã ã«ä½¿ãããã¨å°ãã®ã§ããã¤ãã®ã«ã¼ã«ããäºãã®åæã®å ã«å®ãã¦ãã¾ãã
- ã¡ãã»ã¼ã¸ãéä¿¡ããã¨ãã«ã¯ãéä¿¡å
IDã¨åãIDã®ä¼å£°ç®¡ï¼ãã£ã³ãã«ï¼ã使ãã
- ID1âID2ãªãã°ããã£ã³ãã«2ã使ããã¨ã
- åä¿¡å´ã¯ãå¿
ããããã®ãã£ã³ãã«ãèãæ
å¢ã«ãªã£ã¦ããã¨ã¯éããªãã
- èãæ å¢ã«ãªã£ã¦ããªãã¨ãã¯ãéãããã¡ãã»ã¼ã¸ã¯ãã®ã¾ã¾ã¹ã«ã¼ããã¦æ¶ããã
- èãã¨ãã«ã¯ãèªåã®IDã¨åãIDã®ãã£ã³ãã«ãåªå ãã¦èãã
ãããã«ã¼ã«ã¯ãRednetAPIã®ä»æ§ã«ããæé»çã«å®ãããã¦ãã¾ããè¨ãæ¹ãå¤ããã°ãRednetAPIã使ãã°ãèªç¶ã¨ãããã«ã¼ã«ã«å¾ããã¨ã«ãªãã¾ãã ãã£ã¨æè»ãªä½¿ãæ¹ãããããªãã°ãèªåã§æ°ããAPIãã¤ããã¾ãããï¼P
ä¾ï¼ãã¢ããã¥ã¢ç¡ç·ã¿ããããã£ã³ãã«1ã¤ã ãã使ã£ã¦äºãã«ã¡ãã»ã¼ã¸ã®ããåããè¡ãããã«ãããã¡ãããã®éä¿¡çµããããåé¡ãªãåä¿¡ã§ãã¾ããããªã©ã®ãããªç¬¦å·ãå®ç¾©ãã¦ããã¦ããåããããªã©ã