Compare commits

...

5 Commits

Author SHA1 Message Date
Vanessa Dannenberg 1327cb2112 make sure digger is valid before checking for creative
(else assume survival)
2021-07-15 15:14:52 -04:00
OgelGames c08eb3452f allow writing `#` on signs 2021-06-05 17:06:08 +10:00
Vanessa Dannenberg 3ee06f9ba2 protect against nil player on rightclick
(some mods' machines don't supply a valid player object)
2021-06-03 08:40:45 -04:00
Vanessa Dannenberg 02c19e89d9 don't try to run the glow code if the sign's being punched by a machine
that doesn't use a fake player object e.g. basic_machines
2021-05-29 08:03:50 -04:00
Vanessa Dannenberg 8b6f5e23a6 fix typo 2021-05-28 13:24:01 -04:00
2 changed files with 10 additions and 7 deletions

View File

@ -22,7 +22,7 @@ That said, there are some basic text formatting options:
Writing "^" followed by a letter "a" through "h" will produce double-wide versions of these arrows, in the same order. These wide arrows occupy 0x89 to 0x91 in the character set. Writing "^" followed by a letter "a" through "h" will produce double-wide versions of these arrows, in the same order. These wide arrows occupy 0x89 to 0x91 in the character set.
* A color may be specified in the sign text by using "#" followed by a single hexadcimal digit (0-9 or a-f). These colors come from the standard Linux/IRC/CGA color set, and are shown in the sign's formspec. Any color change will remain in effect until changed again, or until the next line break. Any number of color changes in any arbitrary arrangement is allowed. * A color may be specified in the sign text by using "#" followed by a single hexadcimal digit (0-9 or a-f). These colors come from the standard Linux/IRC/CGA color set, and are shown in the sign's formspec. Any color change will remain in effect until changed again, or until the next line break. Any number of color changes in any arbitrary arrangement is allowed. To write "#" on a sign, write "##".
* Most writable signs can display double-wide text by flipping a switch in the sign's formspec. * Most writable signs can display double-wide text by flipping a switch in the sign's formspec.

15
api.lua
View File

@ -232,7 +232,7 @@ function signs_lib.spawn_entity(pos, texture, glow)
end end
if glow ~= "" then if glow ~= "" then
obj:set_properties({glow = tonumber(glow * 5)) obj:set_properties( {glow = tonumber(glow * 5)} )
end end
if yaw then if yaw then
@ -555,8 +555,9 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
end end
end end
local c = word:sub(i, i) local c = word:sub(i, i)
if c == "#" then local c2 = word:sub(i+1, i+1)
local cc = tonumber(word:sub(i+1, i+1), 16) if c == "#" and c2 ~= "#" then
local cc = tonumber(c2, 16)
if cc then if cc then
i = i + 1 i = i + 1
cur_color = cc cur_color = cc
@ -707,7 +708,7 @@ end
function signs_lib.rightclick_sign(pos, node, player, itemstack, pointed_thing) function signs_lib.rightclick_sign(pos, node, player, itemstack, pointed_thing)
if not signs_lib.can_modify(pos, player) then return end if not player or not signs_lib.can_modify(pos, player) then return end
player:get_meta():set_string("signslib:pos", minetest.pos_to_string(pos)) player:get_meta():set_string("signslib:pos", minetest.pos_to_string(pos))
minetest.show_formspec(player:get_player_name(), "signs_lib:sign", get_sign_formspec(pos, node.name)) minetest.show_formspec(player:get_player_name(), "signs_lib:sign", get_sign_formspec(pos, node.name))
@ -942,12 +943,14 @@ function signs_lib.register_fence_with_sign()
end end
local use_glow = function(pos, node, puncher, pointed_thing) local use_glow = function(pos, node, puncher, pointed_thing)
signs_lib.glow(pos, node, puncher) if puncher then -- if e.g. a machine tries to punch; only a real person should change the lighting
signs_lib.glow(pos, node, puncher)
end
return signs_lib.update_sign(pos) return signs_lib.update_sign(pos)
end end
local glow_drops = function(pos, oldnode, oldmetadata, digger) local glow_drops = function(pos, oldnode, oldmetadata, digger)
if minetest.is_creative_enabled(digger:get_player_name()) then if digger and minetest.is_creative_enabled(digger:get_player_name()) then
return return
end end
local glow = oldmetadata and oldmetadata.fields and oldmetadata.fields.glow local glow = oldmetadata and oldmetadata.fields and oldmetadata.fields.glow