From acf3a4309595b735a5c4c6c743b202e37e6366a5 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 22 Jul 2012 17:11:41 +0300 Subject: Add /test1 command to minimal for testing a more complicated player inventory form --- games/minimal/mods/experimental/init.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'games/minimal/mods') diff --git a/games/minimal/mods/experimental/init.lua b/games/minimal/mods/experimental/init.lua index 5661a660f..12aab3b06 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())) -- cgit v1.2.3