mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2025-04-23 07:35:16 +02:00
Check protection earlier in signs' on_rightclick
This commit is contained in:
parent
607a0295f6
commit
85dcaa0f61
3 changed files with 25 additions and 22 deletions
mods/ITEMS/mcl_signs
|
@ -148,13 +148,11 @@ local function generate_line(codepoints, ypos)
|
|||
|
||||
for _, code in ipairs(codepoints) do
|
||||
local file = "_rc"
|
||||
if charmap[utf8.char(code)] then
|
||||
file = charmap[utf8.char(code)]
|
||||
end
|
||||
if file then
|
||||
width = width + printed_char_width
|
||||
table.insert(parsed, file)
|
||||
end
|
||||
local char = utf8.char(code)
|
||||
if charmap[char] then file = charmap[char] end
|
||||
|
||||
width = width + printed_char_width
|
||||
table.insert(parsed, file)
|
||||
end
|
||||
|
||||
width = width - 1
|
||||
|
@ -346,6 +344,8 @@ function sign_tpl.on_place(itemstack, placer, pointed_thing)
|
|||
end
|
||||
|
||||
function sign_tpl.on_rightclick(pos, _, clicker, itemstack)
|
||||
if mcl_util.check_position_protection(pos, clicker) then return end
|
||||
|
||||
local iname = itemstack:get_name()
|
||||
if iname == "mcl_mobitems:glow_ink_sac" then
|
||||
local data = get_signdata(pos)
|
||||
|
@ -365,16 +365,20 @@ function sign_tpl.on_rightclick(pos, _, clicker, itemstack)
|
|||
color = DEFAULT_COLOR,
|
||||
})
|
||||
update_sign(pos)
|
||||
if not core.is_creative_enabled(clicker:get_player_name()) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
elseif iname:sub(1, 8) == "mcl_dye:" then
|
||||
local color = iname:sub(9)
|
||||
set_signmeta(pos, {color = DYE_TO_COLOR[color]})
|
||||
local dye = iname:sub(9)
|
||||
set_signmeta(pos, {color = DYE_TO_COLOR[dye]})
|
||||
update_sign(pos)
|
||||
if not core.is_creative_enabled(clicker:get_player_name()) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
elseif not mcl_util.check_position_protection(pos, clicker) then
|
||||
else
|
||||
show_formspec(clicker, pos)
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
local old_rotnames = {}
|
||||
|
||||
-- these are the "rotation strings" of the old sign rotation scheme
|
||||
local rotkeys = {
|
||||
"22_5",
|
||||
|
@ -57,18 +55,18 @@ for old, new in pairs(signs) do
|
|||
end
|
||||
|
||||
local function upgrade_sign_meta(pos)
|
||||
local m = core.get_meta(pos)
|
||||
local color = m:get_string("mcl_signs:text_color")
|
||||
local glow = m:get_string("mcl_signs:glowing_sign")
|
||||
local meta = core.get_meta(pos)
|
||||
local color = meta:get_string("mcl_signs:text_color")
|
||||
local glow = meta:get_string("mcl_signs:glowing_sign")
|
||||
if color ~= "" then
|
||||
m:set_string("color", color)
|
||||
m:set_string("mcl_signs:text_color", "")
|
||||
meta:set_string("color", color)
|
||||
meta:set_string("mcl_signs:text_color", "")
|
||||
end
|
||||
if glow == "true" then
|
||||
m:set_string("glow", glow)
|
||||
meta:set_string("glow", glow)
|
||||
end
|
||||
if glow ~= "" then
|
||||
m:set_string("mcl_signs:glowing_sign", "")
|
||||
meta:set_string("mcl_signs:glowing_sign", "")
|
||||
end
|
||||
mcl_signs.get_text_entity(pos, true) -- the 2nd "true" arg means deleting the entity for respawn
|
||||
end
|
||||
|
@ -76,13 +74,13 @@ end
|
|||
local function upgrade_sign_rot(pos, node)
|
||||
local numsign = false
|
||||
|
||||
for _,v in ipairs(rotkeys) do
|
||||
for _, v in ipairs(rotkeys) do
|
||||
if old_rotsigns[node.name] then
|
||||
node.name = old_rotsigns[node.name]
|
||||
node.param2 = nidp2_degrotate[v][node.param2 + 1]
|
||||
numsign = true
|
||||
elseif node.name:find(v) then
|
||||
node.name = node.name:gsub(v,"")
|
||||
node.name = node.name:gsub(v, "")
|
||||
node.param2 = nidp2_degrotate[v][node.param2 + 1]
|
||||
numsign = true
|
||||
end
|
||||
|
@ -117,6 +115,7 @@ core.register_lbm({
|
|||
action = upgrade_sign_rot,
|
||||
})
|
||||
|
||||
local old_rotnames = {}
|
||||
for k,_ in pairs(old_rotsigns) do table.insert(old_rotnames, k) end
|
||||
for k,_ in pairs(old_standingsigns) do table.insert(old_rotnames, k) end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ local utf8 = dofile(modpath .. DIR_DELIM .. "utf8.lua")
|
|||
|
||||
-- Character map (see API.md for reference)
|
||||
local charmap = {}
|
||||
for line in io.lines(modpath .. "/characters.tsv") do
|
||||
for line in io.lines(modpath .. DIR_DELIM .. "characters.tsv") do
|
||||
local split = line:split("\t")
|
||||
if #split == 3 then
|
||||
local char, img, _ = split[1], split[2], split[3] -- 3rd is ignored, reserved for width
|
||||
|
|
Loading…
Add table
Reference in a new issue