aboutsummaryrefslogtreecommitdiff
path: root/games/minimal/mods/experimental
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-07-25 02:36:54 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-07-25 02:36:54 +0300
commit9eaf93d41d6745b877f8f52cf54b21050abefda1 (patch)
tree5ceebc9b208a415a01440f60605345f5c238cae2 /games/minimal/mods/experimental
parent2ac20982e0772b94b21d95b53519bd2164632d98 (diff)
downloadminetest-9eaf93d41d6745b877f8f52cf54b21050abefda1.tar.gz
minetest-9eaf93d41d6745b877f8f52cf54b21050abefda1.tar.bz2
minetest-9eaf93d41d6745b877f8f52cf54b21050abefda1.zip
Detached inventory callbacks and reworked node metadata callbacks
Diffstat (limited to 'games/minimal/mods/experimental')
-rw-r--r--games/minimal/mods/experimental/init.lua26
1 files changed, 24 insertions, 2 deletions
diff --git a/games/minimal/mods/experimental/init.lua b/games/minimal/mods/experimental/init.lua
index 498c64623..0b45aeb62 100644
--- a/games/minimal/mods/experimental/init.lua
+++ b/games/minimal/mods/experimental/init.lua
@@ -516,7 +516,7 @@ minetest.register_craft({
--[[minetest.register_on_joinplayer(function(player)
minetest.after(3, function()
- player:set_inventory_formspec("invsize[8,7.5;]"..
+ player:set_inventory_formspec("size[8,7.5]"..
"image[1,0.6;1,2;player.png]"..
"list[current_player;main;0,3.5;8,4;]"..
"list[current_player;craft;3,0;3,3;]"..
@@ -525,7 +525,29 @@ minetest.register_craft({
end)]]
-- Create a detached inventory
-local inv = minetest.create_detached_inventory("test_inventory")
+local inv = minetest.create_detached_inventory("test_inventory", {
+ allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
+ experimental.print_to_everything("allow move asked")
+ return count -- Allow all
+ end,
+ allow_put = function(inv, listname, index, stack, player)
+ experimental.print_to_everything("allow put asked")
+ return 1 -- Allow only 1
+ end,
+ allow_take = function(inv, listname, index, count, player)
+ experimental.print_to_everything("allow take asked")
+ return 4 -- Allow 4 at max
+ end,
+ on_move = function(inv, from_list, from_index, to_list, to_index, count, player)
+ experimental.print_to_everything(player:get_player_name().." moved items")
+ end,
+ on_put = function(inv, listname, index, stack, player)
+ experimental.print_to_everything(player:get_player_name().." put items")
+ end,
+ on_take = function(inv, listname, index, count, player)
+ experimental.print_to_everything(player:get_player_name().." took items")
+ end,
+})
inv:set_size("main", 4*6)
inv:add_item("main", "experimental:tester_tool_1")
inv:add_item("main", "experimental:tnt 5")