develop #28
6 changed files with 106 additions and 90 deletions
|
@ -33,6 +33,7 @@ minetest.register_node("claycrafter:glass_of_water", {
|
||||||
inventory_image = "claycrafter_glass_of_water_inv.png",
|
inventory_image = "claycrafter_glass_of_water_inv.png",
|
||||||
wield_image = "claycrafter_glass_of_water.png",
|
wield_image = "claycrafter_glass_of_water.png",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
use_texture_alpha = true,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
|
|
|
@ -457,7 +457,8 @@ local del_display = function(pos)
|
||||||
|
|
||||||
for _, v in ipairs(objects) do
|
for _, v in ipairs(objects) do
|
||||||
|
|
||||||
if v:get_luaentity().name == "protector:display" then
|
if v and v:get_luaentity()
|
||||||
|
and v:get_luaentity().name == "protector:display" then
|
||||||
v:remove()
|
v:remove()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -78,17 +78,11 @@ In this text, common terms such as `pos`, `node`, or `placer`/`digger` will not
|
||||||
|
|
||||||
Default: `signs_lib.after_place_node`
|
Default: `signs_lib.after_place_node`
|
||||||
|
|
||||||
* `on_rightclick = function(pos)`
|
* `on_rightclick = function(pos, node, player, itemstack, pointed_thing)`
|
||||||
|
|
||||||
See below under "Main functions".
|
See below under "Main functions".
|
||||||
|
|
||||||
Default: `signs_lib.construct_sign`
|
Default: `signs_lib.rightclick_sign`
|
||||||
|
|
||||||
* `on_construct = function(pos)`
|
|
||||||
|
|
||||||
See below under "Main functions".
|
|
||||||
|
|
||||||
Default: `signs_lib.construct_sign`
|
|
||||||
|
|
||||||
* `on_destruct = function(pos)`
|
* `on_destruct = function(pos)`
|
||||||
|
|
||||||
|
@ -96,12 +90,6 @@ In this text, common terms such as `pos`, `node`, or `placer`/`digger` will not
|
||||||
|
|
||||||
Default: `signs_lib.destruct_sign`
|
Default: `signs_lib.destruct_sign`
|
||||||
|
|
||||||
* `on_receive_fields = function(pos, formname, fields, sender)`
|
|
||||||
|
|
||||||
See below under "Main functions".
|
|
||||||
|
|
||||||
Default: `signs_lib.receive_fields`
|
|
||||||
|
|
||||||
* `on_punch = function(pos)`
|
* `on_punch = function(pos)`
|
||||||
|
|
||||||
See below under "Main functions".
|
See below under "Main functions".
|
||||||
|
@ -258,18 +246,14 @@ signs_lib.register_sign("basic_signs:sign_wall_glass", {
|
||||||
|
|
||||||
* `locked`: if set to **true**, the sign's meta will be tweaked to indicate its ownership by the `placer`.
|
* `locked`: if set to **true**, the sign's meta will be tweaked to indicate its ownership by the `placer`.
|
||||||
|
|
||||||
* `signs_lib.construct_sign(pos)`
|
* `signs_lib.rightclick_sign(pos, node, player, itemstack, pointed_thing)`
|
||||||
|
|
||||||
Sets up the sign's formspec and infotext overlay.
|
Open the default sign formspec, if the player has the `signslib_edit` privilege.
|
||||||
|
|
||||||
* `signs_lib.destruct_sign(pos)`
|
* `signs_lib.destruct_sign(pos)`
|
||||||
|
|
||||||
Deletes the sign's entity, if any, when the sign is dug.
|
Deletes the sign's entity, if any, when the sign is dug.
|
||||||
|
|
||||||
* `signs_lib.receive_fields(pos, formname, fields, sender)`
|
|
||||||
|
|
||||||
This handles the text input and wide font on/off switch, logging any actions the user takes. Bails-out silently if the user is not allowed to edit the sign. See the standard Minetest lua_api.txt for details.
|
|
||||||
|
|
||||||
* `signs_lib.update_sign(pos, fields)`
|
* `signs_lib.update_sign(pos, fields)`
|
||||||
|
|
||||||
If the sign's writable, this deletes any sign-related entities in the sign's node space, spawns a new one, and renders whatever text is in the sign's meta.
|
If the sign's writable, this deletes any sign-related entities in the sign's node space, spawns a new one, and renders whatever text is in the sign's meta.
|
||||||
|
@ -352,7 +336,7 @@ Supplying one or both of the following in the pole/post node's definition will c
|
||||||
If supplied, this function will be run when the mod is looking for a normal vertical pole/post. Useful if the target node's orientation and/or shape determine what sides a sign can attach to. For example, [Pipeworks](https://forum.minetest.net/viewtopic.php?pid=27794) uses this to figure out if a sign can be attached to a tube or pipe, depending on the tube's/pipe's number of junctions, and on its orientation and that of the placed sign.
|
If supplied, this function will be run when the mod is looking for a normal vertical pole/post. Useful if the target node's orientation and/or shape determine what sides a sign can attach to. For example, [Pipeworks](https://forum.minetest.net/viewtopic.php?pid=27794) uses this to figure out if a sign can be attached to a tube or pipe, depending on the tube's/pipe's number of junctions, and on its orientation and that of the placed sign.
|
||||||
|
|
||||||
* `def`: the placed sign's node defintion
|
* `def`: the placed sign's node defintion
|
||||||
* `pole_pos`: the target node's position
|
* `pole_pos`: the target node's position
|
||||||
* `pole_node`: the target node itself
|
* `pole_node`: the target node itself
|
||||||
* `pole_def`: its node definition
|
* `pole_def`: its node definition
|
||||||
|
|
||||||
|
|
|
@ -55,3 +55,9 @@ At present, only one command is defined:
|
||||||
This will read through the list of currently-loaded blocks known to contain one or more signs, delete all entities found in each sign's node space, and respawn and re-render each from scratch.
|
This will read through the list of currently-loaded blocks known to contain one or more signs, delete all entities found in each sign's node space, and respawn and re-render each from scratch.
|
||||||
|
|
||||||
The list of loaded, sign-bearing blocks is created/populated by an LBM (and trimmed by this command if any listed blocks are found to have been unloaded).
|
The list of loaded, sign-bearing blocks is created/populated by an LBM (and trimmed by this command if any listed blocks are found to have been unloaded).
|
||||||
|
|
||||||
|
## Privileges
|
||||||
|
|
||||||
|
* `signslib_edit`
|
||||||
|
|
||||||
|
Allows to rotate signs and to open (and consequently edit) any default sign formspec.
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
local S = signs_lib.gettext
|
local S = signs_lib.gettext
|
||||||
|
|
||||||
|
local function get_sign_formspec() end
|
||||||
|
|
||||||
signs_lib.lbm_restore_nodes = {}
|
signs_lib.lbm_restore_nodes = {}
|
||||||
signs_lib.old_fenceposts = {}
|
signs_lib.old_fenceposts = {}
|
||||||
signs_lib.old_fenceposts_replacement_signs = {}
|
signs_lib.old_fenceposts_replacement_signs = {}
|
||||||
|
@ -345,10 +347,10 @@ local function file_exists(name, return_handle, mode)
|
||||||
if (return_handle) then
|
if (return_handle) then
|
||||||
return f
|
return f
|
||||||
end
|
end
|
||||||
io.close(f)
|
io.close(f)
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -552,7 +554,7 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
||||||
table.insert(texture, (":%d,%d=%s"):format(xpos + ch.off, ypos, ch.tex))
|
table.insert(texture, (":%d,%d=%s"):format(xpos + ch.off, ypos, ch.tex))
|
||||||
end
|
end
|
||||||
table.insert(
|
table.insert(
|
||||||
texture,
|
texture,
|
||||||
(":%d,%d="):format(xpos + word.w, ypos) .. char_tex(font_name, " ")
|
(":%d,%d="):format(xpos + word.w, ypos) .. char_tex(font_name, " ")
|
||||||
)
|
)
|
||||||
xpos = xpos + word.w + cwidth_tab[" "]
|
xpos = xpos + word.w + cwidth_tab[" "]
|
||||||
|
@ -619,31 +621,13 @@ function signs_lib.split_lines_and_words(text)
|
||||||
return lines
|
return lines
|
||||||
end
|
end
|
||||||
|
|
||||||
function signs_lib.construct_sign(pos)
|
function signs_lib.rightclick_sign(pos, node, player, itemstack, pointed_thing)
|
||||||
local form = "size[6,4]"..
|
|
||||||
"textarea[0,-0.3;6.5,3;text;;${text}]"..
|
|
||||||
"background[-0.5,-0.5;7,5;signs_lib_sign_bg.jpg]"
|
|
||||||
local node = minetest.get_node(pos)
|
|
||||||
local def = minetest.registered_items[node.name]
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
|
|
||||||
if def.allow_widefont then
|
local playername = player:get_player_name()
|
||||||
local state = "off"
|
if not minetest.check_player_privs(playername, {signslib_edit = true}) then return end
|
||||||
if meta:get_int("widefont") == 1 then state = "on" end
|
|
||||||
form = form.."label[1,3.4;Use wide font]"..
|
|
||||||
"image_button[1.1,3.7;1,0.6;signs_lib_switch_"..
|
|
||||||
state..".png;"..
|
|
||||||
state..";;;false;signs_lib_switch_interm.png]"..
|
|
||||||
"button_exit[3,3.4;2,1;ok;"..S("Write").."]"
|
|
||||||
else
|
|
||||||
form = form.."button_exit[2,3.4;2,1;ok;"..S("Write").."]"
|
|
||||||
end
|
|
||||||
|
|
||||||
meta:set_string("formspec", form)
|
player:get_meta():set_string("signslib:pos", minetest.pos_to_string(pos))
|
||||||
local i = meta:get_string("infotext")
|
minetest.show_formspec(playername, "signs_lib:sign", get_sign_formspec(pos, node.name))
|
||||||
if i == "" then -- it wasn't even set, so set it.
|
|
||||||
meta:set_string("infotext", "")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function signs_lib.destruct_sign(pos)
|
function signs_lib.destruct_sign(pos)
|
||||||
|
@ -663,6 +647,11 @@ end
|
||||||
function signs_lib.update_sign(pos, fields)
|
function signs_lib.update_sign(pos, fields)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
|
-- legacy udpate
|
||||||
|
if meta:get_string("formspec") ~= "" then
|
||||||
|
meta:set_string("formspec", "")
|
||||||
|
end
|
||||||
|
|
||||||
local text = fields and fields.text or meta:get_string("text")
|
local text = fields and fields.text or meta:get_string("text")
|
||||||
text = trim_input(text)
|
text = trim_input(text)
|
||||||
|
|
||||||
|
@ -675,54 +664,19 @@ function signs_lib.update_sign(pos, fields)
|
||||||
signs_lib.set_obj_text(pos, text)
|
signs_lib.set_obj_text(pos, text)
|
||||||
end
|
end
|
||||||
|
|
||||||
function signs_lib.receive_fields(pos, formname, fields, sender)
|
|
||||||
|
|
||||||
if not fields or not signs_lib.can_modify(pos, sender) then return end
|
|
||||||
|
|
||||||
if fields.text and fields.ok then
|
|
||||||
minetest.log("action", S("@1 wrote \"@2\" to sign at @3",
|
|
||||||
(sender:get_player_name() or ""),
|
|
||||||
fields.text:gsub('\\', '\\\\'):gsub("\n", "\\n"),
|
|
||||||
minetest.pos_to_string(pos)
|
|
||||||
))
|
|
||||||
signs_lib.update_sign(pos, fields)
|
|
||||||
elseif fields.on or fields.off then
|
|
||||||
local node = minetest.get_node(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local change
|
|
||||||
|
|
||||||
if fields.on and meta:get_int("widefont") == 1 then
|
|
||||||
meta:set_int("widefont", 0)
|
|
||||||
change = true
|
|
||||||
elseif fields.off and meta:get_int("widefont") == 0 then
|
|
||||||
meta:set_int("widefont", 1)
|
|
||||||
change = true
|
|
||||||
end
|
|
||||||
if change then
|
|
||||||
minetest.log("action", S("@1 flipped the wide-font switch to \"@2\" at @3",
|
|
||||||
(sender:get_player_name() or ""),
|
|
||||||
(fields.on and "off" or "on"),
|
|
||||||
minetest.pos_to_string(pos)
|
|
||||||
))
|
|
||||||
signs_lib.construct_sign(pos)
|
|
||||||
signs_lib.update_sign(pos, fields)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function signs_lib.can_modify(pos, player)
|
function signs_lib.can_modify(pos, player)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
|
|
||||||
if minetest.is_protected(pos, playername) then
|
if minetest.is_protected(pos, playername) then
|
||||||
minetest.record_protection_violation(pos, playername)
|
minetest.record_protection_violation(pos, playername)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if owner == ""
|
if owner == ""
|
||||||
or playername == owner
|
or playername == owner
|
||||||
or (minetest.check_player_privs(playername, {sign_editor=true}))
|
or (minetest.check_player_privs(playername, {signslib_edit=true}))
|
||||||
or (playername == minetest.settings:get("name")) then
|
or (playername == minetest.settings:get("name")) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -887,10 +841,8 @@ function signs_lib.register_sign(name, raw_def)
|
||||||
def.after_place_node = raw_def.after_place_node or signs_lib.after_place_node
|
def.after_place_node = raw_def.after_place_node or signs_lib.after_place_node
|
||||||
|
|
||||||
if raw_def.entity_info then
|
if raw_def.entity_info then
|
||||||
def.on_rightclick = raw_def.on_rightclick or signs_lib.construct_sign
|
def.on_rightclick = raw_def.on_rightclick or signs_lib.rightclick_sign
|
||||||
def.on_construct = raw_def.on_construct or signs_lib.construct_sign
|
|
||||||
def.on_destruct = raw_def.on_destruct or signs_lib.destruct_sign
|
def.on_destruct = raw_def.on_destruct or signs_lib.destruct_sign
|
||||||
def.on_receive_fields = raw_def.on_receive_fields or signs_lib.receive_fields
|
|
||||||
def.on_punch = raw_def.on_punch or signs_lib.update_sign
|
def.on_punch = raw_def.on_punch or signs_lib.update_sign
|
||||||
def.number_of_lines = raw_def.number_of_lines or signs_lib.standard_lines
|
def.number_of_lines = raw_def.number_of_lines or signs_lib.standard_lines
|
||||||
def.horiz_scaling = raw_def.horiz_scaling or signs_lib.standard_hscale
|
def.horiz_scaling = raw_def.horiz_scaling or signs_lib.standard_hscale
|
||||||
|
@ -1184,3 +1136,74 @@ minetest.register_chatcommand("regen_signs", {
|
||||||
minetest.chat_send_player(player_name, "Finished.")
|
minetest.chat_send_player(player_name, "Finished.")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_privilege("signslib_edit", {})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- local functions
|
||||||
|
--
|
||||||
|
|
||||||
|
function get_sign_formspec(pos, nodename)
|
||||||
|
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local txt = meta:get_string("text")
|
||||||
|
|
||||||
|
local formspec = {
|
||||||
|
"size[6,4]",
|
||||||
|
"textarea[0,-0.3;6.5,3;text;;" .. txt .. "]",
|
||||||
|
"background[-0.5,-0.5;7,5;signs_lib_sign_bg.jpg]",
|
||||||
|
"button_exit[2,3.4;2,1;ok;" .. S("Write") .. "]"
|
||||||
|
}
|
||||||
|
|
||||||
|
if minetest.registered_nodes[nodename].allow_widefont then
|
||||||
|
local state = "off"
|
||||||
|
if meta:get_int("widefont") == 1 then state = "on" end
|
||||||
|
formspec[5] = "label[0.5,3.4;Use wide font]"
|
||||||
|
formspec[6] = "image_button[0.6,3.7;1,0.6;signs_lib_switch_" .. state .. ".png;"
|
||||||
|
.. state .. ";;;false;signs_lib_switch_interm.png]"
|
||||||
|
end
|
||||||
|
|
||||||
|
return table.concat(formspec, "")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
|
||||||
|
if formname ~= "signs_lib:sign" then return end
|
||||||
|
|
||||||
|
local pos_string = player:get_meta():get_string("signslib:pos")
|
||||||
|
local pos = minetest.string_to_pos(pos_string)
|
||||||
|
local playername = player:get_player_name()
|
||||||
|
|
||||||
|
if fields.text and fields.ok then
|
||||||
|
minetest.log("action", S("@1 wrote \"@2\" to sign at @3",
|
||||||
|
(playername or ""),
|
||||||
|
fields.text:gsub('\\', '\\\\'):gsub("\n", "\\n"),
|
||||||
|
pos_string
|
||||||
|
))
|
||||||
|
signs_lib.update_sign(pos, fields)
|
||||||
|
elseif fields.on or fields.off then
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local change
|
||||||
|
|
||||||
|
if fields.on and meta:get_int("widefont") == 1 then
|
||||||
|
meta:set_int("widefont", 0)
|
||||||
|
change = true
|
||||||
|
elseif fields.off and meta:get_int("widefont") == 0 then
|
||||||
|
meta:set_int("widefont", 1)
|
||||||
|
change = true
|
||||||
|
end
|
||||||
|
if change then
|
||||||
|
minetest.log("action", S("@1 flipped the wide-font switch to \"@2\" at @3",
|
||||||
|
(playername or ""),
|
||||||
|
(fields.on and "off" or "on"),
|
||||||
|
minetest.pos_to_string(pos)
|
||||||
|
))
|
||||||
|
minetest.show_formspec(playername, "signs_lib:sign", get_sign_formspec(pos, node.name))
|
||||||
|
signs_lib.update_sign(pos, fields)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
|
@ -9,6 +9,7 @@ This Minetest mod offers changeable player skins with a graphical interface for
|
||||||
- Skin change menu for sfinv (in minetest_game) and [unified_inventory](https://forum.minetest.net/viewtopic.php?t=12767)
|
- Skin change menu for sfinv (in minetest_game) and [unified_inventory](https://forum.minetest.net/viewtopic.php?t=12767)
|
||||||
- Skins change menu and command line using chat command /skinsdb (set | show | list | list private | list public | ui)
|
- Skins change menu and command line using chat command /skinsdb (set | show | list | list private | list public | ui)
|
||||||
- Supported by [smart_inventory](https://forum.minetest.net/viewtopic.php?t=16597) for the skin selection
|
- Supported by [smart_inventory](https://forum.minetest.net/viewtopic.php?t=16597) for the skin selection
|
||||||
|
- Supported by [i3](https://github.com/minetest-mods/i3) inventory mod
|
||||||
- Skin previews supported in selection
|
- Skin previews supported in selection
|
||||||
- Additional information for each skin
|
- Additional information for each skin
|
||||||
- Support for different skins lists: public and a per-player list are currently implemented
|
- Support for different skins lists: public and a per-player list are currently implemented
|
||||||
|
|
Loading…
Reference in a new issue