{"id":1966,"date":"2022-06-05T10:31:51","date_gmt":"2022-06-05T02:31:51","guid":{"rendered":"https:\/\/www.shuizilong.com\/house\/?p=1966"},"modified":"2022-06-05T10:50:46","modified_gmt":"2022-06-05T02:50:46","slug":"minetest-in-game-transfer","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/minetest-in-game-transfer\/","title":{"rendered":"Minetest \u5982\u4f55\u5b9e\u73b0\u6e38\u620f\u5185\u8f6c\u8d26"},"content":{"rendered":"<h2>\u5ba2\u6237\u7aef\u4fee\u6539<\/h2>\n<p>\u4e4b\u524d\u53d1\u73b0 Minetest \u7684\u5f15\u64ce\u4ee3\u7801\u662f\u548c easyrpg \u4e00\u6837\u662f cpp\uff0c\u90a3\u4e48\u4e5f\u5c31\u610f\u5473\u7740\u5b83\u4e5f\u540c\u6837\u6709\u673a\u4f1a\u53ef\u4ee5\u4f7f\u7528 emscripten \u7f16\u8bd1\u5230\u6d4f\u89c8\u5668\u4e2d\u8fd0\u884c\u3002<br \/>\n\u7f51\u4e0a\u641c\u4e86\u4e00\u5708\uff0c\u53d1\u73b0\u8fd8\u771f\u6709\u4eba\u5df2\u7ecf\u505a\u4e86\u8fd9\u4ef6\u4e8b\u3002\u3002\u3002<br \/>\nhttps:\/\/blog.minetest.net\/2022\/03\/27\/March\/<\/p>\n<p>\u90a3\u4e48\u73b0\u5728\u8f6c\u8d26\u547d\u4ee4\u5c31\u975e\u5e38\u5bb9\u6613\u5b9e\u73b0\u4e86\uff0c\u53ef\u4ee5\u5148\u5199\u5728 js \u91cc\uff0c\u7136\u540e\u76f4\u63a5\u8c03\u7528\u5bf9\u5e94\u7684 js \u65b9\u6cd5\u5373\u53ef\u3002<br \/>\n\u4e0d\u8003\u8651\u5b89\u5168\u95ee\u9898\u3002\u3002\u6211\u4eec\u5148\u505a\u4e00\u4e2a\u7b80\u6613\u4e14\u6cdb\u7528\u7684\u5b9e\u4f5c\u3002\u3002\u7528\u90aa\u6076\u7684 <a href=\"https:\/\/github.com\/AlexNisnevich\/untrusted\">Dr.Eval<\/a> \u5927\u6cd5\uff0c\u6267\u884c\u4efb\u4f55\u811a\u672c\u3002\u3002\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nvoid escape_EM_ASM(const std::wstring &amp;message) {\r\n\tstd::wstring m = translate_string(message);\r\n\tstd::string s(m.length(), 0);\r\n\tstd::transform(m.begin(), m.end(), s.begin(), &#x5B;] (wchar_t c) {\r\n\t\treturn (char)c;\r\n\t});\r\n\tMAIN_THREAD_ASYNC_EM_ASM(console.log(&quot;Msg: &quot; + UTF8ToString($0)), s.c_str());\r\n\tstd::string c;\r\n\tc = &quot;.EM_ASM &quot;;\r\n\tif (s.find(c) != std::string::npos) {\r\n\t\ts = s.substr(s.find(c) + c.size());\r\n\t\tMAIN_THREAD_ASYNC_EM_ASM(eval(UTF8ToString($0)), s.c_str());\r\n\t\treturn;\r\n\t}\r\n}\r\n<\/pre>\n<p>\u6ce8\u610f\u8fd9\u91cc\u6211\u8e29\u4e86\u4e00\u4e2a\u5751\u3002\u3002\u3002https:\/\/github.com\/paradust7\/minetest-wasm\/issues\/3<br \/>\n\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u6700\u597d\u7528\u8fd9\u4e2a\u547d\u4ee4\u3002\u3002MAIN_THREAD_ASYNC_EM_ASM\u3002\u3002\u3002<br \/>\n\u4e0a\u9762\u7684\u4ee3\u7801\u5982\u679c\u6362\u6210 EM_ASM\uff0c\u90a3\u4e48\u53d1\u6d88\u606f\u7684\u65f6\u5019\u7528\u8fd9\u4e2a\u8fd8\u662f\u80fd trigger \u91cc\u9762\u7684 js \u4ee3\u7801\uff0c<br \/>\n\u4f46\u662f\u5982\u679c\u7ecf\u8fc7\u4e00\u6b21\u670d\u52a1\u5668\u6536\u5230\u6d88\u606f\u7684\u65f6\u5019\u8fdb\u884c\u89e3\u6790\u5c31\u65e0\u6548\u4e86\uff0c\u800c\u6a21\u7ec4\u91cc\u7684 <code>minetest.chat_send_player(name, text)<\/code> API \u662f\u4f1a\u7ecf\u8fc7\u4e00\u6b21\u670d\u52a1\u5668\u7684\u3002<\/p>\n<h2>\u6a21\u7ec4\u4fee\u6539<\/h2>\n<p>\u6a21\u7ec4\u7b2c\u4e00\u4e2a\u8981\u6c42\u5c31\u662f\u6211\u4eec\u9700\u8981\u6709\u4e00\u4e2a\u52a8\u4f5c\u80fd\u591f trigger \u53f3\u51fb\u73a9\u5bb6\u8fd9\u4e2a\u4e8b\u4ef6\u3002\u3002\u3002<code>on_rightclick<\/code> \u4ec0\u4e48\u7684\u3002\u3002<br \/>\n\u641c\u4e86\u4e00\u5708\u53d1\u73b0\u6ca1\u6709\u73b0\u6210\u7684 API\u3002\u3002\u3002<\/p>\n<p>\u4f46\u662f\u6709\u4e00\u4e2a\u73b0\u6210\u7684 mod \u91cc\u6709\u8fd9\u4e2a\u529f\u80fd\u3002\u3002\u3002\u6240\u4ee5\u6211\u4eec\u4ece\u90a3\u4e2a\u6a21\u7ec4\u5f00\u59cb\u5165\u624b\u3002\u3002\u3002<br \/>\n\u9996\u5148\u6dfb\u52a0 right_click \u7684\u4e8b\u4ef6\uff0c\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u83dc\u5355\u3002\u3002\u3002<\/p>\n<p>https:\/\/rubenwardy.com\/minetest_modding_book\/en\/players\/formspecs.html<\/p>\n<pre class=\"brush: jscript; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nminetest.register_on_rightclickplayer(function(player, clicker)\r\n\tlocal s = clicker:get_player_name()\r\n\tlocal t = player:get_player_name()\r\n\tlocal controls = clicker:get_player_control()\r\n\tif not(check_distance(clicker, player)) then\r\n\t\tminetest.chat_send_player(s, S(&quot;Target too far.&quot;))\r\n\t\treturn\r\n\tend\r\n\tlocal context = get_context(s)\r\n\tcontext.target = t\t\r\n\tlocal formspec = {\r\n\t\t&quot;formspec_version&#x5B;4]&quot;,\r\n\t\t&quot;size&#x5B;4.5,5.25]&quot;,\r\n\t\t&quot;label&#x5B;0.375,0.5;&quot;, minetest.formspec_escape(&quot;This is &quot; .. t .. &quot;.&quot;), &quot;]&quot;,\r\n\t\t&quot;button_exit&#x5B;0.5,1;3.5,0.8;profile;Profile]&quot;,\r\n\t\t&quot;button_exit&#x5B;0.5,2;3.5,0.8;transfer;Transfer]&quot;,\r\n\t\t&quot;button_exit&#x5B;0.5,3;3.5,0.8;follow;Follow]&quot;,\r\n\t\t&quot;button_exit&#x5B;0.5,4;3.5,0.8;cancel;Cancel]&quot;\r\n\t}\r\n\tminetest.show_formspec(s, &quot;player:interact&quot;, table.concat(formspec, &quot;&quot;))\r\nend)\r\n<\/pre>\n<p>\u4e0a\u9762\u7684\u4ee3\u7801\u91cc\u6211\u4eec\u5f00\u4e86\u4e00\u4e2a\u72b6\u6001 context.target \u7528\u6765\u8bb0\u5f55\u5f53\u524d\u4ea4\u4e92\u7684\u5bf9\u8c61\u3002\u3002<\/p>\n<p><a href=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2022\/06\/FUcd02daAAAcnnY.jpg\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1968\" data-permalink=\"https:\/\/www.shuizilong.com\/house\/archives\/minetest-in-game-transfer\/fucd02daaaacnny\/\" data-orig-file=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2022\/06\/FUcd02daAAAcnnY.jpg\" data-orig-size=\"965,703\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"FUcd02daAAAcnnY\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2022\/06\/FUcd02daAAAcnnY.jpg\" data-large-file=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2022\/06\/FUcd02daAAAcnnY.jpg\" src=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2022\/06\/FUcd02daAAAcnnY.jpg\" alt=\"\" width=\"965\" height=\"703\" class=\"aligncenter size-full wp-image-1968\" \/><\/a><\/p>\n<p>\u7136\u540e\u518d\u5904\u7406\u83dc\u5355\u7684\u56de\u6267\u5373\u53ef\u3002\u3002\u3002<\/p>\n<pre class=\"brush: jscript; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nminetest.register_on_player_receive_fields(function(player, formname, fields)\r\n\r\n    if formname == &quot;player:interact&quot; then\r\n\t\tlocal s = player:get_player_name()\r\n\t\tlocal t = get_context(s).target\t\t\r\n\t\tif fields.profile then\t\t\t\r\n\t\t\tminetest.chat_send_player(s, &quot;.EM_ASM window.open(\\&quot;https:\/\/&quot; .. t .. &quot;.test.w3itch.io\/zh-CN\\&quot;, \\&quot;new\\&quot;)&quot;)\t\t\t\t\t\t\t\r\n\t\tend\r\n\t\tif fields.transfer then\t\t\t\r\n\t\t\tminetest.chat_send_player(s, &quot;.EM_ASM alert(feature not implement yet...)&quot;)\t\t\t\t\t\t\t\r\n\t\tend\r\n\t\tif fields.follow then\t\t\t\r\n\t\t\tminetest.chat_send_player(s, &quot;.EM_ASM alert(feature not implement yet...)&quot;)\t\t\t\t\t\t\t\r\n\t\tend\r\n\t\treturn true\r\n    end\r\n\r\nend)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5ba2\u6237\u7aef\u4fee\u6539 \u4e4b\u524d\u53d1\u73b0 Minetest \u7684\u5f15\u64ce\u4ee3\u7801\u662f\u548c easyrpg \u4e00\u6837\u662f cpp\uff0c\u90a3\u4e48\u4e5f\u5c31\u610f\u5473\u7740\u5b83\u4e5f\u540c\u6837\u6709\u673a\u4f1a\u53ef\u4ee5\u4f7f\u7528 emscripten \u7f16\u8bd1\u5230\u6d4f\u89c8\u5668\u4e2d\u8fd0\u884c\u3002 \u7f51\u4e0a\u641c\u4e86\u4e00\u5708\uff0c\u53d1\u73b0\u8fd8\u771f\u6709\u4eba\u5df2\u7ecf\u505a\u4e86\u8fd9\u4ef6\u4e8b\u3002\u3002\u3002 https:\/\/blog.minetest.net\/2022\/03\/27\/March\/ \u90a3\u4e48\u73b0\u5728\u8f6c\u8d26\u547d\u4ee4\u5c31\u975e\u5e38\u5bb9\u6613\u5b9e\u73b0\u4e86\uff0c\u53ef\u4ee5\u5148\u5199\u5728 js \u91cc\uff0c\u7136\u540e\u76f4\u63a5\u8c03\u7528\u5bf9\u5e94\u7684 js \u65b9\u6cd5\u5373\u53ef\u3002 \u4e0d\u8003\u8651\u5b89\u5168\u95ee\u9898\u3002\u3002\u6211\u4eec\u5148\u505a\u4e00\u4e2a\u7b80\u6613\u4e14\u6cdb\u7528\u7684\u5b9e\u4f5c\u3002\u3002\u7528\u90aa\u6076\u7684 Dr.Eval \u5927\u6cd5\uff0c\u6267\u884c\u4efb\u4f55\u811a\u672c\u3002\u3002\u3002 void escape_EM_ASM(const std::wstring &amp;message) { std::wstring m = translate_string(message); std::string s(m.length(), 0); std::transform(m.begin(), m.end(), s.begin(), &#x5B;] (wchar_t c) { return (char)c; }); MAIN_THREAD_ASYNC_EM_ASM(console.log(&quot;Msg: &quot; + UTF8ToString($0)), s.c_str()); std::string c; c = &quot;.EM_ASM &quot;; if (s.find(c) != [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[],"class_list":["post-1966","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-vI","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/comments?post=1966"}],"version-history":[{"count":1,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1966\/revisions"}],"predecessor-version":[{"id":1967,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1966\/revisions\/1967"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=1966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=1966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=1966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}