{"id":5903,"date":"2024-11-25T16:58:17","date_gmt":"2024-11-25T08:58:17","guid":{"rendered":"http:\/\/blog.coolcoding.cn\/?p=5903"},"modified":"2024-11-25T17:12:32","modified_gmt":"2024-11-25T09:12:32","slug":"lua%e8%a1%a8%e6%a0%bc%e6%95%b0%e6%8d%ae%e4%bc%98%e5%8c%96%e8%ae%b0%e5%bd%95","status":"publish","type":"post","link":"https:\/\/blog.coolcoding.cn\/?p=5903","title":{"rendered":"Lua\u8868\u683c\u6570\u636e\u4f18\u5316\u8bb0\u5f55"},"content":{"rendered":"\n<p>\u9879\u76ee\u4e2d\u4f7f\u7528\u4e86Unity+Lua\uff0c\u800c\u7b56\u5212\u8868\u683c\u6570\u636e\u4f7f\u7528\u7684\u662f\u4e00\u6b3e\u5f00\u6e90\u7684Excel\u8f6cLua\u7684\u5de5\u5177<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/zhangqi-ulua\/XlsxToLua\">https:\/\/github.com\/zhangqi-ulua\/XlsxToLua<\/a><\/p>\n\n\n\n<p>\u8fd9\u4e2a\u8f6c\u51fa\u6765\u7684\u6570\u636e\uff0c\u6700\u5927\u7684\u95ee\u9898\u5728\u4e8e &#8211; <strong>\u539f\u59cb<\/strong><\/p>\n\n\n\n<p>\u4e00\u3001\u5185\u5b58<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>return {\n  &#91;1001] = {\n    id = 100, \n    name = \"name1\",\n    items = {\n      &#91;1]= { \n        itemid = 1,\n        itemnum = 2,\n      },\n      &#91;2]= { \n        itemid = 1,\n        itemnum = 2,\n      },\n    },\n  },\n  &#91;1002] = {\n    id = 102, \n    name = \"name2\",\n    items = {\n      &#91;1]= { \n        itemid = 1,\n        itemnum = 2,\n      },\n      &#91;2]= { \n        itemid = 1,\n        itemnum = 2,\n      },\n    },\n  },\n}<\/code><\/pre>\n\n\n\n<p>\u5927\u91cf\u7684Key-Value\u7ed3\u6784\uff0c\u5bfc\u81f4\u5185\u5b58\u5360\u7528\u8fc7\u9ad8<\/p>\n\n\n\n<p>\u4e8c\u3001\u6613\u88ab\u4fee\u6539<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>local items = require(\"items\")\nlocal item = items&#91;1]\nlocal itemId = item.id\nitem.id = 1002<\/code><\/pre>\n\n\n\n<p class=\"has-vivid-red-color has-text-color has-link-color wp-elements-726ae57a96ef59b7bccbadb54bcb6398\"><strong>\u7b56\u5212\u8868\u683c\u6570\u636e\u4e3a\u53ea\u8bfb\u6570\u636e\uff0c\u4e0d\u80fd\u968f\u6613\u4fee\u6539\u6570\u636e<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6539\u9020\u65b9\u6848<\/h2>\n\n\n\n<p>\u884c\u8f6c\u5217<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>return {\n  id = { 1001, 1002, 1003 ... },\n  name = { \"name1\", \"name2\" ... },\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\u6ce8\u610f\uff1a\u8fd9\u6837\u9700\u8981\u4e00\u4e2a\u8bfb\u53d6\u5668\uff0c\u8fdb\u884c\u8f6c\u6362\uff0c\u793a\u4f8b\uff1a\nlocal line = Config.Get(1001)\nprint(line.id)\nprint(line.name)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u6539\u9020\u540e\u7684\u6570\u636e\u5bf9\u6bd4<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\u4e00\u5171\u6539\u9020\u4e8611\u5f20\u8868\uff0c\u8fd0\u884c\u65f6\u5185\u5b58\u5bf9\u6bd4\uff1a\n\u6539\u9020\u524d\u4e3b\u57ce\u754c\u9762Lua\u5360\u7528\u5185\u5b58\uff1a72.1M\n\u6539\u9020\u524d\u4e3b\u57ce\u754c\u9762Lua\u5360\u7528\u5185\u5b58\uff1a54.9M<\/code><\/pre>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-ffd58ef82270093eacd1c5e70d8b2949\">Lua\u4e2d\u4e00\u4e2atable\u5360\u7528\u4e8640\u4e2a\u5b57\u8282\uff0c\u5e76\u4e14\u5f53table\u4e2d\u5b58\u50a8\u7684\u4e0d\u4e3a\u539f\u751f\u6570\u7ec4\u540e\uff0c\u5176\u5360\u7528\u5b58\u50a8\u7a7a\u95f4\u66f4\u5927<\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-982fcf94a18960af2f0512d69e8a6988\">\u6240\u4ee5\u8981\u5c3d\u91cf\u5c11\u4f7f\u7528table\uff0c\u591a\u4f7f\u7528\u539f\u751f\u6570\u636e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9879\u76ee\u4e2d\u4f7f\u7528\u4e86Unity+Lua\uff0c\u800c\u7b56\u5212\u8868\u683c\u6570\u636e\u4f7f\u7528\u7684\u662f\u4e00\u6b3e\u5f00\u6e90\u7684Excel\u8f6cLua\u7684\u5de5\u5177 https:\/\/gi [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/5903"}],"collection":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5903"}],"version-history":[{"count":8,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/5903\/revisions"}],"predecessor-version":[{"id":5912,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/5903\/revisions\/5912"}],"wp:attachment":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}