forked from mtcontrib/signs_lib
rework sign type and ownership checks
minor tweaks elsewhere to fit those changes got rid of a couple of obsolete MT/mtg version checks
This commit is contained in:
parent
dfa47c2519
commit
1d33e15ea5
64
init.lua
64
init.lua
@ -169,9 +169,15 @@ signs_lib.sign_post_model = {
|
|||||||
|
|
||||||
-- the list of standard sign nodes
|
-- the list of standard sign nodes
|
||||||
|
|
||||||
|
local default_sign = "default:sign_wall_wood"
|
||||||
|
local default_sign_image = "default_sign_wood.png"
|
||||||
|
|
||||||
|
local default_sign_metal = "default:sign_wall_steel"
|
||||||
|
local default_sign_metal_image = "default_sign_steel.png"
|
||||||
|
|
||||||
signs_lib.sign_node_list = {
|
signs_lib.sign_node_list = {
|
||||||
"default:sign_wall_wood",
|
default_sign,
|
||||||
"default:sign_wall_steel",
|
default_sign_metal,
|
||||||
"signs:sign_yard",
|
"signs:sign_yard",
|
||||||
"signs:sign_hanging",
|
"signs:sign_hanging",
|
||||||
"signs:sign_wall_green",
|
"signs:sign_wall_green",
|
||||||
@ -185,20 +191,6 @@ signs_lib.sign_node_list = {
|
|||||||
"locked_sign:sign_wall_locked"
|
"locked_sign:sign_wall_locked"
|
||||||
}
|
}
|
||||||
|
|
||||||
local default_sign, default_sign_image
|
|
||||||
|
|
||||||
-- Default sign was renamed in 0.4.14. Support both & old versions.
|
|
||||||
if minetest.registered_nodes["default:sign_wall_wood"] then
|
|
||||||
default_sign = "default:sign_wall_wood"
|
|
||||||
default_sign_image = "default_sign_wood.png"
|
|
||||||
else
|
|
||||||
default_sign = "default:sign_wall"
|
|
||||||
default_sign_image = "default_sign_wall.png"
|
|
||||||
end
|
|
||||||
|
|
||||||
default_sign_metal = "default:sign_wall_steel"
|
|
||||||
default_sign_metal_image = "default_sign_steel.png"
|
|
||||||
|
|
||||||
--table copy
|
--table copy
|
||||||
|
|
||||||
function signs_lib.table_copy(t)
|
function signs_lib.table_copy(t)
|
||||||
@ -685,6 +677,7 @@ function signs_lib.determine_sign_type(itemstack, placer, pointed_thing, locked)
|
|||||||
z = above.z - placer_pos.z
|
z = above.z - placer_pos.z
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
local finalpos = above
|
||||||
|
|
||||||
local fdir = minetest.dir_to_facedir(dir)
|
local fdir = minetest.dir_to_facedir(dir)
|
||||||
local pt_name = minetest.get_node(under).name
|
local pt_name = minetest.get_node(under).name
|
||||||
@ -692,23 +685,23 @@ function signs_lib.determine_sign_type(itemstack, placer, pointed_thing, locked)
|
|||||||
|
|
||||||
if fences_with_sign[pt_name] and signname == default_sign then
|
if fences_with_sign[pt_name] and signname == default_sign then
|
||||||
minetest.add_node(under, {name = fences_with_sign[pt_name], param2 = fdir})
|
minetest.add_node(under, {name = fences_with_sign[pt_name], param2 = fdir})
|
||||||
|
finalpos = under
|
||||||
elseif wdir == 0 and signname == default_sign then
|
elseif wdir == 0 and signname == default_sign then
|
||||||
minetest.add_node(above, {name = "signs:sign_hanging", param2 = fdir})
|
minetest.add_node(above, {name = "signs:sign_hanging", param2 = fdir})
|
||||||
elseif wdir == 1 and signname == default_sign then
|
elseif wdir == 1 and signname == default_sign then
|
||||||
minetest.add_node(above, {name = "signs:sign_yard", param2 = fdir})
|
minetest.add_node(above, {name = "signs:sign_yard", param2 = fdir})
|
||||||
elseif signname == default_sign_metal then
|
elseif signname == default_sign
|
||||||
|
or signname == default_sign_metal
|
||||||
|
or signname == "locked_sign:sign_wall_locked" then
|
||||||
minetest.add_node(above, {name = signname, param2 = wdir })
|
minetest.add_node(above, {name = signname, param2 = wdir })
|
||||||
elseif signname ~= default_sign
|
else
|
||||||
and signname ~= default_sign_metal
|
minetest.add_node(above, {name = signname, param2 = fdir}) -- it must be a colored metal sign
|
||||||
and signname ~= "locked_sign:sign_wall_locked" then -- it's a signs_lib colored metal wall sign.
|
end
|
||||||
minetest.add_node(above, {name = signname, param2 = fdir})
|
|
||||||
else -- it must be a default or locked wooden wall sign
|
if locked then
|
||||||
minetest.add_node(above, {name = signname, param2 = wdir }) -- note it's wallmounted here!
|
local meta = minetest.get_meta(finalpos)
|
||||||
if locked then
|
local owner = placer:get_player_name()
|
||||||
local meta = minetest.get_meta(above)
|
meta:set_string("owner", owner)
|
||||||
local owner = placer:get_player_name()
|
|
||||||
meta:set_string("owner", owner)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if not signs_lib.expect_infinite_stacks then
|
if not signs_lib.expect_infinite_stacks then
|
||||||
@ -918,7 +911,7 @@ minetest.register_node(":locked_sign:sign_wall_locked", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- default metal sign, if defined
|
-- default metal sign
|
||||||
|
|
||||||
minetest.register_node(":"..default_sign_metal, {
|
minetest.register_node(":"..default_sign_metal, {
|
||||||
description = S("Sign"),
|
description = S("Sign"),
|
||||||
@ -932,12 +925,11 @@ minetest.register_node(":"..default_sign_metal, {
|
|||||||
node_box = signs_lib.regular_wall_sign_model.nodebox,
|
node_box = signs_lib.regular_wall_sign_model.nodebox,
|
||||||
tiles = {"signs_wall_sign_metal.png"},
|
tiles = {"signs_wall_sign_metal.png"},
|
||||||
groups = sign_groups,
|
groups = sign_groups,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
return signs_lib.determine_sign_type(itemstack, placer, pointed_thing)
|
return signs_lib.determine_sign_type(itemstack, placer, pointed_thing, true)
|
||||||
end,
|
end,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
signs_lib.construct_sign(pos)
|
signs_lib.construct_sign(pos, true)
|
||||||
end,
|
end,
|
||||||
on_destruct = function(pos)
|
on_destruct = function(pos)
|
||||||
signs_lib.destruct_sign(pos)
|
signs_lib.destruct_sign(pos)
|
||||||
@ -955,6 +947,13 @@ minetest.register_node(":"..default_sign_metal, {
|
|||||||
on_punch = function(pos, node, puncher)
|
on_punch = function(pos, node, puncher)
|
||||||
signs_lib.update_sign(pos,nil,nil,node)
|
signs_lib.update_sign(pos,nil,nil,node)
|
||||||
end,
|
end,
|
||||||
|
can_dig = function(pos, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local owner = meta:get_string("owner")
|
||||||
|
local pname = player:get_player_name()
|
||||||
|
return pname == owner or pname == minetest.settings:get("name")
|
||||||
|
or minetest.check_player_privs(pname, {sign_editor=true})
|
||||||
|
end,
|
||||||
on_rotate = function(pos, node, user, mode)
|
on_rotate = function(pos, node, user, mode)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
@ -966,7 +965,6 @@ minetest.register_node(":"..default_sign_metal, {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- metal, colored signs
|
-- metal, colored signs
|
||||||
if enable_colored_metal_signs then
|
if enable_colored_metal_signs then
|
||||||
-- array : color, translated color, default text color
|
-- array : color, translated color, default text color
|
||||||
|
Loading…
Reference in New Issue
Block a user