aboutsummaryrefslogtreecommitdiff
path: root/ontime_clocks
diff options
context:
space:
mode:
authorNiklp <89982526+Niklp09@users.noreply.github.com>2023-07-24 09:59:26 +0200
committerGitHub <noreply@github.com>2023-07-24 09:59:26 +0200
commit1440f35fa62fd2c01b4844261290c88e42d2430f (patch)
treee42db53056e5d6f1c4fd562a924934081ae787c4 /ontime_clocks
parente0e03058362e038d07d4063c4fbd6999ad27109c (diff)
downloaddisplay_modpack_no_craft-1440f35fa62fd2c01b4844261290c88e42d2430f.tar.gz
display_modpack_no_craft-1440f35fa62fd2c01b4844261290c88e42d2430f.zip
Add luacheck, update translations, replace ABMs, bug fixes (#1)
* luacheck, mt 5 translation, german translation, maintenance * fix luacheck warnings * Fix digital clock nodebox and texture * Fix luacheck usage * Add comment why fonts are not split into several lines
Diffstat (limited to 'ontime_clocks')
-rw-r--r--ontime_clocks/common.lua6
-rw-r--r--ontime_clocks/crafts.lua2
-rw-r--r--ontime_clocks/init.lua7
-rw-r--r--ontime_clocks/intllib.lua45
-rw-r--r--ontime_clocks/locale/fr.po43
-rw-r--r--ontime_clocks/locale/ms.po42
-rw-r--r--ontime_clocks/locale/ontime_clocks.de.tr7
-rw-r--r--ontime_clocks/locale/ontime_clocks.fr.tr7
-rw-r--r--ontime_clocks/locale/ontime_clocks.ms.tr7
-rw-r--r--ontime_clocks/locale/template.pot42
-rw-r--r--ontime_clocks/locale/template.txt7
-rw-r--r--ontime_clocks/mod.conf1
-rw-r--r--ontime_clocks/nodes.lua89
-rw-r--r--ontime_clocks/textures/ontime_clocks_green_digital_inventory.pngbin175 -> 164 bytes
-rwxr-xr-xontime_clocks/tools/updatepo.sh25
15 files changed, 75 insertions, 255 deletions
diff --git a/ontime_clocks/common.lua b/ontime_clocks/common.lua
index cced299..2c7639f 100644
--- a/ontime_clocks/common.lua
+++ b/ontime_clocks/common.lua
@@ -1,5 +1,5 @@
--[[
- ontime_clocks mod for Minetest - Clock nodes displaying ingame time
+ ontime_clocks mod for Minetest - Clock nodes displaying ingame time
(c) Pierre-Yves Rollo
This file is part of ontime_clocks.
@@ -34,7 +34,7 @@ function ontime_clocks.get_m12()
end
function ontime_clocks.get_digital_properties(color_off, color_on, hour, minute)
- return
+ return
{
textures={"ontime_clocks_digital_background.png^[colorize:"..color_off
.."^([combine:21x7"
@@ -51,7 +51,7 @@ end
function ontime_clocks.get_needles_properties(color, size, hour, minute)
return
{
- textures={"[combine:"..size.."x"..size
+ textures={"[combine:"..size.."x"..size
..":0,"..(-size*hour).."=ontime_clocks_needle_h"..size..".png"
..":0,"..(-size*minute).."=ontime_clocks_needle_m"..size..".png"
.."^[colorize:"..color},
diff --git a/ontime_clocks/crafts.lua b/ontime_clocks/crafts.lua
index c94352a..9eab3a9 100644
--- a/ontime_clocks/crafts.lua
+++ b/ontime_clocks/crafts.lua
@@ -1,5 +1,5 @@
--[[
- ontime_clocks mod for Minetest - Clock nodes displaying ingame time
+ ontime_clocks mod for Minetest - Clock nodes displaying ingame time
(c) Pierre-Yves Rollo
This file is part of ontime_clocks.
diff --git a/ontime_clocks/init.lua b/ontime_clocks/init.lua
index d0ac334..83edcdb 100644
--- a/ontime_clocks/init.lua
+++ b/ontime_clocks/init.lua
@@ -1,5 +1,5 @@
--[[
- ontime_clocks mod for Minetest - Clock nodes displaying ingame time
+ ontime_clocks mod for Minetest - Clock nodes displaying ingame time
(c) Pierre-Yves Rollo
This file is part of ontime_clocks.
@@ -22,9 +22,8 @@ ontime_clocks = {}
ontime_clocks.name = minetest.get_current_modname()
ontime_clocks.path = minetest.get_modpath(ontime_clocks.name)
--- Load support for intllib.
-local S, NS = dofile(ontime_clocks.path.."/intllib.lua")
-ontime_clocks.intllib = S
+-- Translation support
+ontime_clocks.S = minetest.get_translator(ontime_clocks.name)
dofile(ontime_clocks.path.."/common.lua")
dofile(ontime_clocks.path.."/nodes.lua")
diff --git a/ontime_clocks/intllib.lua b/ontime_clocks/intllib.lua
deleted file mode 100644
index 6669d72..0000000
--- a/ontime_clocks/intllib.lua
+++ /dev/null
@@ -1,45 +0,0 @@
-
--- 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/ontime_clocks/locale/fr.po b/ontime_clocks/locale/fr.po
deleted file mode 100644
index ed5d2b4..0000000
--- a/ontime_clocks/locale/fr.po
+++ /dev/null
@@ -1,43 +0,0 @@
-# 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: 2017-08-05 09:50+0200\n"
-"PO-Revision-Date: 2017-05-08 06:20+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"
-"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-
-#: nodes.lua
-msgid "Green digital clock"
-msgstr "Horloge numérique verte"
-
-#: nodes.lua
-msgid "Red digital clock"
-msgstr "Horloge numérique rouge"
-
-#: nodes.lua
-msgid "White clock"
-msgstr "Horloge blanche"
-
-#: nodes.lua
-msgid "Frameless clock"
-msgstr "Horloge sans cadre"
-
-#: nodes.lua
-msgid "Frameless gold clock"
-msgstr "Horloge dorée sans cadre"
-
-#: nodes.lua
-msgid "Frameless white clock"
-msgstr "Horloge blanche sans cadre"
diff --git a/ontime_clocks/locale/ms.po b/ontime_clocks/locale/ms.po
deleted file mode 100644
index 4d52ac2..0000000
--- a/ontime_clocks/locale/ms.po
+++ /dev/null
@@ -1,42 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# Yaya (Nurul Azeera Hidayah @ Muhammad Nur Hidayat) <translation@mnh48.moe>, 2017.
-msgid ""
-msgstr ""
-"Project-Id-Version: Display Modpack\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2017-08-26 11:21+0200\n"
-"PO-Revision-Date: 2020-07-05 11:32+0000\n"
-"Last-Translator: Yaya MNH48 <translation@mnh48.moe>\n"
-"Language-Team: Malay <translation@mnh48.moe>\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: Poedit 2.3\n"
-
-#: nodes.lua
-msgid "Green digital clock"
-msgstr "Jam digital hijau"
-
-#: nodes.lua
-msgid "Red digital clock"
-msgstr "Jam digital merah"
-
-#: nodes.lua
-msgid "White clock"
-msgstr "Jam putih"
-
-#: nodes.lua
-msgid "Frameless clock"
-msgstr "Jam tanpa bingkai"
-
-#: nodes.lua
-msgid "Frameless gold clock"
-msgstr "Jam emas tanpa bingkai"
-
-#: nodes.lua
-msgid "Frameless white clock"
-msgstr "Jam putih tanpa bingkai"
diff --git a/ontime_clocks/locale/ontime_clocks.de.tr b/ontime_clocks/locale/ontime_clocks.de.tr
new file mode 100644
index 0000000..5bdb660
--- /dev/null
+++ b/ontime_clocks/locale/ontime_clocks.de.tr
@@ -0,0 +1,7 @@
+# textdomain: ontime_clocks
+Green digital clock=Grüne Digitaluhr
+Red digital clock=Rote Digitaluhr
+White clock=Weiße Uhr
+Frameless clock=Rahmenlose Uhr
+Frameless gold clock=Rahmenlose goldene Uhr
+Frameless white clock=Rahmenlose weiße Uhr
diff --git a/ontime_clocks/locale/ontime_clocks.fr.tr b/ontime_clocks/locale/ontime_clocks.fr.tr
new file mode 100644
index 0000000..fdc8ccf
--- /dev/null
+++ b/ontime_clocks/locale/ontime_clocks.fr.tr
@@ -0,0 +1,7 @@
+# textdomain: ontime_clocks
+Green digital clock=Horloge numérique verte
+Red digital clock=Horloge numérique rouge
+White clock=Horloge blanche
+Frameless clock=Horloge sans cadre
+Frameless gold clock=Horloge dorée sans cadre
+Frameless white clock=Horloge blanche sans cadre
diff --git a/ontime_clocks/locale/ontime_clocks.ms.tr b/ontime_clocks/locale/ontime_clocks.ms.tr
new file mode 100644
index 0000000..0478935
--- /dev/null
+++ b/ontime_clocks/locale/ontime_clocks.ms.tr
@@ -0,0 +1,7 @@
+# textdomain: ontime_clocks
+Green digital clock=Jam digital hijau
+Red digital clock=Jam digital merah
+White clock=Jam putih
+Frameless clock=Jam tanpa bingkai
+Frameless gold clock=Jam emas tanpa bingkai
+Frameless white clock=Jam putih tanpa bingkai
diff --git a/ontime_clocks/locale/template.pot b/ontime_clocks/locale/template.pot
deleted file mode 100644
index dca736f..0000000
--- a/ontime_clocks/locale/template.pot
+++ /dev/null
@@ -1,42 +0,0 @@
-# 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: 2017-08-26 11:21+0200\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"
-
-#: nodes.lua
-msgid "Green digital clock"
-msgstr ""
-
-#: nodes.lua
-msgid "Red digital clock"
-msgstr ""
-
-#: nodes.lua
-msgid "White clock"
-msgstr ""
-
-#: nodes.lua
-msgid "Frameless clock"
-msgstr ""
-
-#: nodes.lua
-msgid "Frameless gold clock"
-msgstr ""
-
-#: nodes.lua
-msgid "Frameless white clock"
-msgstr ""
diff --git a/ontime_clocks/locale/template.txt b/ontime_clocks/locale/template.txt
new file mode 100644
index 0000000..6db07cb
--- /dev/null
+++ b/ontime_clocks/locale/template.txt
@@ -0,0 +1,7 @@
+# textdomain: ontime_clocks
+Green digital clock=
+Red digital clock=
+White clock=
+Frameless clock=
+Frameless gold clock=
+Frameless white clock=
diff --git a/ontime_clocks/mod.conf b/ontime_clocks/mod.conf
index f6afbde..144b266 100644
--- a/ontime_clocks/mod.conf
+++ b/ontime_clocks/mod.conf
@@ -2,4 +2,3 @@ name = ontime_clocks
title = Ontime Clocks
description = Clocks displaing real ingame time
depends = default,dye,display_api
-optional_depends = intllib
diff --git a/ontime_clocks/nodes.lua b/ontime_clocks/nodes.lua
index 107d2e9..dcdcbdd 100644
--- a/ontime_clocks/nodes.lua
+++ b/ontime_clocks/nodes.lua
@@ -18,7 +18,18 @@
along with ontime_clocks. If not, see <http://www.gnu.org/licenses/>.
--]]
-local S = ontime_clocks.intllib
+local S = ontime_clocks.S
+
+local function clock_on_construct(pos)
+ local timer = minetest.get_node_timer(pos)
+ timer:start(5)
+ display_api.on_construct(pos)
+end
+
+local function clock_on_timer(pos)
+ display_api.update_entities(pos)
+ return true
+end
-- Green digital clock
minetest.register_node("ontime_clocks:green_digital", {
@@ -30,9 +41,9 @@ minetest.register_node("ontime_clocks:green_digital", {
drawtype = "nodebox",
node_box = {
type = "wallmounted",
- wall_side = { -0.5, -3/16, -7/16, -13/32, 7/32, 7/16 },
- wall_top = { -7/16, 0.5, -7/32, 7/16, 13/32, 3/16 },
- wall_bottom = { -7/16, -0.5, -3/16, 7/16, -13/32, 7/32 },
+ wall_side = {-0.5, -3/16, -7/16, -13/32, 7/32, 7/16},
+ wall_bottom = {-7/16, -0.5, -3/16, 7/16, -13/32, 7/32},
+ wall_top = {-7/16, 0.5, -7/32, 7/16, 13/32, 3/16}
},
tiles = {"ontime_clocks_digital.png"},
groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1},
@@ -46,17 +57,12 @@ minetest.register_node("ontime_clocks:green_digital", {
end },
},
on_place = display_api.on_place,
- on_construct = display_api.on_construct,
+ on_construct = clock_on_construct,
on_destruct = display_api.on_destruct,
on_rotate = display_api.on_rotate,
+ on_timer = clock_on_timer,
})
-minetest.register_abm({
- nodenames = {"ontime_clocks:green_digital"},
- interval = 5,
- chance = 1,
- action = display_api.update_entities,
-})
-- Red digital clock
minetest.register_node("ontime_clocks:red_digital", {
@@ -68,9 +74,9 @@ minetest.register_node("ontime_clocks:red_digital", {
drawtype = "nodebox",
node_box = {
type = "wallmounted",
- wall_side = { -0.5, -3/16, -7/16, -13/32, 7/32, 7/16 },
- wall_bottom = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 },
- wall_top = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
+ wall_side = {-0.5, -3/16, -7/16, -13/32, 7/32, 7/16},
+ wall_bottom = {-7/16, -0.5, -3/16, 7/16, -13/32, 7/32},
+ wall_top = {-7/16, 0.5, -7/32, 7/16, 13/32, 3/16}
},
tiles = {"ontime_clocks_digital.png"},
groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1},
@@ -84,16 +90,10 @@ minetest.register_node("ontime_clocks:red_digital", {
end },
},
on_place = display_api.on_place,
- on_construct = display_api.on_construct,
+ on_construct = clock_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_api.update_entities,
+ on_timer = clock_on_timer,
})
@@ -122,17 +122,12 @@ minetest.register_node("ontime_clocks:white", {
end },
},
on_place = display_api.on_place,
- on_construct = display_api.on_construct,
+ on_construct = clock_on_construct,
on_destruct = display_api.on_destruct,
on_rotate = display_api.on_rotate,
+ on_timer = clock_on_timer,
})
-minetest.register_abm({
- nodenames = {"ontime_clocks:white"},
- interval = 5,
- chance = 1,
- action = display_api.update_entities,
-})
minetest.register_node("ontime_clocks:frameless_black", {
description = S("Frameless clock"),
@@ -159,17 +154,12 @@ minetest.register_node("ontime_clocks:frameless_black", {
end },
},
on_place = display_api.on_place,
- on_construct = display_api.on_construct,
+ on_construct = clock_on_construct,
on_destruct = display_api.on_destruct,
on_rotate = display_api.on_rotate,
+ on_timer = clock_on_timer,
})
-minetest.register_abm({
- nodenames = {"ontime_clocks:frameless_black"},
- interval = 5,
- chance = 1,
- action = display_api.update_entities,
-})
minetest.register_node("ontime_clocks:frameless_gold", {
description = S("Frameless gold clock"),
@@ -196,17 +186,12 @@ minetest.register_node("ontime_clocks:frameless_gold", {
end },
},
on_place = display_api.on_place,
- on_construct = display_api.on_construct,
+ on_construct = clock_on_construct,
on_destruct = display_api.on_destruct,
on_rotate = display_api.on_rotate,
+ on_timer = clock_on_timer,
})
-minetest.register_abm({
- nodenames = {"ontime_clocks:frameless_gold"},
- interval = 5,
- chance = 1,
- action = display_api.update_entities,
-})
minetest.register_node("ontime_clocks:frameless_white", {
description = S("Frameless white clock"),
@@ -233,14 +218,20 @@ minetest.register_node("ontime_clocks:frameless_white", {
end },
},
on_place = display_api.on_place,
- on_construct = display_api.on_construct,
+ on_construct = clock_on_construct,
on_destruct = display_api.on_destruct,
on_rotate = display_api.on_rotate,
+ on_timer = clock_on_timer,
})
-minetest.register_abm({
- nodenames = {"ontime_clocks:frameless_white"},
- interval = 5,
- chance = 1,
- action = display_api.update_entities,
+
+minetest.register_lbm({
+ name = "ontime_clocks:nodetimer_init",
+ nodenames = {"ontime_clocks:green_digital", "ontime_clocks:red_digital", "ontime_clocks:white",
+ "ontime_clocks:frameless_black", "ontime_clocks:frameless_gold", "ontime_clocks:frameless_white"},
+ run_at_every_load = false,
+ action = function(pos)
+ local timer = minetest.get_node_timer(pos)
+ timer:start(5)
+ end
})
diff --git a/ontime_clocks/textures/ontime_clocks_green_digital_inventory.png b/ontime_clocks/textures/ontime_clocks_green_digital_inventory.png
index 2bf9043..5bd3d60 100644
--- a/ontime_clocks/textures/ontime_clocks_green_digital_inventory.png
+++ b/ontime_clocks/textures/ontime_clocks_green_digital_inventory.png
Binary files differ
diff --git a/ontime_clocks/tools/updatepo.sh b/ontime_clocks/tools/updatepo.sh
deleted file mode 100755
index feb2504..0000000
--- a/ontime_clocks/tools/updatepo.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#! /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