Fix frames.
I actually broke most insertions into frames. This is much more careful, and it now tells the player that something just can not be put in a frame. Tested with breakable nodes, tools, and torch. The frames autolock on things like flowers. Attempting to unlock a frame yields a message explaining why some can not be unlocked.
This commit is contained in:
parent
05d24a6c24
commit
9dbf15df24
@ -30,17 +30,11 @@ local function frame_on_punch(pos, node, puncher, pointed_thing)
|
|||||||
minetest.check_player_privs(puncher, "server")) then
|
minetest.check_player_privs(puncher, "server")) then
|
||||||
|
|
||||||
local idef = minetest.registered_nodes[def.frame_contents]
|
local idef = minetest.registered_nodes[def.frame_contents]
|
||||||
if not idef then
|
if idef and not(idef.groups.hand or idef.groups.axe or idef.groups.shovel or idef.groups.pickaxe or idef.groups.torch) then
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
if not(idef.groups.hand or idef.groups.axe or idef.groups.shovel or idef.groups.pickaxe) then
|
|
||||||
meta:set_int("locked", 1)
|
meta:set_int("locked", 1)
|
||||||
minetest.chat_send_player(name, "Item frame contains item the player can not obtain, is therefore locked")
|
minetest.chat_send_player(name, "Item frame contains item the player can not obtain, therefore remains locked")
|
||||||
return false
|
return false
|
||||||
end
|
elseif meta:get_int("locked") == 1 then
|
||||||
|
|
||||||
if meta:get_int("locked") == 1 then
|
|
||||||
meta:set_int("locked", 0)
|
meta:set_int("locked", 0)
|
||||||
minetest.chat_send_player(name, "Item frame is now unlocked")
|
minetest.chat_send_player(name, "Item frame is now unlocked")
|
||||||
return false
|
return false
|
||||||
@ -102,13 +96,16 @@ local function frame_on_rightclick(pos, node, clicker, itemstack, pointed_thing)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local idef = minetest.registered_nodes[nodename]
|
local name = "frame:" .. nodename:gsub(":", "_")
|
||||||
if not idef then
|
local def = minetest.registered_nodes[name]
|
||||||
return false
|
if not def then
|
||||||
|
minetest.chat_send_player(clicker:get_player_name(), "This item can not be inserted in a frame.")
|
||||||
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if not(idef.groups.hand or idef.groups.axe or idef.groups.shovel or idef.groups.pickaxe) then
|
local idef = minetest.registered_nodes[nodename]
|
||||||
|
if idef and not(idef.groups.hand or idef.groups.axe or idef.groups.shovel or idef.groups.pickaxe or idef.groups.torch) then
|
||||||
meta:set_int("locked", 1)
|
meta:set_int("locked", 1)
|
||||||
minetest.chat_send_player(clicker:get_player_name(), "Item inserted into frame is not obtainable, frame locked")
|
minetest.chat_send_player(clicker:get_player_name(), "Item inserted into frame is not obtainable, frame locked")
|
||||||
end
|
end
|
||||||
@ -122,12 +119,6 @@ local function frame_on_rightclick(pos, node, clicker, itemstack, pointed_thing)
|
|||||||
meta:set_string("metadata", metadata)
|
meta:set_string("metadata", metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
local name = "frame:" .. nodename:gsub(":", "_")
|
|
||||||
local def = minetest.registered_nodes[name]
|
|
||||||
if not def then
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
|
|
||||||
--minetest.sound_play(def.sounds.place, {pos = pos})
|
--minetest.sound_play(def.sounds.place, {pos = pos})
|
||||||
minetest.swap_node(pos, {name = name, param2 = node.param2})
|
minetest.swap_node(pos, {name = name, param2 = node.param2})
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user