aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas--S <info@thomas-stangl.de>2018-02-01 16:54:55 +0100
committerThomas--S <info@thomas-stangl.de>2018-02-07 06:04:12 +0100
commitf3970f641eb60bf92492b6715084273cc1bceb74 (patch)
tree3542b64df78d8f8a8cb1365d08469fd843c0ed37
parent2acccd72610d240c115c17a63fe1d0b8a068406a (diff)
downloaddisplay_modpack-f3970f641eb60bf92492b6715084273cc1bceb74.tar.gz
display_modpack-f3970f641eb60bf92492b6715084273cc1bceb74.tar.bz2
display_modpack-f3970f641eb60bf92492b6715084273cc1bceb74.zip
Seperate signs API from signs definitions
Change modnames from *_lib to *_api
-rw-r--r--README.md5
-rw-r--r--display_api/API.md (renamed from display_lib/API.md)20
-rw-r--r--display_api/LICENSE.txt (renamed from display_lib/LICENSE.txt)0
-rw-r--r--display_api/README.md (renamed from display_lib/README.md)2
-rw-r--r--display_api/copyright.txt (renamed from display_lib/copyright.txt)0
-rw-r--r--display_api/depends.txt (renamed from display_lib/depends.txt)0
-rw-r--r--display_api/init.lua (renamed from display_lib/init.lua)44
-rw-r--r--font_api/API.md (renamed from font_lib/API.md)10
-rw-r--r--font_api/LICENSE.txt (renamed from font_lib/LICENSE.txt)0
-rw-r--r--font_api/README.md (renamed from font_lib/README.md)4
-rw-r--r--font_api/copyright.txt (renamed from font_lib/copyright.txt)0
-rw-r--r--font_api/depends.txt (renamed from font_lib/depends.txt)0
-rw-r--r--font_api/init.lua (renamed from font_lib/init.lua)47
-rw-r--r--font_api/settingtypes.txt (renamed from font_lib/settingtypes.txt)0
-rwxr-xr-xfont_api/tools/make_font_lua.sh (renamed from font_lib/tools/make_font_lua.sh)10
-rwxr-xr-xfont_api/tools/make_font_textures.sh (renamed from font_lib/tools/make_font_textures.sh)4
-rw-r--r--font_epilepsy/README.md4
-rw-r--r--font_epilepsy/depends.txt2
-rw-r--r--font_epilepsy/init.lua2
-rw-r--r--ontime_clocks/README.md2
-rw-r--r--ontime_clocks/common.lua2
-rw-r--r--ontime_clocks/depends.txt2
-rw-r--r--ontime_clocks/nodes.lua72
-rw-r--r--signs/common.lua173
-rw-r--r--signs/compatibility.lua6
-rw-r--r--signs/depends.txt5
-rw-r--r--signs/nodes.lua28
-rw-r--r--signs_api/LICENSE.txt166
-rw-r--r--signs_api/README.md29
-rw-r--r--signs_api/common.lua188
-rw-r--r--signs_api/copyright.txt10
-rw-r--r--signs_api/depends.txt4
-rw-r--r--signs_api/init.lua33
-rw-r--r--signs_api/intllib.lua45
-rw-r--r--signs_api/locale/fr.po49
-rw-r--r--signs_api/locale/ms.po46
-rw-r--r--signs_api/locale/template.pot31
-rwxr-xr-xsigns_api/tools/updatepo.sh25
-rw-r--r--signs_road/compatibility.lua6
-rw-r--r--signs_road/depends.txt6
-rw-r--r--signs_road/nodes.lua48
-rw-r--r--steles/depends.txt4
-rw-r--r--steles/nodes.lua20
43 files changed, 829 insertions, 325 deletions
diff --git a/README.md b/README.md
index def1949..f7f8146 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,10 @@
This modpack provides mods with dynamic display. Mods are :
-- **display_lib**: A library for adding display entities to nodes;
-- **font_lib**: A library for displaying fonts on entities;
+- **display_api**: A library for adding display entities to nodes;
+- **font_api**: A library for displaying fonts on entities;
- **ontime_clocks**: A mod providing clocks which display the ingame time;
+- **signs_api**: A library for the easy creation of signs;
- **signs**: A mod providing signs and direction signs displaying text;
- **signs_road**: A mod providing road signs displaying text;
- **steles**: A mod providing stone steles with text;
diff --git a/display_lib/API.md b/display_api/API.md
index 5c05999..b133c8a 100644
--- a/display_lib/API.md
+++ b/display_api/API.md
@@ -40,9 +40,9 @@ This is a helper to register entities used for display.
* Register display entities with `register_display_entity`
* Register node with :
- - `on_place`, `on_construct`, `on_destruct` and `on_rotate` callbacks using display_lib callbacks.
+ - `on_place`, `on_construct`, `on_destruct` and `on_rotate` callbacks using display_api callbacks.
 
- - `display_lib_node` group. This will make this node have their entities updated as soon as the mapblock is loaded (Useful after /clearobjects).
+ - `display_modpack_node` group. This will make this node have their entities updated as soon as the mapblock is loaded (Useful after /clearobjects).
 
- a `display_entities` field in node definition containing a entity name indexed table. See below for description of each display_entities fields.
@@ -51,12 +51,12 @@ This is a helper to register entities used for display.
`depth`, `right` and `heigh` : Entity position regarding to node facedir/wallmounted main axis. Values for these fields can be any number between -0.5 and 0.5 (default value is 0). Position 0,0,0 is the center of the node. `depth` goes from front (-0.5) to rear (0.5), `height` goes from bottom (-0.5) to top (0.5) and `right` goes from left (-0.5) to right (0.5).
-In order to avoid flickering text, it's better to have text a little behind node surface. A good spacing value is given by `display_lib.entity_spacing` variable.
+In order to avoid flickering text, it's better to have text a little behind node surface. A good spacing value is given by `display_api.entity_spacing` variable.
### Example
- display_lib.register_display_entity("mymod:entity1")
- display_lib.register_display_entity("mymod:entity2")
+ display_api.register_display_entity("mymod:entity1")
+ display_api.register_display_entity("mymod:entity2")
function my_display_update1(pos, objref)
objref:set_properties({ textures= {"mytexture1.png"},
@@ -72,7 +72,7 @@ In order to avoid flickering text, it's better to have text a little behind node
...
paramtype2 = "facedir",
...
- groups = { display_lib_node = 1, ... },
+ groups = { display_modpack_node = 1, ... },
...
display_entities = {
["mymod:entity1"] = {
@@ -83,9 +83,9 @@ In order to avoid flickering text, it's better to have text a little behind node
on_display_update = my_display_update2 },
},
...
- on_place = display_lib.on_place,
- on_construct = display_lib.on_construct,
- on_destruct = display_lib.on_destruct,
- on_rotate = display_lib.on_rotate,
+ on_place = display_api.on_place,
+ on_construct = display_api.on_construct,
+ on_destruct = display_api.on_destruct,
+ on_rotate = display_api.on_rotate,
...
})
diff --git a/display_lib/LICENSE.txt b/display_api/LICENSE.txt
index 341c30b..341c30b 100644
--- a/display_lib/LICENSE.txt
+++ b/display_api/LICENSE.txt
diff --git a/display_lib/README.md b/display_api/README.md
index 88a39ee..f51996d 100644
--- a/display_lib/README.md
+++ b/display_api/README.md
@@ -8,7 +8,7 @@ This library's purpose is to ease creation of nodes with one or more displays on
**License**: LPGL
-**API**: See [API.md](https://github.com/pyrollo/display_modpack/blob/master/display_lib/API.md) document please.
+**API**: See [API.md](https://github.com/pyrollo/display_modpack/blob/master/display_api/API.md) document please.
For more information, see the [forum topic](https://forum.minetest.net/viewtopic.php?t=19365) at the Minetest forums.
diff --git a/display_lib/copyright.txt b/display_api/copyright.txt
index e3a15e9..e3a15e9 100644
--- a/display_lib/copyright.txt
+++ b/display_api/copyright.txt
diff --git a/display_lib/depends.txt b/display_api/depends.txt
index e69de29..e69de29 100644
--- a/display_lib/depends.txt
+++ b/display_api/depends.txt
diff --git a/display_lib/init.lua b/display_api/init.lua
index 11ed60e..7439119 100644
--- a/display_lib/init.lua
+++ b/display_api/init.lua
@@ -1,5 +1,5 @@
--[[
- display_lib mod for Minetest - Library to add dynamic display
+ display_api mod for Minetest - Library to add dynamic display
capabilities to nodes
(c) Pierre-Yves Rollo
@@ -17,12 +17,12 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
--]]
-display_lib = {}
+display_api = {}
-- Prefered gap between node and entity
-- Entity positionment is up to mods but it is a good practice to use this
-- variable as spacing between entity and node
-display_lib.entity_spacing = 0.002
+display_api.entity_spacing = 0.002
-- Miscelaneous values depending on wallmounted param2
local wallmounted_values = {
@@ -144,25 +144,25 @@ local function call_node_on_display_update(pos, objref)
end
--- Force entity update
-function display_lib.update_entities(pos)
+function display_api.update_entities(pos)
local objrefs = place_entities(pos)
for _, objref in pairs(objrefs) do
call_node_on_display_update(pos, objref)
end
end
---- On_activate callback for display_lib entities. Calls on_display_update callbacks
+--- On_activate callback for display_api entities. Calls on_display_update callbacks
--- of corresponding node for each entity.
-function display_lib.on_activate(entity, staticdata)
+function display_api.on_activate(entity, staticdata)
if entity then
entity.object:set_armor_groups({immortal=1})
call_node_on_display_update(entity.object:getpos(), entity.object)
end
end
---- On_place callback for display_lib items. Does nothing more than preventing item
+--- On_place callback for display_api items. Does nothing more than preventing item
--- from being placed on ceiling or ground
-function display_lib.on_place(itemstack, placer, pointed_thing)
+function display_api.on_place(itemstack, placer, pointed_thing)
local ndef = itemstack:get_definition()
local above = pointed_thing.above
local under = pointed_thing.under
@@ -189,13 +189,13 @@ function display_lib.on_place(itemstack, placer, pointed_thing)
end
---- On_construct callback for display_lib items. Creates entities and update them.
-function display_lib.on_construct(pos)
- display_lib.update_entities(pos)
+--- On_construct callback for display_api items. Creates entities and update them.
+function display_api.on_construct(pos)
+ display_api.update_entities(pos)
end
---- On_destruct callback for display_lib items. Removes entities.
-function display_lib.on_destruct(pos)
+--- On_destruct callback for display_api items. Removes entities.
+function display_api.on_destruct(pos)
local objrefs = get_entities(pos)
for _, objref in pairs(objrefs) do
@@ -203,8 +203,8 @@ function display_lib.on_destruct(pos)
end
end
--- On_rotate (screwdriver) callback for display_lib items. Prevents axis rotation and reorients entities.
-function display_lib.on_rotate(pos, node, user, mode, new_param2)
+-- On_rotate (screwdriver) callback for display_api items. Prevents axis rotation and reorients entities.
+function display_api.on_rotate(pos, node, user, mode, new_param2)
if mode ~= 1 then return false end
local values = get_values(node)
@@ -219,22 +219,24 @@ function display_lib.on_rotate(pos, node, user, mode, new_param2)
end
--- Creates display entity with some fields and the on_activate callback
-function display_lib.register_display_entity(entity_name)
+function display_api.register_display_entity(entity_name)
if not minetest.registered_entity then
minetest.register_entity(':'..entity_name, {
collisionbox = { 0, 0, 0, 0, 0, 0 },
visual = "upright_sprite",
textures = {},
- on_activate = display_lib.on_activate,
+ on_activate = display_api.on_activate,
})
end
end
minetest.register_lbm({
- label = "Update display_lib entities",
- name = "display_lib:update_entities",
+ label = "Update display_api entities",
+ name = "display_api:update_entities",
run_at_every_load = true,
- nodenames = {"group:display_lib_node"},
- action = function(pos, node) display_lib.update_entities(pos) end,
+ nodenames = {"group:display_modpack_node", "group:display_lib_node"},
+ action = function(pos, node) display_api.update_entities(pos) end,
})
+-- Compatibility
+display_lib = display_api \ No newline at end of file
diff --git a/font_lib/API.md b/font_api/API.md
index 1b79b55..a4aee6d 100644
--- a/font_lib/API.md
+++ b/font_api/API.md
@@ -46,7 +46,7 @@ Builds texture for a multiline colored text
### register\_font
**font\_lib.register_font(font\_name, height, widths)**
-Registers a new font in font_lib.
+Registers a new font in font_api.
**font\_name**: Name of the font to register (this name will be used to address the font later)
If registering different sizes of the same font, add size in the font name (e.g. times\_10, times\_12...).
@@ -81,7 +81,7 @@ __Syntax__
**make\_font\_texture.sh <fontfile> <fontname> <fontsize>**
**<fontfile>**: A TTF font file to use to create textures.
-**<fontname>**: The font name to be used in font_lib (should be simple, with no spaces).
+**<fontname>**: The font name to be used in font_api (should be simple, with no spaces).
**<fontsize>**: Font height to be rendered.
### make_font_lua.sh
@@ -94,14 +94,14 @@ __Syntax__
**make\_font_lua.sh <fontname>**
-**<fontname>**: The font name to be used in font_lib (same as given to make\_font\_texture.sh)
+**<fontname>**: The font name to be used in font_api (same as given to make\_font\_texture.sh)
### An exemple generating a font mod
mkdir font_myfont
cd font_myfont
- /<path_to_font_lib>/tools/make_font_texture.sh myfont.ttf myfont 12
- /<path_to_font_lib>/tools/make_font_lua.sh myfont
+ /<path_to_font_api>/tools/make_font_texture.sh myfont.ttf myfont 12
+ /<path_to_font_api>/tools/make_font_lua.sh myfont
mv font_myfont.lua init.lua
diff --git a/font_lib/LICENSE.txt b/font_api/LICENSE.txt
index 341c30b..341c30b 100644
--- a/font_lib/LICENSE.txt
+++ b/font_api/LICENSE.txt
diff --git a/font_lib/README.md b/font_api/README.md
index 6b53a6b..c7ae64b 100644
--- a/font_lib/README.md
+++ b/font_api/README.md
@@ -1,6 +1,6 @@
# Font Lib
-This library for font display on entities (to be used with display_lib for sign creation).
+This library for font display on entities (to be used with display_api for sign creation).
**Dependancies**: default
@@ -8,7 +8,7 @@ This library for font display on entities (to be used with display_lib for sign
(Default font taken from VanessaE's homedecor/signs_lib, originally under WTFPL)
-**API**: See [API.md](https://github.com/pyrollo/display_modpack/blob/master/font_lib/API.md) document please.
+**API**: See [API.md](https://github.com/pyrollo/display_modpack/blob/master/font_api/API.md) document please.
For more information, see the [forum topic](https://forum.minetest.net/viewtopic.php?t=13563) at the Minetest forums.
diff --git a/font_lib/copyright.txt b/font_api/copyright.txt
index ceb5446..ceb5446 100644
--- a/font_lib/copyright.txt
+++ b/font_api/copyright.txt
diff --git a/font_lib/depends.txt b/font_api/depends.txt
index e69de29..e69de29 100644
--- a/font_lib/depends.txt
+++ b/font_api/depends.txt
diff --git a/font_lib/init.lua b/font_api/init.lua
index 76a6b38..f407f8b 100644
--- a/font_lib/init.lua
+++ b/font_api/init.lua
@@ -1,6 +1,6 @@
--[[
- font_lib mod for Minetest - Library to add font display capability
- to display_lib mod.
+ font_api mod for Minetest - Library to add font display capability
+ to display_api mod.
(c) Pierre-Yves Rollo
This program is free software: you can redistribute it and/or modify
@@ -20,10 +20,10 @@
-- Global variables
-------------------
-font_lib = {}
-font_lib.name = minetest.get_current_modname()
-font_lib.path = minetest.get_modpath(font_lib.name)
-font_lib.registered_fonts = {}
+font_api = {}
+font_api.name = minetest.get_current_modname()
+font_api.path = minetest.get_modpath(font_api.name)
+font_api.registered_fonts = {}
-- Local variables
------------------
@@ -59,7 +59,7 @@ local function get_default_font()
local settings_font = minetest.settings:get("default_font")
if settings_font ~= nil and settings_font ~= "" then
- default_font = font_lib.registered_fonts[settings_font]
+ default_font = font_api.registered_fonts[settings_font]
if default_font == nil then
minetest.log("warning", "Default font in settings (\""..
@@ -69,7 +69,7 @@ local function get_default_font()
-- If failed, choose first font
if default_font == nil then
- for _, font in pairs(font_lib.registered_fonts) do
+ for _, font in pairs(font_api.registered_fonts) do
default_font = font
break
end
@@ -88,7 +88,7 @@ end
-- Returns font properties to be used according to font_name
local function get_font(font_name)
- local font = font_lib.registered_fonts[font_name]
+ local font = font_api.registered_fonts[font_name]
if font == nil then
local message
@@ -150,7 +150,7 @@ end
-- @param text Text to be rendered
-- @return Rendered text (width, height)
-function font_lib.get_text_size(font_name, text)
+function font_api.get_text_size(font_name, text)
local char
local width = 0
local pos = 1
@@ -181,7 +181,7 @@ end
-- @param y Vertical position of the line in texture
-- @return Texture string
-function font_lib.make_line_texture(font_name, text, width, x, y)
+function font_api.make_line_texture(font_name, text, width, x, y)
local texture = ""
local char
local pos = 1
@@ -193,7 +193,7 @@ function font_lib.make_line_texture(font_name, text, width, x, y)
-- Replace chars with no texture by the NULL(0) char
if font.widths[char] == nil then
- print(string.format("["..font_lib.name
+ print(string.format("["..font_api.name
.."] Missing char %d (%04x)",char,char))
char = 0
end
@@ -222,7 +222,7 @@ end
-- @param color Color of the text (optional)
-- @return Texture string
-function font_lib.make_multiline_texture(font_name, text, width, height,
+function font_api.make_multiline_texture(font_name, text, width, height,
maxlines, halign, valign, color)
local texture = ""
local lines = {}
@@ -230,7 +230,7 @@ function font_lib.make_multiline_texture(font_name, text, width, height,
local y, w, h
for num, line in pairs(split_lines(text, maxlines)) do
- w, h = font_lib.get_text_size(font_name, line)
+ w, h = font_api.get_text_size(font_name, line)
lines[num] = { text = line, width = w, height = h, }
textheight = textheight + h
end
@@ -248,15 +248,15 @@ function font_lib.make_multiline_texture(font_name, text, width, height,
for _, line in pairs(lines) do
if halign == "left" then
texture = texture..
- font_lib.make_line_texture(font_name, line.text, width,
+ font_api.make_line_texture(font_name, line.text, width,
0, y)
elseif halign == "right" then
texture = texture..
- font_lib.make_line_texture(font_name, line.text, width,
+ font_api.make_line_texture(font_name, line.text, width,
width - line.width, y)
else
texture = texture..
- font_lib.make_line_texture(font_name, line.text, width,
+ font_api.make_line_texture(font_name, line.text, width,
(width - line.width) / 2, y)
end
y = y + line.height
@@ -278,9 +278,9 @@ end
-- @param height Font height in pixels
-- @param widths Array of character widths in pixels, indexed by UTF codepoints
-function font_lib.register_font(font_name, height, widths)
+function font_api.register_font(font_name, height, widths)
- if font_lib.registered_fonts[font_name] ~= nil then
+ if font_api.registered_fonts[font_name] ~= nil then
minetest.log("error", "Font \""..font_name.."\" already registered.")
return
end
@@ -303,7 +303,7 @@ function font_lib.register_font(font_name, height, widths)
return
end
- font_lib.registered_fonts[font_name] =
+ font_api.registered_fonts[font_name] =
{ name = font_name, height = height, widths = widths }
-- Force to choose again default font
@@ -317,7 +317,7 @@ end
-- @param pos Node position
-- @param objref Object reference of entity
-function font_lib.on_display_update(pos, objref)
+function font_api.on_display_update(pos, objref)
local meta = minetest.get_meta(pos)
local text = meta:get_string("display_text")
local ndef = minetest.registered_nodes[minetest.get_node(pos).name]
@@ -328,7 +328,7 @@ function font_lib.on_display_update(pos, objref)
local font = get_font(def.font_name)
objref:set_properties({
- textures={font_lib.make_multiline_texture(
+ textures={font_api.make_multiline_texture(
def.font_name, text,
def.size.x * def.resolution.x * font.height,
def.size.y * def.resolution.y * font.height,
@@ -338,3 +338,6 @@ function font_lib.on_display_update(pos, objref)
end
end
+-- Compatibility
+font_lib = font_api
+
diff --git a/font_lib/settingtypes.txt b/font_api/settingtypes.txt
index d111159..d111159 100644
--- a/font_lib/settingtypes.txt
+++ b/font_api/settingtypes.txt
diff --git a/font_lib/tools/make_font_lua.sh b/font_api/tools/make_font_lua.sh
index 607ff95..ae24001 100755
--- a/font_lib/tools/make_font_lua.sh
+++ b/font_api/tools/make_font_lua.sh
@@ -39,18 +39,18 @@ $luafile generated by $scriptname $(LANG=en_US date)
--]]
-font_lib.register_font(
+font_api.register_font(
'$font_name',
$font_height,
{ $font_widths }
);
" > font_$font_name.lua
-if grep -q font_lib depends.txt &>/dev/null
+if grep -q font_api depends.txt &>/dev/null
then
- echo "font_lib already in depends.txt."
+ echo "font_api already in depends.txt."
else
- echo "adding font_lib to depends.txt."
- echo "font_lib" >> depends.txt
+ echo "adding font_api to depends.txt."
+ echo "font_api" >> depends.txt
fi
diff --git a/font_lib/tools/make_font_textures.sh b/font_api/tools/make_font_textures.sh
index ade2e32..6f4959d 100755
--- a/font_lib/tools/make_font_textures.sh
+++ b/font_api/tools/make_font_textures.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-# This program generates a bitmap font for font_lib mod for Minetest game.
+# This program generates a bitmap font for font_api mod for Minetest game.
# (c) Andrzej Pieńkowski <pienkowski.andrzej@gmail.com>
# (c) Pierre-Yves Rollo <dev@pyrollo.com>
# License: GPL
@@ -8,7 +8,7 @@
usage() {
echo "Usage: $0 fontfile fontname fontsize"
echo "fontfile: A TTF font file to use to create textures."
- echo "fontname: The font name to be used in font_lib (should be simple, with no spaces)."
+ echo "fontname: The font name to be used in font_api (should be simple, with no spaces)."
echo "fontsize: Font height to be rendered."
}
diff --git a/font_epilepsy/README.md b/font_epilepsy/README.md
index 992c55a..20798cd 100644
--- a/font_epilepsy/README.md
+++ b/font_epilepsy/README.md
@@ -1,10 +1,10 @@
# Font Epilepsy
-Font mod for font_lib mod.
+Font mod for font_api mod.
**Font**: EpilepsySansBold by Kreative Software under KREATIVE SOFTWARE RELAY FONTS FREE USE LICENSE version 1.2f.
-**Dependancies**:font_lib
+**Dependancies**:font_api
**License**: LPGL for the cod, KREATIVE SOFTWARE RELAY FONTS FREE USE LICENSE version 1.2f for the font (see FONT LICENSE.txt)
diff --git a/font_epilepsy/depends.txt b/font_epilepsy/depends.txt
index c8e3a5b..7372f0d 100644
--- a/font_epilepsy/depends.txt
+++ b/font_epilepsy/depends.txt
@@ -1 +1 @@
-font_lib
+font_api
diff --git a/font_epilepsy/init.lua b/font_epilepsy/init.lua
index 25a093b..6dd7d74 100644
--- a/font_epilepsy/init.lua
+++ b/font_epilepsy/init.lua
@@ -4,7 +4,7 @@
--]]
-font_lib.register_font(
+font_api.register_font(
'epilepsy',
14,
{ [0]=8, [32]=8, [33]=5, [34]=8, [35]=8, [36]=9, [37]=10, [38]=10, [39]=5, [40]=6, [41]=6, [42]=7, [43]=7, [44]=4, [45]=5, [46]=5, [47]=7, [48]=8, [49]=8, [50]=8, [51]=8, [52]=8, [53]=8, [54]=8, [55]=8, [56]=8, [57]=8, [58]=5, [59]=5, [60]=7, [61]=7, [62]=7, [63]=7, [64]=13, [65]=9, [66]=8, [67]=8, [68]=8, [69]=7, [70]=7, [71]=9, [72]=8, [73]=5, [74]=6, [75]=9, [76]=7, [77]=11, [78]=9, [79]=9, [80]=8, [81]=9, [82]=8, [83]=8, [84]=8, [85]=8, [86]=9, [87]=11, [88]=9, [89]=10, [90]=9, [91]=5, [92]=7, [93]=5, [94]=7, [95]=7, [96]=5, [97]=8, [98]=8, [99]=8, [100]=8, [101]=8, [102]=6, [103]=8, [104]=8, [105]=4, [106]=5, [107]=8, [108]=4, [109]=12, [110]=8, [111]=8, [112]=8, [113]=8, [114]=7, [115]=7, [116]=6, [117]=8, [118]=8, [119]=11, [120]=9, [121]=8, [122]=8, [123]=6, [124]=5, [125]=6, [126]=9, [160]=4, [161]=5, [162]=9, [163]=9, [164]=9, [165]=10, [166]=5, [167]=6, [168]=7, [169]=10, [170]=6, [171]=7, [172]=7, [173]=5, [174]=10, [175]=6, [176]=6, [177]=7, [178]=5, [179]=5, [180]=5, [181]=9, [182]=7, [183]=5, [184]=6, [185]=5, [186]=6, [187]=7, [188]=10, [189]=10, [190]=10, [191]=7, [192]=9, [193]=9, [194]=9, [195]=9, [196]=9, [197]=9, [198]=11, [199]=8, [200]=7, [201]=7, [202]=7, [203]=7, [204]=5, [205]=5, [206]=6, [207]=6, [208]=9, [209]=9, [210]=9, [211]=9, [212]=9, [213]=9, [214]=9, [215]=7, [216]=9, [217]=8, [218]=8, [219]=8, [220]=8, [221]=10, [222]=8, [223]=8, [224]=8, [225]=8, [226]=8, [227]=8, [228]=8, [229]=8, [230]=12, [231]=8, [232]=8, [233]=8, [234]=8, [235]=8, [236]=4, [237]=4, [238]=5, [239]=5, [240]=8, [241]=8, [242]=8, [243]=8, [244]=8, [245]=8, [246]=8, [247]=8, [248]=10, [249]=8, [250]=8, [251]=8, [252]=8, [253]=8, [254]=8, [255]=8, [256]=9, [257]=8, [258]=9, [259]=8, [260]=9, [261]=8, [262]=8, [263]=8, [264]=8, [265]=8, [266]=8, [267]=8, [268]=8, [269]=8, [270]=8, [271]=11, [272]=9, [273]=8, [274]=7, [275]=8, [276]=7, [277]=8, [278]=7, [279]=8, [280]=7, [281]=8, [282]=7, [283]=8, [284]=9, [285]=8, [286]=9, [287]=8, [288]=9, [289]=8, [290]=9, [291]=8, [292]=8, [293]=8, [294]=8, [295]=8, [296]=7, [297]=6, [298]=5, [299]=4, [300]=6, [301]=5, [302]=5, [303]=4, [304]=5, [305]=4, [306]=10, [307]=8, [308]=6, [309]=5, [310]=9, [311]=8, [312]=8, [313]=7, [314]=4, [315]=7, [316]=4, [317]=10, [318]=7, [319]=7, [320]=8, [321]=7, [322]=5, [323]=9, [324]=8, [325]=9, [326]=8, [327]=9, [328]=8, [329]=11, [330]=9, [331]=8, [332]=9, [333]=8, [334]=9, [335]=8, [336]=9, [337]=8, [338]=11, [339]=11, [340]=8, [341]=7, [342]=8, [343]=7, [344]=8, [345]=7, [346]=8, [347]=7, [348]=8, [349]=7, [350]=8, [351]=7, [352]=8, [353]=7, [354]=8, [355]=6, [356]=8, [357]=10, [358]=8, [359]=6, [360]=8, [361]=8, [362]=8, [363]=8, [364]=8, [365]=8, [366]=8, [367]=8, [368]=8, [369]=8, [370]=8, [371]=8, [372]=11, [373]=11, [374]=10, [375]=8, [376]=10, [377]=9, [378]=8, [379]=9, [380]=8, [381]=9, [382]=8, [383]=6, [884]=5, [885]=5, [890]=4, [894]=4, [900]=5, [901]=8, [902]=9, [903]=5, [904]=7, [905]=8, [906]=5, [908]=9, [910]=10, [911]=9, [912]=6, [913]=9, [914]=8, [915]=7, [916]=10, [917]=7, [918]=9, [919]=8, [920]=9, [921]=5, [922]=9, [923]=9, [924]=11, [925]=9, [926]=8, [927]=9, [928]=8, [929]=8, [931]=8, [932]=8, [933]=10, [934]=10, [935]=9, [936]=12, [937]=9, [938]=6, [939]=10, [940]=9, [941]=8, [942]=8, [943]=5, [944]=8, [945]=9, [946]=8, [947]=8, [948]=8, [949]=8, [950]=8, [951]=8, [952]=8, [953]=5, [954]=7, [955]=8, [956]=9, [957]=8, [958]=8, [959]=8, [960]=9, [961]=8, [962]=8, [963]=9, [964]=9, [965]=8, [966]=10, [967]=8, [968]=12, [969]=10, [970]=6, [971]=8, [972]=8, [973]=8, [974]=10, [976]=8, [977]=10, [978]=11, [979]=11, [980]=11, [981]=10, [982]=10, [983]=9, [984]=9, [985]=8, [986]=9, [987]=8, [988]=7, [989]=7, [990]=9, [991]=7, [992]=11, [993]=8, [994]=10, [995]=10, [996]=9, [997]=9, [998]=9, [999]=10, [1000]=8, [1001]=7, [1002]=9, [1003]=8, [1004]=8, [1005]=8, [1006]=10, [1007]=8, [1008]=9, [1009]=8, [1010]=8, [1011]=5, [1012]=9, [1013]=9, [1014]=9, [1015]=8, [1016]=8, [1017]=8, [1018]=11, [1019]=11, [1020]=8, [1021]=8, [1022]=8, [1023]=8, [1024]=7, [1025]=7, [1026]=10, [1027]=7, [1028]=9, [1029]=7, [1030]=5, [1031]=6, [1032]=6, [1033]=14, [1034]=13, [1035]=10, [1036]=9, [1037]=9, [1038]=10, [1039]=8, [1040]=9, [1041]=8, [1042]=8, [1043]=7, [1044]=10, [1045]=7, [1046]=12, [1047]=8, [1048]=9, [1049]=9, [1050]=9, [1051]=10, [1052]=11, [1053]=8, [1054]=9, [1055]=8, [1056]=8, [1057]=8, [1058]=8, [1059]=10, [1060]=10, [1061]=9, [1062]=8, [1063]=8, [1064]=12, [1065]=12, [1066]=11, [1067]=11, [1068]=8, [1069]=9, [1070]=12, [1071]=8, [1072]=8, [1073]=8, [1074]=8, [1075]=6, [1076]=10, [1077]=8, [1078]=12, [1079]=8, [1080]=9, [1081]=9, [1082]=7, [1083]=10, [1084]=11, [1085]=8, [1086]=8, [1087]=9, [1088]=8, [1089]=8, [1090]=8, [1091]=8, [1092]=12, [1093]=9, [1094]=8, [1095]=8, [1096]=10, [1097]=10, [1098]=10, [1099]=10, [1100]=7, [1101]=9, [1102]=10, [1103]=8, [1104]=8, [1105]=8, [1106]=8, [1107]=6, [1108]=9, [1109]=7, [1110]=4, [1111]=5, [1112]=5, [1113]=12, [1114]=11, [1115]=8, [1116]=7, [1117]=9, [1118]=8, [1119]=8, [1120]=12, [1121]=10, [1122]=8, [1123]=7, [1124]=11, [1125]=11, [1126]=10, [1127]=9, [1128]=13, [1129]=12, [1130]=10, [1131]=10, [1132]=13, [1133]=13, [1134]=8, [1135]=8, [1136]=12, [1137]=12, [1138]=9, [1139]=7, [1140]=11, [1141]=10, [1142]=11, [1143]=10, [1144]=18, [1145]=17, [1146]=11, [1147]=9, [1148]=12, [1149]=10, [1150]=12, [1151]=10, [1152]=8, [1153]=7, [1154]=7, [1155]=1, [1160]=14, [1161]=14, [1162]=9, [1163]=9, [1164]=8, [1165]=7, [1166]=8, [1167]=8, [1168]=7, [1169]=7, [1170]=7, [1171]=6, [1172]=8, [1173]=8, [1174]=12, [1175]=12, [1176]=8, [1177]=8, [1178]=9, [1179]=8, [1180]=9, [1181]=7, [1182]=9, [1183]=7, [1184]=12, [1185]=10, [1186]=8, [1187]=8, [1188]=11, [1189]=11, [1190]=12, [1191]=12, [1192]=11, [1193]=10, [1194]=8, [1195]=8, [1196]=8, [1197]=8, [1198]=10, [1199]=10, [1200]=10, [1201]=10, [1202]=9, [1203]=9, [1204]=11, [1205]=11, [1206]=8, [1207]=8, [1208]=9, [1209]=9, [1210]=8, [1211]=8, [1212]=11, [1213]=11, [1214]=11, [1215]=11, [1216]=5, [1217]=12, [1218]=12, [1219]=8, [1220]=8, [1221]=10, [1222]=10, [1223]=8, [1224]=8, [1225]=8, [1226]=8, [1227]=8, [1228]=8, [1229]=11, [1230]=11, [1232]=9, [1233]=8, [1234]=9, [1235]=8, [1236]=11, [1237]=12, [1238]=7, [1239]=8, [1240]=8, [1241]=8, [1242]=8, [1243]=8, [1244]=12, [1245]=12, [1246]=8, [1247]=8, [1248]=8, [1249]=8, [1250]=9, [1251]=9, [1252]=9, [1253]=9, [1254]=9, [1255]=8, [1256]=9, [1257]=8, [1258]=9, [1259]=8, [1260]=9, [1261]=9, [1262]=10, [1263]=8, [1264]=10, [1265]=8, [1266]=10, [1267]=8, [1268]=8, [1269]=8, [1270]=7, [1271]=6, [1272]=11, [1273]=10, [8208]=5, [8209]=5, [8210]=8, [8211]=7, [8212]=10, [8213]=12, [8216]=4, [8217]=4, [8218]=4, [8219]=4, [8220]=7, [8221]=7, [8222]=7, [8223]=7, [8364]=8 }
diff --git a/ontime_clocks/README.md b/ontime_clocks/README.md
index 2254a43..d9db998 100644
--- a/ontime_clocks/README.md
+++ b/ontime_clocks/README.md
@@ -4,7 +4,7 @@ This mod provides clocks that display real ingame time.
For more information, see the [forum topic](https://forum.minetest.net/viewtopic.php?t=19365) at the Minetest forums.
-**Dependancies**: display_lib, default
+**Dependancies**: display_api, default
**License**: Code under LGPL, textures under CC-BY-SA
diff --git a/ontime_clocks/common.lua b/ontime_clocks/common.lua
index 39462d3..cced299 100644
--- a/ontime_clocks/common.lua
+++ b/ontime_clocks/common.lua
@@ -19,7 +19,7 @@
--]]
-- Entity for time display
-display_lib.register_display_entity("ontime_clocks:display")
+display_api.register_display_entity("ontime_clocks:display")
function ontime_clocks.get_h24()
return math.floor(minetest.get_timeofday()*24)%24
diff --git a/ontime_clocks/depends.txt b/ontime_clocks/depends.txt
index bdefee1..07a2ec1 100644
--- a/ontime_clocks/depends.txt
+++ b/ontime_clocks/depends.txt
@@ -1,5 +1,5 @@
default
dye
-display_lib
+display_api
intllib?
diff --git a/ontime_clocks/nodes.lua b/ontime_clocks/nodes.lua
index d8007e8..aa3583d 100644
--- a/ontime_clocks/nodes.lua
+++ b/ontime_clocks/nodes.lua
@@ -35,7 +35,7 @@ minetest.register_node("ontime_clocks:green_digital", {
wall_top = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
},
tiles = {"ontime_clocks_digital.png"},
- groups = {oddly_breakable_by_hand = 1, not_blocking_trains = 1, display_lib_node = 1},
+ groups = {oddly_breakable_by_hand = 1, not_blocking_trains = 1, display_modpack_node = 1},
display_entities = {
["ontime_clocks:display"] = {
depth = 13/32 - 0.01,
@@ -45,17 +45,17 @@ minetest.register_node("ontime_clocks:green_digital", {
"#040", "#0F0", ontime_clocks.get_h24(), ontime_clocks.get_m12()))
end },
},
- on_place = display_lib.on_place,
- on_construct = display_lib.on_construct,
- on_destruct = display_lib.on_destruct,
- on_rotate = display_lib.on_rotate,
+ on_place = display_api.on_place,
+ on_construct = display_api.on_construct,
+ on_destruct = display_api.on_destruct,
+ on_rotate = display_api.on_rotate,
})
minetest.register_abm({
nodenames = {"ontime_clocks:green_digital"},
interval = 5,
chance = 1,
- action = display_lib.update_entities,
+ action = display_api.update_entities,
})
-- Red digital clock
@@ -73,7 +73,7 @@ minetest.register_node("ontime_clocks:red_digital", {
wall_top = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
},
tiles = {"ontime_clocks_digital.png"},
- groups = {oddly_breakable_by_hand = 1, not_blocking_trains = 1, display_lib_node = 1},
+ groups = {oddly_breakable_by_hand = 1, not_blocking_trains = 1, display_modpack_node = 1},
display_entities = {
["ontime_clocks:display"] = {
depth = 13/32 - 0.01,
@@ -83,17 +83,17 @@ minetest.register_node("ontime_clocks:red_digital", {
"#400", "#F00", ontime_clocks.get_h24(), ontime_clocks.get_m12()))
end },
},
- on_place = display_lib.on_place,
- on_construct = display_lib.on_construct,
- on_destruct = display_lib.on_destruct,
- on_rotate = display_lib.on_rotate,
+ on_place = display_api.on_place,
+ on_construct = display_api.on_construct,
+ on_destruct = display_api.on_destruct,
+ on_rotate = display_api.on_rotate,
})
minetest.register_abm({
nodenames = {"ontime_clocks:red_digital"},
interval = 5,
chance = 1,
- action = display_lib.update_entities,
+ action = display_api.update_entities,
})
@@ -111,7 +111,7 @@ minetest.register_node("ontime_clocks:white", {
wall_top = { -7/16, 0.5, -7/16, 7/16, 7/16, 7/16},
},
tiles = {"ontime_clocks_white.png"},
- groups = {choppy = 1, oddly_breakable_by_hand = 1, not_blocking_trains = 1, display_lib_node = 1},
+ groups = {choppy = 1, oddly_breakable_by_hand = 1, not_blocking_trains = 1, display_modpack_node = 1},
display_entities = {
["ontime_clocks:display"] = {
depth = 6/16 - 0.01,
@@ -121,17 +121,17 @@ minetest.register_node("ontime_clocks:white", {
"#000", 36, ontime_clocks.get_h12(), ontime_clocks.get_m12()))
end },
},
- on_place = display_lib.on_place,
- on_construct = display_lib.on_construct,
- on_destruct = display_lib.on_destruct,
- on_rotate = display_lib.on_rotate,
+ on_place = display_api.on_place,
+ on_construct = display_api.on_construct,
+ on_destruct = display_api.on_destruct,
+ on_rotate = display_api.on_rotate,
})
minetest.register_abm({
nodenames = {"ontime_clocks:white"},
interval = 5,
chance = 1,
- action = display_lib.update_entities,
+ action = display_api.update_entities,
})
minetest.register_node("ontime_clocks:frameless_black", {
@@ -148,7 +148,7 @@ minetest.register_node("ontime_clocks:frameless_black", {
wall_top = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
},
tiles = {"ontime_clocks_frameless.png"},
- groups = {choppy = 1, oddly_breakable_by_hand = 1, not_blocking_trains = 1, display_lib_node = 1},
+ groups = {choppy = 1, oddly_breakable_by_hand = 1, not_blocking_trains = 1, display_modpack_node = 1},
display_entities = {
["ontime_clocks:display"] = {
depth = 7/16,
@@ -158,17 +158,17 @@ minetest.register_node("ontime_clocks:frameless_black", {
"#000", 48, ontime_clocks.get_h12(), ontime_clocks.get_m12()))
end },
},
- on_place = display_lib.on_place,
- on_construct = display_lib.on_construct,
- on_destruct = display_lib.on_destruct,
- on_rotate = display_lib.on_rotate,
+ on_place = display_api.on_place,
+ on_construct = display_api.on_construct,
+ on_destruct = display_api.on_destruct,
+ on_rotate = display_api.on_rotate,
})
minetest.register_abm({
nodenames = {"ontime_clocks:frameless_black"},
interval = 5,
chance = 1,
- action = display_lib.update_entities,
+ action = display_api.update_entities,
})
minetest.register_node("ontime_clocks:frameless_gold", {
@@ -185,7 +185,7 @@ minetest.register_node("ontime_clocks:frameless_gold", {
wall_top = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
},
tiles = {"ontime_clocks_frameless.png^[colorize:#FF0"},
- groups = {choppy = 1, oddly_breakable_by_hand = 1, not_blocking_trains = 1, display_lib_node = 1},
+ groups = {choppy = 1, oddly_breakable_by_hand = 1, not_blocking_trains = 1, display_modpack_node = 1},
display_entities = {
["ontime_clocks:display"] = {
depth = 7/16,
@@ -195,17 +195,17 @@ minetest.register_node("ontime_clocks:frameless_gold", {
"#FF0", 48, ontime_clocks.get_h12(), ontime_clocks.get_m12()))
end },
},
- on_place = display_lib.on_place,
- on_construct = display_lib.on_construct,
- on_destruct = display_lib.on_destruct,
- on_rotate = display_lib.on_rotate,
+ on_place = display_api.on_place,
+ on_construct = display_api.on_construct,
+ on_destruct = display_api.on_destruct,
+ on_rotate = display_api.on_rotate,
})
minetest.register_abm({
nodenames = {"ontime_clocks:frameless_gold"},
interval = 5,
chance = 1,
- action = display_lib.update_entities,
+ action = display_api.update_entities,
})
minetest.register_node("ontime_clocks:frameless_white", {
@@ -222,7 +222,7 @@ minetest.register_node("ontime_clocks:frameless_white", {
wall_top = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
},
tiles = {"ontime_clocks_frameless.png^[colorize:#FFF"},
- groups = {choppy = 1, oddly_breakable_by_hand = 1, not_blocking_trains = 1, display_lib_node = 1},
+ groups = {choppy = 1, oddly_breakable_by_hand = 1, not_blocking_trains = 1, display_modpack_node = 1},
display_entities = {
["ontime_clocks:display"] = {
depth = 7/16,
@@ -232,15 +232,15 @@ minetest.register_node("ontime_clocks:frameless_white", {
"#FFF", 48, ontime_clocks.get_h12(), ontime_clocks.get_m12()))
end },
},
- on_place = display_lib.on_place,
- on_construct = display_lib.on_construct,
- on_destruct = display_lib.on_destruct,
- on_rotate = display_lib.on_rotate,
+ on_place = display_api.on_place,
+ on_construct = display_api.on_construct,
+ on_destruct = display_api.on_destruct,
+ on_rotate = display_api.on_rotate,
})
minetest.register_abm({
nodenames = {"ontime_clocks:frameless_white"},
interval = 5,
chance = 1,
- action = display_lib.update_entities,
+ action = display_api.update_entities,
})
diff --git a/signs/common.lua b/signs/common.lua
index 3665ab5..2b40db2 100644
--- a/signs/common.lua
+++ b/signs/common.lua
@@ -21,113 +21,40 @@
local S = signs.intllib
local F = function(...) return minetest.formspec_escape(S(...)) end
-function signs.set_display_text(pos,text)
- local meta = minetest.get_meta(pos)
- meta:set_string("display_text", text)
- meta:set_string("infotext", "\""..text.."\"")
- display_lib.update_entities(pos)
-end
-function signs.set_formspec(pos)
- local meta = minetest.get_meta(pos)
- local ndef = minetest.registered_nodes[minetest.get_node(pos).name]
- if ndef and ndef.display_entities and ndef.display_entities["signs:display_text"] then
- local maxlines = ndef.display_entities["signs:display_text"].maxlines
- local formspec
-
- if maxlines == 1 then
- formspec = "size[6,3]"..
- default.gui_bg .. default.gui_bg_img .. default.gui_slots ..
- "field[0.5,0.7;5.5,1;display_text;"..F("Text")..";${display_text}]"..
- "button_exit[2,2;2,1;ok;"..F("Write").."]"
- else
- local extralabel = ""
- if maxlines then
- extralabel = F(" (first %s lines only)"):format(maxlines)
- end
-
- formspec = "size[6,4]"..
- default.gui_bg .. default.gui_bg_img .. default.gui_slots ..
- "textarea[0.5,0.7;5.5,2;display_text;"..F("Text")..""..extralabel..";${display_text}]"..
- "button_exit[2,3;2,1;ok;"..F("Write").."]"
- end
+--Backwards compatibility functions
- meta:set_string("formspec", formspec)
- end
+signs.set_display_text = function(...)
+ minetest.log("warning", "signs.set_display_text() is deprecated, please use signs_api.set_display_text() instead.")
+ return signs_api.set_display_text(...)
end
-function signs.on_receive_fields(pos, formname, fields, player)
- if not minetest.is_protected(pos, player:get_player_name()) then
- if fields and (fields.ok or fields.key_enter) then
- signs.set_display_text(pos, fields.display_text)
- end
- end
+signs.set_formspec = function(...)
+ minetest.log("warning", "signs.set_formspec() is deprecated, please use signs_api.set_formspec() instead.")
+ return signs_api.set_formspec(...)
end
--- On place callback for direction signs
--- (chooses which sign according to look direction)
-function signs.on_place_direction(itemstack, placer, pointed_thing)
- local name = itemstack:get_name()
- local ndef = minetest.registered_nodes[name]
-
- local bdir = {x = pointed_thing.under.x - pointed_thing.above.x,
- y = pointed_thing.under.y - pointed_thing.above.y,
- z = pointed_thing.under.z - pointed_thing.above.z}
- local pdir = placer:get_look_dir()
-
- local ndir, test
-
- if ndef.paramtype2 == "facedir" then
- if bdir.x == 0 and bdir.z == 0 then
- -- Ceiling or floor pointed (facedir chosen from player dir)
- ndir = minetest.dir_to_facedir({x=pdir.x, y=0, z=pdir.z})
- else
- -- Wall pointed
- ndir = minetest.dir_to_facedir(bdir)
- end
-
- test = {[0]=-pdir.x, pdir.z, pdir.x, -pdir.z}
- end
-
- if ndef.paramtype2 == "wallmounted" then
- ndir = minetest.dir_to_wallmounted(bdir)
- if ndir == 0 or ndir == 1 then
- -- Ceiling or floor
- ndir = minetest.dir_to_wallmounted({x=pdir.x, y=0, z=pdir.z})
- end
-
- test = {0, pdir.z, -pdir.z, -pdir.x, pdir.x}
- end
+signs.on_receive_fields = function(...)
+ minetest.log("warning", "signs.on_receive_fields() is deprecated, please use signs_api.on_receive_fields() instead.")
+ return signs_api.on_receive_fields(...)
+end
- -- Only for direction signs
- if ndef.signs_other_dir then
- if test[ndir] > 0 then
- itemstack:set_name(ndef.signs_other_dir)
- end
- itemstack = minetest.item_place(itemstack, placer, pointed_thing, ndir)
- itemstack:set_name(name)
+signs.on_place_direction = function(...)
+ minetest.log("warning", "signs.on_place_direction() is deprecated, please use signs_api.on_place_direction() instead.")
+ return signs_api.on_place_direction(...)
+end
- return itemstack
- else
- return minetest.item_place(itemstack, placer, pointed_thing, ndir)
- end
+signs.on_rotate = function(...)
+ minetest.log("warning", "signs.on_rotate() is deprecated, please use signs_api.on_rotate() instead.")
+ return signs_api.on_rotate(...)
end
--- Handles screwdriver rotation. Direction is affected for direction signs
-function signs.on_rotate(pos, node, player, mode, new_param2)
- if mode == 2 then
- local ndef = minetest.registered_nodes[node.name]
- if ndef.signs_other_dir then
- minetest.swap_node(pos, {name = ndef.signs_other_dir,
- param1 = node.param1, param2 = node.param2})
- display_lib.update_entities(pos)
- end
- else
- display_lib.on_rotate(pos, node, user, mode, new_param2)
- end
- return false;
+signs.register_sign = function(...)
+ minetest.log("warning", "signs.register_sign() is deprecated, please use signs_api.register_sign() instead.")
+ return signs_api.register_sign(...)
end
+
-- Generic callback for show_formspec displayed formspecs of "sign" mod
minetest.register_on_player_receive_fields(function(player, formname, fields)
@@ -142,59 +69,3 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
end
end)
-
-function signs.register_sign(mod, name, model)
- -- Default fields
- local fields = {
- sunlight_propagates = true,
- paramtype = "light",
- paramtype2 = "facedir",
- drawtype = "nodebox",
- node_box = {
- type = "fixed",
- fixed = {-model.width/2, -model.height/2, 0.5,
- model.width/2, model.height/2, 0.5 - model.depth},
- },
- groups = {choppy=2, dig_immediate=2, not_blocking_trains = 1, display_lib_node = 1},
- sounds = default.node_sound_defaults(),
- display_entities = {
- ["signs:display_text"] = {
- on_display_update = font_lib.on_display_update,
- depth = 0.5 - display_lib.entity_spacing - model.depth,
- size = { x = model.width, y = model.height },
- resolution = { x = 64, y = 64 },
- maxlines = 1,
- },
-
- },
- on_place = display_lib.on_place,
- on_construct = function(pos)
- signs.set_formspec(pos)
- display_lib.on_construct(pos)
- end,
- on_destruct = display_lib.on_destruct,
- on_rotate = signs.on_rotate,
- on_receive_fields = signs.on_receive_fields,
- on_punch = function(pos, node, player, pointed_thing) display_lib.update_entities(pos) end,
- }
-
- -- Node fields override
- for key, value in pairs(model.node_fields) do
- if key == "groups" then
- for key2, value2 in pairs(value) do
- fields[key][key2] = value2
- end
- else
- fields[key] = value
- end
- end
-
- if not fields.wield_image then fields.wield_image = fields.inventory_image end
-
- -- Entity fields override
- for key, value in pairs(model.entity_fields) do
- fields.display_entities["signs:display_text"][key] = value
- end
-
- minetest.register_node(mod..":"..name, fields)
-end
diff --git a/signs/compatibility.lua b/signs/compatibility.lua
index 3284230..e798a67 100644
--- a/signs/compatibility.lua
+++ b/signs/compatibility.lua
@@ -43,9 +43,9 @@ local function compatibility_check_1(pos, node)
node.name = convert_nodes[node.name]
if node.name then
node.param2 = wallmounted_to_facedir[node.param2]
- display_lib.on_destruct(pos)
+ display_api.on_destruct(pos)
minetest.swap_node(pos, node)
- display_lib.on_construct(pos)
+ display_api.on_construct(pos)
end
end
@@ -76,7 +76,7 @@ local function compatibility_check_2(pos, node)
end
end
-- Create new entity
- display_lib.update_entities(pos)
+ display_api.update_entities(pos)
end
minetest.register_lbm({ name = "signs:conpatibility_2",
diff --git a/signs/depends.txt b/signs/depends.txt
index 3feca07..ad3bb8f 100644
--- a/signs/depends.txt
+++ b/signs/depends.txt
@@ -1,4 +1,5 @@
default
intllib?
-display_lib
-font_lib
+display_api
+font_api
+signs_api
diff --git a/signs/nodes.lua b/signs/nodes.lua
index 354bfd6..18bf1d6 100644
--- a/signs/nodes.lua
+++ b/signs/nodes.lua
@@ -28,7 +28,7 @@ local function display_poster(pos, node, player)
local def = minetest.registered_nodes[node.name].display_entities["signs:display_text"]
-- Title texture
- local titletexture = font_lib.make_multiline_texture(
+ local titletexture = font_api.make_multiline_texture(
def.font_name, meta:get_string("display_text"),
116, 12, def.maxlines, def.valign, def.color)
@@ -61,9 +61,9 @@ local function edit_poster(pos, node, player)
"size[6.5,7.5]"..
default.gui_bg .. default.gui_bg_img .. default.gui_slots ..
"field[0.5,0.7;6,1;display_text;"..F("Title")..";"..
- minetest.formspec_escape(meta:get_string("display_text")).."]"..
+ minetest.formspec_escape(meta:get_string("display_text")).."]"..
"textarea[0.5,1.7;6,6;text;"..F("Text")..";"..
- minetest.formspec_escape(meta:get_string("text")).."]"..
+ minetest.formspec_escape(meta:get_string("text")).."]"..
"button_exit[2.25,7;2,1;write;"..F("Write").."]"
minetest.show_formspec(player:get_player_name(),
node.name.."@"..minetest.pos_to_string(pos)..":edit",
@@ -87,14 +87,14 @@ local function on_receive_fields_poster(pos, formname, fields, player)
meta:set_string("text", fields.text)
meta:set_string("infotext", "\""..fields.display_text
.."\"\n"..S("(right-click to read more text)"))
- display_lib.update_entities(pos)
+ display_api.update_entities(pos)
display_poster(pos, node, player)
end
end
end
-- Text entity for all signs
-display_lib.register_display_entity("signs:display_text")
+display_api.register_display_entity("signs:display_text")
-- Sign models and registration
local models = {
@@ -103,7 +103,7 @@ local models = {
width = 14/16,
height = 7/16,
entity_fields = {
- right = -3/32,
+ right = -3/32,
size = { x = 12/16, y = 6/16 },
resolution = { x = 9, y = 5 },
maxlines = 2,
@@ -113,8 +113,8 @@ local models = {
description = S("Wooden direction sign"),
tiles = { "signs_wooden_direction.png" },
inventory_image = "signs_wooden_inventory.png",
- signs_other_dir = 'signs:wooden_left_sign',
- on_place = signs.on_place_direction,
+ signs_other_dir = 'signs:wooden_left_sign',
+ on_place = signs_api.on_place_direction,
drawtype = "mesh",
mesh = "signs_dir_right.obj",
selection_box = { type="fixed", fixed = {-0.5, -7/32, 0.5, 7/16, 7/32, 7/16}},
@@ -126,7 +126,7 @@ local models = {
width = 14/16,
height = 7/16,
entity_fields = {
- right = 3/32,
+ right = 3/32,
size = { x = 12/16, y = 6/16 },
resolution = { x = 9, y = 5 },
maxlines = 2,
@@ -136,7 +136,7 @@ local models = {
description = S("Wooden direction sign"),
tiles = { "signs_wooden_direction.png" },
inventory_image = "signs_wooden_inventory.png",
- signs_other_dir = 'signs:wooden_right_sign',
+ signs_other_dir = 'signs:wooden_right_sign',
drawtype = "mesh",
mesh = "signs_dir_left.obj",
selection_box = { type="fixed", fixed = {-7/16, -7/32, 0.5, 0.5, 7/32, 7/16}},
@@ -158,10 +158,10 @@ local models = {
node_fields = {
description = S("Poster"),
tiles = { "signs_poster_sides.png", "signs_poster_sides.png",
- "signs_poster_sides.png", "signs_poster_sides.png",
- "signs_poster_sides.png", "signs_poster.png" },
+ "signs_poster_sides.png", "signs_poster_sides.png",
+ "signs_poster_sides.png", "signs_poster.png" },
inventory_image = "signs_poster_inventory.png",
- on_construct = display_lib.on_construct,
+ on_construct = display_api.on_construct,
on_rightclick = display_poster,
on_receive_fields = on_receive_fields_poster,
},
@@ -171,6 +171,6 @@ local models = {
-- Node registration
for name, model in pairs(models)
do
- signs.register_sign("signs", name, model)
+ signs_api.register_sign("signs", name, model)
end
diff --git a/signs_api/LICENSE.txt b/signs_api/LICENSE.txt
new file mode 100644
index 0000000..341c30b
--- /dev/null
+++ b/signs_api/LICENSE.txt
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
diff --git a/signs_api/README.md b/signs_api/README.md
new file mode 100644
index 0000000..99ff20a
--- /dev/null
+++ b/signs_api/README.md
@@ -0,0 +1,29 @@
+# Signs API
+
+This mod provides various helper functions for registereing signs with text display. Text is locked if area is protected.
+No actual signs get registered by this mod, the signs are defined in the sign submod.
+
+For more information, see the [forum topic](https://forum.minetest.net/viewtopic.php?t=19365) at the Minetest forums.
+
+**Dependancies**: default, display\_lib, font\_lib
+
+**License**: Code under LGPL, Textures and models under CC-BY-SA
+
+## API Functions
+### `signs_api.set_display_text(pos, text)`
+Sets the text of a sign. Usually called in `on_receive_fields`.
+
+### `signs_api.set_formspec(pos)`
+Usually called in `on_construct` to set the formspec.
+
+### `signs_api.on_receive_fields(pos, formname, fields, player)`
+Helper function for `on_receive_fields`. Sets the display text and checks for protection.
+
+### `signs_api.on_place_direction(itemstack, placer, pointed_thing)`
+On place callback for direction signs (chooses which sign according to look direction).
+
+### `signs_api.on_rotate(pos, node, player, mode, new_param2)`
+Handles screwdriver rotation. Direction is affected for direction signs.
+
+### `signs_api.register_sign(mod, name, model)`
+A method to quickly register signs.
diff --git a/signs_api/common.lua b/signs_api/common.lua
new file mode 100644
index 0000000..2528ff5
--- /dev/null
+++ b/signs_api/common.lua
@@ -0,0 +1,188 @@
+--[[
+ signs mod for Minetest - Various signs with text displayed on
+ (c) Pierre-Yves Rollo
+
+ This file is part of signs.
+
+ signs is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ signs is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with signs. If not, see <http://www.gnu.org/licenses/>.
+--]]
+
+local S = signs_api.intllib
+local F = function(...) return minetest.formspec_escape(S(...)) end
+
+function signs_api.set_display_text(pos,text)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("display_text", text)
+ meta:set_string("infotext", "\""..text.."\"")
+ display_api.update_entities(pos)
+end
+
+function signs_api.set_formspec(pos)
+ local meta = minetest.get_meta(pos)
+ local ndef = minetest.registered_nodes[minetest.get_node(pos).name]
+ if ndef and ndef.display_entities and ndef.display_entities["signs:display_text"] then
+ local maxlines = ndef.display_entities["signs:display_text"].maxlines
+ local formspec
+
+ if maxlines == 1 then
+ formspec = "size[6,3]"..
+ default.gui_bg .. default.gui_bg_img .. default.gui_slots ..
+ "field[0.5,0.7;5.5,1;display_text;"..F("Text")..";${display_text}]"..
+ "button_exit[2,2;2,1;ok;"..F("Write").."]"
+ else
+ local extralabel = ""
+ if maxlines then
+ extralabel = F(" (first %s lines only)"):format(maxlines)
+ end
+
+ formspec = "size[6,4]"..
+ default.gui_bg .. default.gui_bg_img .. default.gui_slots ..
+ "textarea[0.5,0.7;5.5,2;display_text;"..F("Text")..""..extralabel..";${display_text}]"..
+ "button_exit[2,3;2,1;ok;"..F("Write").."]"
+ end
+
+ meta:set_string("formspec", formspec)
+ end
+end
+
+function signs_api.on_receive_fields(pos, formname, fields, player)
+ if not minetest.is_protected(pos, player:get_player_name()) then
+ if fields and (fields.ok or fields.key_enter) then
+ signs_api.set_display_text(pos, fields.display_text)
+ end
+ end
+end
+
+-- On place callback for direction signs
+-- (chooses which sign according to look direction)
+function signs_api.on_place_direction(itemstack, placer, pointed_thing)
+ local name = itemstack:get_name()
+ local ndef = minetest.registered_nodes[name]
+
+ local bdir = {x = pointed_thing.under.x - pointed_thing.above.x,
+ y = pointed_thing.under.y - pointed_thing.above.y,
+ z = pointed_thing.under.z - pointed_thing.above.z}
+ local pdir = placer:get_look_dir()
+
+ local ndir, test
+
+ if ndef.paramtype2 == "facedir" then
+ if bdir.x == 0 and bdir.z == 0 then
+ -- Ceiling or floor pointed (facedir chosen from player dir)
+ ndir = minetest.dir_to_facedir({x=pdir.x, y=0, z=pdir.z})
+ else
+ -- Wall pointed
+ ndir = minetest.dir_to_facedir(bdir)
+ end
+
+ test = {[0]=-pdir.x, pdir.z, pdir.x, -pdir.z}
+ end
+
+ if ndef.paramtype2 == "wallmounted" then
+ ndir = minetest.dir_to_wallmounted(bdir)
+ if ndir == 0 or ndir == 1 then
+ -- Ceiling or floor
+ ndir = minetest.dir_to_wallmounted({x=pdir.x, y=0, z=pdir.z})
+ end
+
+ test = {0, pdir.z, -pdir.z, -pdir.x, pdir.x}
+ end
+
+ -- Only for direction signs
+ if ndef.signs_other_dir then
+ if test[ndir] > 0 then
+ itemstack:set_name(ndef.signs_other_dir)
+ end
+ itemstack = minetest.item_place(itemstack, placer, pointed_thing, ndir)
+ itemstack:set_name(name)
+
+ return itemstack
+ else
+ return minetest.item_place(itemstack, placer, pointed_thing, ndir)
+ end
+end
+
+-- Handles screwdriver rotation. Direction is affected for direction signs
+function signs_api.on_rotate(pos, node, player, mode, new_param2)
+ if mode == 2 then
+ local ndef = minetest.registered_nodes[node.name]
+ if ndef.signs_other_dir then
+ minetest.swap_node(pos, {name = ndef.signs_other_dir,
+ param1 = node.param1, param2 = node.param2})
+ display_api.update_entities(pos)
+ end
+ else
+ display_api.on_rotate(pos, node, user, mode, new_param2)
+ end
+ return false;
+end
+
+function signs_api.register_sign(mod, name, model)
+ -- Default fields
+ local fields = {
+ sunlight_propagates = true,
+ paramtype = "light",
+ paramtype2 = "facedir",
+ drawtype = "nodebox",
+ node_box = {
+ type = "fixed",
+ fixed = {-model.width/2, -model.height/2, 0.5,
+ model.width/2, model.height/2, 0.5 - model.depth},
+ },
+ groups = {choppy=2, dig_immediate=2, not_blocking_trains = 1, display_modpack_node = 1},
+ sounds = default.node_sound_defaults(),
+ display_entities = {
+ ["signs:display_text"] = {
+ on_display_update = font_api.on_display_update,
+ depth = 0.5 - display_api.entity_spacing - model.depth,
+ size = { x = model.width, y = model.height },
+ resolution = { x = 64, y = 64 },
+ maxlines = 1,
+ },
+
+ },
+ on_place = display_api.on_place,
+ on_construct = function(pos)
+ signs_api.set_formspec(pos)
+ display_api.on_construct(pos)
+ end,
+ on_destruct = display_api.on_destruct,
+ on_rotate = signs_api.on_rotate,
+ on_receive_fields = signs_api.on_receive_fields,
+ on_punch = function(pos, node, player, pointed_thing) display_api.update_entities(pos) end,
+ }
+
+ -- Node fields override
+ for key, value in pairs(model.node_fields) do
+ if key == "groups" then
+ for key2, value2 in pairs(value) do
+ fields[key][key2] = value2
+ end
+ else
+ fields[key] = value
+ end
+ end
+
+ if not fields.wield_image then fields.wield_image = fields.inventory_image end
+
+ -- Entity fields override
+ for key, value in pairs(model.entity_fields) do
+ fields.display_entities["signs:display_text"][key] = value
+ end
+
+ minetest.register_node(mod..":"..name, fields)
+end
+
+-- Text entity for all signs
+display_api.register_display_entity("signs:display_text")
diff --git a/signs_api/copyright.txt b/signs_api/copyright.txt
new file mode 100644
index 0000000..b70e051
--- /dev/null
+++ b/signs_api/copyright.txt
@@ -0,0 +1,10 @@
+Code by Pierre-Yves Rollo (pyrollo)
+intllib support (i18n) by (fat115)
+intllib fallback code and tools by Diego Martínez (kaeza)
+Extra contributors:
+(gpcf)
+(Thomas--S)
+Translations:
+Muhammad Nur Hidayat Yasuyoshi (MuhdNurHidayat)
+(fat115)
+
diff --git a/signs_api/depends.txt b/signs_api/depends.txt
new file mode 100644
index 0000000..f75ffcc
--- /dev/null
+++ b/signs_api/depends.txt
@@ -0,0 +1,4 @@
+default
+intllib?
+display_api
+font_api
diff --git a/signs_api/init.lua b/signs_api/init.lua
new file mode 100644
index 0000000..c13a253
--- /dev/null
+++ b/signs_api/init.lua
@@ -0,0 +1,33 @@
+--[[
+ signs mod for Minetest - Various signs with text displayed on
+ (c) Pierre-Yves Rollo
+
+ This file is part of signs.
+
+ signs is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ signs is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with signs. If not, see <http://www.gnu.org/licenses/>.
+--]]
+
+signs_api = {}
+signs_api.name = minetest.get_current_modname()
+signs_api.path = minetest.get_modpath(signs_api.name)
+
+-- Load support for intllib.
+local S, NS = dofile(signs_api.path.."/intllib.lua")
+signs_api.intllib = S
+
+dofile(signs_api.path.."/common.lua")
+
+
+
+
diff --git a/signs_api/intllib.lua b/signs_api/intllib.lua
new file mode 100644
index 0000000..6669d72
--- /dev/null
+++ b/signs_api/intllib.lua
@@ -0,0 +1,45 @@
+
+-- Fallback functions for when `intllib` is not installed.
+-- Code released under Unlicense <http://unlicense.org>.
+
+-- Get the latest version of this file at:
+-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
+
+local function format(str, ...)
+ local args = { ... }
+ local function repl(escape, open, num, close)
+ if escape == "" then
+ local replacement = tostring(args[tonumber(num)])
+ if open == "" then
+ replacement = replacement..close
+ end
+ return replacement
+ else
+ return "@"..open..num..close
+ end
+ end
+ return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
+end
+
+local gettext, ngettext
+if minetest.get_modpath("intllib") then
+ if intllib.make_gettext_pair then
+ -- New method using gettext.
+ gettext, ngettext = intllib.make_gettext_pair()
+ else
+ -- Old method using text files.
+ gettext = intllib.Getter()
+ end
+end
+
+-- Fill in missing functions.
+
+gettext = gettext or function(msgid, ...)
+ return format(msgid, ...)
+end
+
+ngettext = ngettext or function(msgid, msgid_plural, n, ...)
+ return format(n==1 and msgid or msgid_plural, ...)
+end
+
+return gettext, ngettext
diff --git a/signs_api/locale/fr.po b/signs_api/locale/fr.po
new file mode 100644
index 0000000..e490d1b
--- /dev/null
+++ b/signs_api/locale/fr.po
@@ -0,0 +1,49 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2018-02-01 05:56+0100\n"
+"PO-Revision-Date: 2017-05-08 07:08+0200\n"
+"Last-Translator: Peppy <peppy@twang-factory.com>\n"
+"Language-Team: \n"
+"Language: fr\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.12\n"
+
+#: common.lua
+msgid "Text"
+msgstr "Texte"
+
+#: common.lua
+msgid "Write"
+msgstr "Écrire"
+
+#: common.lua
+#, lua-format
+msgid " (first %s lines only)"
+msgstr " (uniquement les %s premières lignes)"
+
+#~ msgid "Title"
+#~ msgstr "Titre"
+
+#~ msgid "Close"
+#~ msgstr "Fermer"
+
+#~ msgid "(right-click to read more text)"
+#~ msgstr "(Clic-droit pour afficher le texte entier)"
+
+#~ msgid "Wooden direction sign"
+#~ msgstr "Panneau de direction en bois"
+
+#~ msgid "Poster"
+#~ msgstr "Affiche"
+
+#~ msgid "Textd"
+#~ msgstr "Texte"
diff --git a/signs_api/locale/ms.po b/signs_api/locale/ms.po
new file mode 100644
index 0000000..9c8aab8
--- /dev/null
+++ b/signs_api/locale/ms.po
@@ -0,0 +1,46 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Muhammad Nur Hidayat <muhdnurhidayat96@yahoo.com>, 2017.
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2018-02-01 05:56+0100\n"
+"PO-Revision-Date: 2017-08-27 15:50+0800\n"
+"Last-Translator: Muhammad Nur Hidayat <muhdnurhidayat96@yahoo.com>\n"
+"Language-Team: Malay <muhdnurhidayat96@yahoo.com>\n"
+"Language: ms\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+"X-Generator: Vé 0.1.4\n"
+
+#: common.lua
+msgid "Text"
+msgstr "Teks"
+
+#: common.lua
+msgid "Write"
+msgstr "Tulis"
+
+#: common.lua
+#, lua-format
+msgid " (first %s lines only)"
+msgstr "( %s baris pertama sahaja )"
+
+#~ msgid "Title"
+#~ msgstr "Tajuk"
+
+#~ msgid "Close"
+#~ msgstr "Tutup"
+
+#~ msgid "(right-click to read more text)"
+#~ msgstr "(klik-kanan untuk baca teks penuh)"
+
+#~ msgid "Wooden direction sign"
+#~ msgstr "Papan tanda arah kayu"
+
+#~ msgid "Poster"
+#~ msgstr "Poster"
diff --git a/signs_api/locale/template.pot b/signs_api/locale/template.pot
new file mode 100644
index 0000000..6004024
--- /dev/null
+++ b/signs_api/locale/template.pot
@@ -0,0 +1,31 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2018-02-01 05:56+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: common.lua
+msgid "Text"
+msgstr ""
+
+#: common.lua
+msgid "Write"
+msgstr ""
+
+#: common.lua
+#, lua-format
+msgid " (first %s lines only)"
+msgstr ""
diff --git a/signs_api/tools/updatepo.sh b/signs_api/tools/updatepo.sh
new file mode 100755
index 0000000..feb2504
--- /dev/null
+++ b/signs_api/tools/updatepo.sh
@@ -0,0 +1,25 @@
+#! /bin/bash
+
+# To create a new translation:
+# msginit --locale=ll_CC -o locale/ll_CC.po -i locale/template.pot
+
+cd "$(dirname "${BASH_SOURCE[0]}")/..";
+
+# Extract translatable strings.
+xgettext --from-code=UTF-8 \
+ --language=Lua \
+ --sort-by-file \
+ --keyword=S \
+ --keyword=NS:1,2 \
+ --keyword=N_ \
+ --keyword=F \
+ --add-comments='Translators:' \
+ --add-location=file \
+ -o locale/template.pot \
+ $(find . -name '*.lua')
+
+# Update translations.
+find locale -name '*.po' | while read -r file; do
+ echo $file
+ msgmerge --update $file locale/template.pot;
+done
diff --git a/signs_road/compatibility.lua b/signs_road/compatibility.lua
index fa5f94b..9e6b29b 100644
--- a/signs_road/compatibility.lua
+++ b/signs_road/compatibility.lua
@@ -45,9 +45,9 @@ local function compatibility_check(pos, node)
node.name = convert_nodes[node.name]
if node.name then
node.param2 = wallmounted_to_facedir[node.param2]
- display_lib.on_destruct(pos)
+ display_api.on_destruct(pos)
minetest.swap_node(pos, node)
- display_lib.on_construct(pos)
+ display_api.on_construct(pos)
end
end
@@ -69,7 +69,7 @@ local function compatibility_check_2(pos, node)
end
end
-- Create new entity
- display_lib.update_entities(pos)
+ display_api.update_entities(pos)
end
minetest.register_lbm({ name = "signs_road:conpatibility_2",
diff --git a/signs_road/depends.txt b/signs_road/depends.txt
index 730e727..eeb3b01 100644
--- a/signs_road/depends.txt
+++ b/signs_road/depends.txt
@@ -1,6 +1,6 @@
default
intllib?
dye
-display_lib
-font_lib
-signs
+display_api
+font_api
+signs_api
diff --git a/signs_road/nodes.lua b/signs_road/nodes.lua
index b167db8..c4c0b04 100644
--- a/signs_road/nodes.lua
+++ b/signs_road/nodes.lua
@@ -131,7 +131,7 @@ local models = {
width = 1,
height = 0.5,
entity_fields = {
- resolution = { x = 7, y = 5 },
+ resolution = { x = 7, y = 5 },
maxlines = 1,
color = "#000",
},
@@ -142,8 +142,8 @@ local models = {
"signs_road_sides.png", "signs_road_black_dir_right.png" },
inventory_image = "signs_road_black_dir_inventory.png",
signs_other_dir = "signs_road:black_left_sign",
- on_place = signs.on_place_direction,
- on_rightclick = signs.on_right_click_direction,
+ on_place = signs_api.on_place_direction,
+ on_rightclick = signs_api.on_right_click_direction,
},
},
black_left_sign = {
@@ -164,8 +164,8 @@ local models = {
signs_other_dir = "signs_road:black_right_sign",
groups = { not_in_creative_inventory = 1 },
drop = "signs_road:black_right_sign",
- on_place = signs.on_place_direction,
- on_rightclick = signs.on_right_click_direction,
+ on_place = signs_api.on_place_direction,
+ on_rightclick = signs_api.on_right_click_direction,
},
},
@@ -174,7 +174,7 @@ local models = {
width = 14/16,
height = 7/16,
entity_fields = {
- right = -3/32,
+ right = -3/32,
size = { x = 12/16, y = 6/16 },
resolution = { x = 9, y = 5.5 },
maxlines = 2,
@@ -185,8 +185,8 @@ local models = {
tiles = { "signs_road_green_direction.png" },
inventory_image = "signs_road_green_dir_inventory.png",
signs_other_dir = "signs_road:green_left_sign",
- on_place = signs.on_place_direction,
- on_rightclick = signs.on_right_click_direction,
+ on_place = signs_api.on_place_direction,
+ on_rightclick = signs_api.on_right_click_direction,
drawtype = "mesh",
mesh = "signs_dir_right.obj",
selection_box = { type = "fixed", fixed = { -0.5, -7/32, 0.5, 7/16, 7/32, 7/16 } },
@@ -198,7 +198,7 @@ local models = {
width = 14/16,
height = 7/16,
entity_fields = {
- right = 3/32,
+ right = 3/32,
size = { x = 12/16, y = 6/16 },
resolution = { x = 9, y = 5.5 },
maxlines = 2,
@@ -209,8 +209,8 @@ local models = {
tiles = { "signs_road_green_direction.png" },
inventory_image = "signs_road_green_dir_inventory.png",
signs_other_dir = "signs_road:green_right_sign",
- on_place = signs.on_place_direction,
- on_rightclick = signs.on_right_click_direction,
+ on_place = signs_api.on_place_direction,
+ on_rightclick = signs_api.on_right_click_direction,
drawtype = "mesh",
mesh = "signs_dir_left.obj",
selection_box = { type = "fixed", fixed = { -7/16, -7/32, 0.5, 0.5, 7/32, 7/16 } },
@@ -224,7 +224,7 @@ local models = {
width = 14/16,
height = 7/16,
entity_fields = {
- right = -3/32,
+ right = -3/32,
size = { x = 12/16, y = 6/16 },
resolution = { x = 9, y = 5.5 },
maxlines = 2,
@@ -235,8 +235,8 @@ local models = {
tiles = { "signs_road_yellow_direction.png" },
inventory_image = "signs_road_yellow_dir_inventory.png",
signs_other_dir = "signs_road:yellow_left_sign",
- on_place = signs.on_place_direction,
- on_rightclick = signs.on_right_click_direction,
+ on_place = signs_api.on_place_direction,
+ on_rightclick = signs_api.on_right_click_direction,
drawtype = "mesh",
mesh = "signs_dir_right.obj",
selection_box = { type = "fixed", fixed = { -0.5, -7/32, 0.5, 7/16, 7/32, 7/16 } },
@@ -248,7 +248,7 @@ local models = {
width = 14/16,
height = 7/16,
entity_fields = {
- right = 3/32,
+ right = 3/32,
size = { x = 12/16, y = 6/16 },
resolution = { x = 9, y = 5.5 },
maxlines = 2,
@@ -259,8 +259,8 @@ local models = {
tiles = { "signs_road_yellow_direction.png" },
inventory_image = "signs_road_yellow_dir_inventory.png",
signs_other_dir = "signs_road:yellow_right_sign",
- on_place = signs.on_place_direction,
- on_rightclick = signs.on_right_click_direction,
+ on_place = signs_api.on_place_direction,
+ on_rightclick = signs_api.on_right_click_direction,
drawtype = "mesh",
mesh = "signs_dir_left.obj",
selection_box = { type = "fixed", fixed = { -7/16, -7/32, 0.5, 0.5, 7/32, 7/16 } },
@@ -274,7 +274,7 @@ local models = {
width = 14/16,
height = 7/16,
entity_fields = {
- right = -3/32,
+ right = -3/32,
size = { x = 12/16, y = 6/16 },
resolution = { x = 9, y = 5.5 },
maxlines = 2,
@@ -285,8 +285,8 @@ local models = {
tiles = { "signs_road_white_direction.png" },
inventory_image = "signs_road_white_dir_inventory.png",
signs_other_dir = "signs_road:white_left_sign",
- on_place = signs.on_place_direction,
- on_rightclick = signs.on_right_click_direction,
+ on_place = signs_api.on_place_direction,
+ on_rightclick = signs_api.on_right_click_direction,
drawtype = "mesh",
mesh = "signs_dir_right.obj",
selection_box = { type = "fixed", fixed = { -0.5, -7/32, 0.5, 7/16, 7/32, 7/16 } },
@@ -298,7 +298,7 @@ local models = {
width = 14/16,
height = 7/16,
entity_fields = {
- right = 3/32,
+ right = 3/32,
size = { x = 12/16, y = 6/16 },
resolution = { x = 9, y = 5.5 },
maxlines = 2,
@@ -309,8 +309,8 @@ local models = {
tiles = { "signs_road_white_direction.png" },
inventory_image = "signs_road_white_dir_inventory.png",
signs_other_dir = "signs_road:white_right_sign",
- on_place=signs.on_place_direction,
- on_rightclick = signs.on_right_click_direction,
+ on_place=signs_api.on_place_direction,
+ on_rightclick = signs_api.on_right_click_direction,
drawtype = "mesh",
mesh = "signs_dir_left.obj",
selection_box = { type = "fixed", fixed = { -7/16, -7/32, 0.5, 0.5, 7/32, 7/16 } },
@@ -324,7 +324,7 @@ local models = {
-- Node registration
for name, model in pairs(models)
do
- signs.register_sign("signs_road", name, model)
+ signs_api.register_sign("signs_road", name, model)
end
diff --git a/steles/depends.txt b/steles/depends.txt
index 35625c0..ba43223 100644
--- a/steles/depends.txt
+++ b/steles/depends.txt
@@ -1,5 +1,5 @@
default
intllib?
-display_lib
-font_lib
+display_api
+font_api
technic?
diff --git a/steles/nodes.lua b/steles/nodes.lua
index d2fb504..eabb096 100644
--- a/steles/nodes.lua
+++ b/steles/nodes.lua
@@ -21,7 +21,7 @@
local S = steles.intllib
local F = function(...) return minetest.formspec_escape(S(...)) end
-display_lib.register_display_entity("steles:text")
+display_api.register_display_entity("steles:text")
for i, material in ipairs(steles.materials) do
@@ -30,7 +30,7 @@ for i, material in ipairs(steles.materials) do
if ndef then
local groups = table.copy(ndef.groups)
local parts = material:split(":")
- groups.display_lib_node = 1
+ groups.display_modpack_node = 1
minetest.register_node("steles:"..parts[2].."_stele", {
description = steles.materials_desc[i],
@@ -49,8 +49,8 @@ for i, material in ipairs(steles.materials) do
groups = groups,
display_entities = {
["steles:text"] = {
- on_display_update = font_lib.on_display_update,
- depth = -2/16 - display_lib.entity_spacing, height = 2/16,
+ on_display_update = font_api.on_display_update,
+ depth = -2/16 - display_api.entity_spacing, height = 2/16,
size = { x = 14/16, y = 12/16 },
resolution = { x = 11, y = 5 },
maxlines = 3,
@@ -58,7 +58,7 @@ for i, material in ipairs(steles.materials) do
},
on_place = function(itemstack, placer, pointed_thing)
minetest.rotate_node(itemstack, placer, pointed_thing)
- display_lib.on_place(itemstack, placer, pointed_thing)
+ display_api.on_place(itemstack, placer, pointed_thing)
end,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
@@ -68,21 +68,21 @@ for i, material in ipairs(steles.materials) do
..F("Displayed text (3 lines max)")
..";${display_text}]"
.."button_exit[2,3;2,1;ok;"..F("Write").."]")
- display_lib.on_construct(pos)
+ display_api.on_construct(pos)
end,
- on_destruct = display_lib.on_destruct,
- on_rotate = display_lib.on_rotate,
+ on_destruct = display_api.on_destruct,
+ on_rotate = display_api.on_rotate,
on_receive_fields = function(pos, formname, fields, player)
if not minetest.is_protected(pos, player:get_player_name()) then
local meta = minetest.get_meta(pos)
if fields and fields.ok then
meta:set_string("display_text", fields.display_text)
meta:set_string("infotext", "\""..fields.display_text.."\"")
- display_lib.update_entities(pos)
+ display_api.update_entities(pos)
end
end
end,
- on_punch = display_lib.update_entities,
+ on_punch = display_api.update_entities,
})
end
end