25 lines
923 B
Lua
25 lines
923 B
Lua
reward_inv.treasure_chest_can_dig = function(pos, player)
|
|
-- the treasure chest can be digged if no reward_id is assigned
|
|
local meta = minetest.get_meta(pos)
|
|
local reward_id = meta:get_string("reward_id")
|
|
return (not(reward_id) or reward_id == "")
|
|
and default.can_interact_with_node(player, pos)
|
|
end
|
|
|
|
|
|
reward_inv.treasure_chest_on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
|
if(not(clicker)) then
|
|
return
|
|
end
|
|
local meta = minetest.get_meta(pos)
|
|
local reward_id = meta:get_string("reward_id")
|
|
local pname = clicker:get_player_name()
|
|
-- this may also help to identify the chest (or NPC) the player
|
|
-- wants to create a new inventory for
|
|
reward_inv.clicked_at_chest[pname] = pos
|
|
-- the player has discovered/unlocked this reward
|
|
reward_inv.grant_access(pname, reward_id)
|
|
-- the actual inventory is a detached one; show the formspec
|
|
reward_inv.show_reward_fs(clicker, reward_id)
|
|
end
|