APIãä½ããï¼ï¼ï¼ï¼Colors APIãã調ã¹ã¦ã³ããã¤ããã
ã¯ããã«
ååã¯å¤±ç¤¼ãã¾ããã
ããã§ã¯æ°ããAPIãå®è£ ããããã«ãæ¢åã®APIã調ã¹ã¦ã¿ã¾ãããã
ãCraft OSããTurtle OSããæä¾ãã¦ããAPIãããããè¦ãã¦ã¿ãã®ã§ããã
å°ããã¦ã·ã³ãã«ã¨ããç¹ã§Colors APIãåèã«ãªãããã§ãã
ä»åã¯ãã®Colors APIã調ã¹ã¦ã¿ã¾ãããã
ãªãããã®APIã®è©³ç´°ã«ã¤ãã¦ã¯ä»¥ä¸ãåç
§ãã¦ãã ããã
CC非公式Wiki Colors API
ã¾ãããã¤ãã®ãã¨ãé·ãã®ã§ãæéã®ãªã人ã¯ãã¾ã¨ããã ãè¦ã¦ä¸ããã
Colors APIã¨ã¯
ããã¯ä½ãããAPIãªã®ã
è²ã¾ãã¯è²éåï¼ç½ã¨éã¨é»ãã®ããã«åç´ã«è²ãç¾
åããéåï¼ãåãæ±ãããã®ãã®ã§ã
MFRã®RedNetCableãRedPowerã®BundledCableãããã¦éè²ã®Advanced Computerï¼Monitorï¼ãªã©ã§å©ç¨ãã¾ãã
ã¤ã®ãªã¹äººåãã«å¥ç¶´ãã®åä¸APIï¼Colours APIï¼ãç¨æãã¦ããã¨ãããæ°é
ãç´°ããã§ããã
ãªãCCã§æ±ããè²ã¯å ¨é¨ã§16è²ã以ä¸ã®ããã«ä»æ§ã決ã¾ã£ã¦ãã¾ãã
- 16ããã2é²æ°ã«ããã¦1ãæã ã1ãç«ã¦ããã®16種é¡ãããã使ã£ã¦16è²ã表ç¾
- 10é²æ°è¡¨ç¾ã§è¨ããªãã°ãç½=1(2ã®0ä¹)ããªã¬ã³ã¸=2(2ã®1ä¹)ãã»ã»ã»ãé»=32768(2ã®15ä¹)ãã®ããã«å¯¾å¿ãã¦ããã
- ããã«ãã£ã¦è²éåããåè²ã®ãããè«çåãåããã¨ã§è¡¨ç¾ã§ããã
æä½éãããã ãç¥ã£ã¦ããã°å¤§ä¸å¤«
2é²æ°ã¨ãè¨ããã¾ãã¦ãã»ã»ã»ã¨ããæ¹ã¸ã
2é²æ°ããããªãã¦ã大ä¸å¤«ããããæ¼ç®ã¨ãããããªã人ã§ãè²ãåãæ±ããããã«ãã¦ãããã®ããã®APIã®ç®çã§ããã¨ã¦ã親åï¼
以ä¸ã®èµ¤åã ãè¦ãã¦ãã ãããã·ã³ãã«ãªAPIã§ããï¼ããããããã¾ãã«APIã®æ¬è³ªã§ããã
- ããã°ã©ã ä¸ã§ä½¿ããè²ã¯ä»¥ä¸ã®16è²ã
- white, orange, magenta, lightBlue, yellow, lime, pink, gray, lightGray, cyan, purple, blue, brown, green, red, black
- è²ãæå®ããããã«ã¯ããã¨ãã°ç½ãªãããcolors.whiteãã¨ããå®æ°ã使ãã
- MFRã®RedNetCableã§ã¯ããç½ã¨éã¨é»è²ãã®ããã«è¤æ°ã®è²ãä¸åº¦ã«æå®ããããã¨ãããã
- ãã®ã¨ãã«ã¯ãcolors.combineé¢æ°ã使ã£ã¦ã以ä¸ã®ããã«è²éåãä½ããæå®ããã
colors.combine(colors.white, colors.blue, colors.yellow)
Colors APIã®å®è£
æ¦è¦
- ã¾ããã°ãã¼ãã«å¤æ°ãcolorsããç¨æãããããã®ä¸èº«ã¯ãã¼ãã«ã
- ãã®ãã¼ãã«ã®ä¸ã«ã16åã®è²å®æ°ãè²éåãæ±ãããã®3ã¤ã®é¢æ°ãå ¥ã£ã¦ãã
- ãcolors.whiteãã®ããã«ã.ãï¼ãããï¼è¨æ³ã§åå®æ°ãé¢æ°ã«ã¢ã¯ã»ã¹ããã
å ·ä½çãªå®è£
/rom/program/apis/colors ã¨ãããã¡ã¤ã«ããã®å®è£
ã§ãã
以ä¸ã«å¼ç¨ããã®ã§ãã£ã¨çºãã¦ã¿ã¾ãããã
-- Colors white = 1 orange = 2 magenta = 4 lightBlue = 8 yellow = 16 lime = 32 pink = 64 gray = 128 lightGray = 256 cyan = 512 purple = 1024 blue = 2048 brown = 4096 green = 8192 red = 16384 black = 32768 function combine( ... ) local r = 0 for n,c in ipairs( { ... } ) do r = bit.bor(r,c) end return r end function subtract( colors, ... ) local r = colors for n,c in ipairs( { ... } ) do r = bit.band(r, bit.bnot(c)) end return r end function test( colors, color ) return ((bit.band(colors, color)) == color) end
- ååã¯16åã®å®æ°å®ç¾©ã
- å¾åã®é¢æ°å®ç¾©ã§ã¯ããããæ¼ç®ãé§ä½¿ãã¦ããã2é²æ°è¦æãªäººãå¤ãã ãããããã§ã¯è©³ç´°ã«ã¯è§¦ãã¾ããã
- é¢æ°å®ç¾©æã®å¼æ°ã¨ãã¦ã...ããè¨è¿°ãã¦ãã¾ãããããã¯å¯å¤å¼æ°ï¼å¼æ°ã®åæ°ã¯ããã¤ã§ãå¯ï¼ã«å¯¾å¿ãããããã§ãã
- ãã¤ã³ãã¯ãå®æ°ããé¢æ°ããã¹ã¦ã°ãã¼ãã«ã¨ãã¦å®ç¾©ãã¦ãããã¨ã
ã¤ã¾ãããcolorsãã¨ãããã¡ã¤ã«ã®ä¸ã«ã°ãã¼ãã«ã¨ãã¦å¤æ°ï¼å®æ°ï¼ã»é¢æ°ãå®ç¾©ãã¦ããã¨ãä»ã®ããã°ã©ã ã¯ãããããcolorsãã¨ããã°ãã¼ãã«å¤æ°ãä»ãã¦å©ç¨ã§ããããã«ãªãã
ãªãè£è¶³ã§ããããã¡ã¤ã«å
ã§local宣è¨ãã¦ãã¼ã«ã«ã§å®ç¾©ããå¤æ°ã»é¢æ°ã¯ãããã°ã©ãå´ã¯å©ç¨ã§ãã¾ããã
ã¾ããæ¨æºã®APIã§ã¯ãªãæ°ãã追å ãããAPIãå©ç¨ããã«ã¯ããos.loadAPI(ãã¡ã¤ã«å)ãé¢æ°ã使ãå¿
è¦ãããã¾ãã
ã¾ã¨ãï¼ãAPIä½ææã®ãã¤ã³ã
以ä¸ãã¾ã¨ãã¾ãã
CCã³ã³ãã¥ã¼ã¿ã«ãããAPI
ãTurtle OSããCraft OSãã®APIã¯ãå®ç¨ä¸ã以ä¸ã®ããã«æä¾ããã¦ãã¾ãã
- APIã«å«ã¾ããå®æ°ã»é¢æ°ã¯ãä¸ã¤ã®ã°ãã¼ãã«å¤æ°ï¼ãã¨ãã°ãcolorsãï¼ã®ä¸ã«ãã¼ãã«ã®å½¢ã§å ¥ã£ã¦ãã¾ãã
- ãã®ãã¼ãã«ã®ä¸ã«ããå®æ°ã»é¢æ°ã«ã¯ããcolors.whiteããcolors.combine()ãã®ããã«ã.ãï¼ãããï¼è¨æ³ã§ã¢ã¯ã»ã¹ãã¾ãã
APIã®å®è£ æ¹æ³
ãã®ãããæ°ããAPIãå®è£ ããããã«ã¯ä»¥ä¸ã®ãã¨ã«æ°ãä»ãã¾ã
- ãå®æ°ã»é¢æ°ãæ ¼ç´ããã°ãã¼ãã«å¤æ°åãï¼ããã¡ã¤ã«åãã§ãã
- ã¤ã¾ããmyapiãã¨ãããã¡ã¤ã«å ã§å®ç¾©ããé¢æ°ãhevohevo()ãã¯ããmyapi.hevohevo()ãã¨è¨è¿°ãããã¨ã§å©ç¨ã§ããã
- ãã®ãã¡ã¤ã«ä¸ã§ã°ãã¼ãã«å®£è¨ããå¤æ°ã»é¢æ°ã¯ããã¹ã¦å¤é¨ããã°ã©ã ããå©ç¨å¯è½ã«ãªãã¾ãã
- å¤é¨ããã°ã©ã ããã¢ã¯ã»ã¹ãã¦æ¬²ãããªããã®ã¯ããã¹ã¦ãã¼ã«ã«å®£è¨ãã¦ããã¾ãããã
APIã®å©ç¨å®£è¨
APIãå¤é¨ã®ããã°ã©ã ã§å©ç¨ããããã«ã¯æ¬¡ã®ããããã®æ¹æ³ãã¨ãã¾ãã
æ¹æ³ï¼ï¼os.loadAPI()é¢æ°ãããã°ã©ã ã®å é ã§ä½¿ã
æ°ããä½ã£ãèªå®¶è£½APIãå©ç¨ããããã«ã¯ã
å©ç¨ããå´ã®ããã°ã©ã ã®æåã®æ¹ã§ãOS APIã®loadAPI()é¢æ°ã使ãã¾ãããã
os.loadAPI("myapi") --ããã°ã©ã ã¨åããã£ã¬ã¯ããªã«ãããªããã¡ã¤ã«åã ãã§è¯ã os.loadAPI("/rom/apis/opt/myapi") -- ã¡ãããã£ã¬ã¯ããªã«ãããªã絶対ãã¹è¡¨ç¾ã§
ãã®é¢æ°ãããã¡ã¤ã«åã¨åãå¤æ°ä½ã£ã¦ãã¡ã¤ã«å ã®ã°ãã¼ãã«å¤æ°ã»é¢æ°ãæ ¼ç´ãã¨ããã¨ããã¾ã§ä¸æ°ã«ãã£ã¦ãããããã§ããããããããã¼ã
æ¹æ³ï¼ï¼æ¨æºAPIã¨ãã¦èªã¿è¾¼ã¾ãããã£ã¬ã¯ããªã«APIãã¡ã¤ã«ãä¿åããã
- ã/rom/apis/ããæ¨æºã®ãã£ã¬ã¯ããªã§ããã¿ã¼ãã«ç¨APIãªãã/rom/apis/turtleãã§ãã
- ããã«ãã¡ã¤ã«ãä¿åãã¾ãããã
- ãã¨ã¯èªåçã«loadAPI()ãã¦ããã¾ãï¼ãªããã®ä½æ¥ã¯bios.luaãã¡ã¤ã«å ã«è¨è¿°ããã¦ãã¾ãï¼ã
æ¹æ³ï¼ï¼ã¹ã¿ã¼ãã¢ãããã¡ã¤ã«ã§èªåçã«loadAPIããã
- èªä½APIãloadAPI()ããããã°ã©ã ï¼ã¹ã¯ãªããï¼ãä½ã£ã¦ããã¦ãCCã³ã³ãã¥ã¼ã¿èµ·åæã«å®è¡ãããã®ãããã§ãããã
- ã/rom/autorun/ããã£ã¬ã¯ããªã®å©ç¨ã§ãããå ·ä½çãªã¹ã¯ãªãããããæ¹ã«ã¤ãã¦ã¯ã¾ãå¾æ¥ã