minetest.register_node("holidaychests:halloween_chest", {
description = "Halloween Chest",
tiles = {"holidaychests_halloween_chest_top.png", "holidaychests_halloween_chest_top.png", "holidaychests_halloween_chest_side.png",
"holidaychests_halloween_chest_side.png", "holidaychests_halloween_chest_side.png", "holidaychests_halloween_chest_front.png"},
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"size[8,9]"..
"list[current_name;main;0,0;8,4;]"..
"list[current_player;main;0,5;8,4;]")
meta:set_string("infotext", "Halloween Chest")
local inv = meta:get_inventory()
inv:set_size("main", 9*4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
return inv:default_torch("main")
end,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", player:get_player_name()..
" moves stuff in chest at "..minetest.pos_to_string(pos))
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name()..
" moves stuff to chest at "..minetest.pos_to_string(pos))
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name()..
" takes stuff from chest at "..minetest.pos_to_string(pos))
light_source = LIGHT_MAX-1
end,
})
local function has_locked_chest_privilege(meta, player)
if player:get_player_name() ~= meta:get_string("owner") then
return false
end
return true
end
Chinchow wrote:Ok I tried making a mod for Halloween when this Idea came to me but the mod won't work and I don't know why
Here is the code:
minetest.register_node("holidaychests:halloween_chest", {
description = "Halloween Chest",
tiles = {"holidaychests_halloween_chest_top.png", "holidaychests_halloween_chest_top.png", "holidaychests_halloween_chest_side.png",
"holidaychests_halloween_chest_side.png", "holidaychests_halloween_chest_side.png", "holidaychests_halloween_chest_front.png"},
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
-- drop = 'default:torch',
drop = {max_items = 2,
items = {
{
items = {'default:torch'},
},
{
items = {'holidaychests:halloween_chest'},
},
}
},
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"size[8,9]"..
"list[current_name;main;0,0;8,4;]"..
"list[current_player;main;0,5;8,4;]")
meta:set_string("infotext", "Halloween Chest")
local inv = meta:get_inventory()
inv:set_size("main", 9*4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
--return inv:default_torch("main")
return inv:is_empty("main")
end,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", player:get_player_name()..
" moves stuff in chest at "..minetest.pos_to_string(pos))
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name()..
" moves stuff to chest at "..minetest.pos_to_string(pos))
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name()..
" takes stuff from chest at "..minetest.pos_to_string(pos))
light_source = LIGHT_MAX-1
end,
})
local function has_locked_chest_privilege(meta, player)
if player:get_player_name() ~= meta:get_string("owner") then
return false
end
return true
end
light_source = LIGHT_MAX-1end,Users browsing this forum: No registered users and 6 guests