From: Perttu Ahola Date: Sun, 22 Jul 2012 14:11:41 +0000 (+0300) Subject: Add /test1 command to minimal for testing a more complicated player inventory form X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=acf3a4309595b735a5c4c6c743b202e37e6366a5;p=zefram%2Fminetest%2Fminetest_engine.git Add /test1 command to minimal for testing a more complicated player inventory form --- diff --git a/games/minimal/mods/experimental/init.lua b/games/minimal/mods/experimental/init.lua index 5661a660..12aab3b0 100644 --- a/games/minimal/mods/experimental/init.lua +++ b/games/minimal/mods/experimental/init.lua @@ -517,6 +517,38 @@ minetest.register_craft({ end) end)]] +minetest.register_chatcommand("test1", { + params = "", + description = "Test 1: Modify player's inventory view", + func = function(name, param) + local player = minetest.env:get_player_by_name(name) + if not player then + return + end + player:set_inventory_formspec( + "size[13,7.5]".. + "image[6,0.6;1,2;player.png]".. + "list[current_player;main;5,3.5;8,4;]".. + "list[current_player;craft;8,0;3,3;]".. + "list[current_player;craftpreview;12,1;1,1;]".. + "button[0.5,7;2,1;button1;Button 1]".. + "button[2.5,7;2,1;button2;Button 2]" + ) + minetest.chat_send_player(name, "Done."); + end, +}) + +minetest.register_on_player_receive_fields(function(player, formname, fields) + experimental.print_to_everything("Inventory fields 1: player="..player:get_player_name()..", fields="..dump(fields)) +end) +minetest.register_on_player_receive_fields(function(player, formname, fields) + experimental.print_to_everything("Inventory fields 2: player="..player:get_player_name()..", fields="..dump(fields)) + return true -- Disable the first callback +end) +minetest.register_on_player_receive_fields(function(player, formname, fields) + experimental.print_to_everything("Inventory fields 3: player="..player:get_player_name()..", fields="..dump(fields)) +end) + minetest.log("experimental modname="..dump(minetest.get_current_modname())) minetest.log("experimental modpath="..dump(minetest.get_modpath("experimental"))) minetest.log("experimental worldpath="..dump(minetest.get_worldpath()))