From bfee841c7abf9e57f20e8032eda39b116bf214d5 Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Tue, 6 Jun 2023 13:43:00 -0400 Subject: [PATCH] compatibility layer to work with MT 0.4.16 engine * use intlib if present if not mock the translation function * do not miss thirth parameter in the force register function of nodes * better (in sync with minenux) description * add depends.txt and description.txt files with such information for 0.4 * lower the requirements in mod.conf file so * minor update to README then --- README.md | 3 ++- depends.txt | 10 ++++++++++ description.txt | 1 + init.lua | 25 +++++++++++++++++++++++++ mod.conf | 4 ++-- src/chess.lua | 2 +- src/cooking.lua | 2 +- src/enchanting.lua | 2 +- src/hive.lua | 2 +- src/itemframe.lua | 2 +- src/mailbox.lua | 2 +- src/mechanisms.lua | 2 +- src/nodes.lua | 18 +++++++++--------- src/rope.lua | 2 +- src/workbench.lua | 2 +- 15 files changed, 58 insertions(+), 21 deletions(-) create mode 100644 depends.txt create mode 100644 description.txt diff --git a/README.md b/README.md index 05340a2..3aea3b6 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ It adds a bunch of cute cubes, various mechanisms and stuff for [cutting](https: This mod is a lightweight alternative to HomeDecor and MoreBlocks. ### Requirements ### -This mod requires at least version 5.1 of Minetest. + +This mod requires at least version 0.4.16 of Minetest. ### Credits ### diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..c582a68 --- /dev/null +++ b/depends.txt @@ -0,0 +1,10 @@ +default +bucket +doors +farming +stairs +xpanes +fire? +oresplus? +moreblocks? +mesecons? diff --git a/description.txt b/description.txt new file mode 100644 index 0000000..8738846 --- /dev/null +++ b/description.txt @@ -0,0 +1 @@ +HOME decoration mod meant to be simple diff --git a/init.lua b/init.lua index 1399a1c..79d63aa 100644 --- a/init.lua +++ b/init.lua @@ -3,6 +3,31 @@ xdecor = {} local modpath = minetest.get_modpath("xdecor") +-- Intllib +local S +if minetest.get_translator ~= nil then + S = minetest.get_translator("xdecor") -- 5.x translation function +else + if minetest.get_modpath("intllib") then + dofile(minetest.get_modpath("intllib") .. "/init.lua") + if intllib.make_gettext_pair then + gettext, ngettext = intllib.make_gettext_pair() -- new gettext method + else + gettext = intllib.Getter() -- old text file method + end + S = gettext + else -- boilerplate function + S = function(str, ...) + local args = {...} + return str:gsub("@%d+", function(match) + return args[tonumber(match:sub(2))] + end) + end + end +end + +xdecor.S = S + dofile(modpath .. "/handlers/animations.lua") dofile(modpath .. "/handlers/helpers.lua") dofile(modpath .. "/handlers/nodeboxes.lua") diff --git a/mod.conf b/mod.conf index 62a4a4d..5ae1cae 100644 --- a/mod.conf +++ b/mod.conf @@ -1,5 +1,5 @@ name = xdecor -description = A decoration mod meant to be simple and well-featured. +description = HOME decoration mod meant to be simple depends = default, bucket, doors, farming, stairs, xpanes optional_depends = fire, oresplus, moreblocks, mesecons -min_minetest_version = 5.1.0 +min_minetest_version = 0.4.16 diff --git a/src/chess.lua b/src/chess.lua index fd34859..15c2dc1 100644 --- a/src/chess.lua +++ b/src/chess.lua @@ -1,5 +1,5 @@ local realchess = {} -local S = minetest.get_translator("xdecor") +local S = xdecor.S local FS = function(...) return minetest.formspec_escape(S(...)) end local ALPHA_OPAQUE = minetest.features.use_texture_alpha_string_modes and "opaque" or false screwdriver = screwdriver or {} diff --git a/src/cooking.lua b/src/cooking.lua index 8abcb14..3dae2f4 100644 --- a/src/cooking.lua +++ b/src/cooking.lua @@ -1,5 +1,5 @@ local cauldron, sounds = {}, {} -local S = minetest.get_translator("xdecor") +local S = xdecor.S -- Add more ingredients here that make a soup. local ingredients_list = { diff --git a/src/enchanting.lua b/src/enchanting.lua index fd07336..508d42e 100644 --- a/src/enchanting.lua +++ b/src/enchanting.lua @@ -1,5 +1,5 @@ screwdriver = screwdriver or {} -local S = minetest.get_translator("xdecor") +local S = xdecor.S local FS = function(...) return minetest.formspec_escape(S(...)) end local ceil, abs, random = math.ceil, math.abs, math.random local reg_tools = minetest.registered_tools diff --git a/src/hive.lua b/src/hive.lua index 2aa9910..9aae303 100644 --- a/src/hive.lua +++ b/src/hive.lua @@ -1,5 +1,5 @@ local hive = {} -local S = minetest.get_translator("xdecor") +local S = xdecor.S local FS = function(...) return minetest.formspec_escape(S(...)) end local honey_max = 16 diff --git a/src/itemframe.lua b/src/itemframe.lua index 38dcc0a..9465501 100644 --- a/src/itemframe.lua +++ b/src/itemframe.lua @@ -1,5 +1,5 @@ local itemframe, tmp = {}, {} -local S = minetest.get_translator("xdecor") +local S = xdecor.S screwdriver = screwdriver or {} local function remove_item(pos, node) diff --git a/src/mailbox.lua b/src/mailbox.lua index 78a3ed3..8d7439c 100644 --- a/src/mailbox.lua +++ b/src/mailbox.lua @@ -1,6 +1,6 @@ local mailbox = {} screwdriver = screwdriver or {} -local S = minetest.get_translator("xdecor") +local S = xdecor.S local FS = function(...) return minetest.formspec_escape(S(...)) end local function get_img(img) diff --git a/src/mechanisms.lua b/src/mechanisms.lua index a758f45..d9d723e 100644 --- a/src/mechanisms.lua +++ b/src/mechanisms.lua @@ -3,7 +3,7 @@ local plate = {} screwdriver = screwdriver or {} -local S = minetest.get_translator("xdecor") +local S = xdecor.S local ALPHA_OPAQUE = minetest.features.use_texture_alpha_string_modes and "opaque" or false local function door_toggle(pos_actuator, pos_door, player) diff --git a/src/nodes.lua b/src/nodes.lua index 256e819..cecb04e 100644 --- a/src/nodes.lua +++ b/src/nodes.lua @@ -1,5 +1,5 @@ screwdriver = screwdriver or {} -local S = minetest.get_translator("xdecor") +local S = xdecor.S local ALPHA_CLIP = minetest.features.use_texture_alpha_string_modes and "clip" or true local ALPHA_OPAQUE = minetest.features.use_texture_alpha_string_modes and "opaque" or false @@ -540,7 +540,7 @@ xdecor.register("stonepath", { }) local function register_hard_node(name, desc, def) - def = def or {} + if def == nil then def = { groups = {cracky=1}, sounds = default.node_sound_stone_defaults() } end xdecor.register(name, { description = desc, tiles = {"xdecor_" .. name .. ".png"}, @@ -549,13 +549,13 @@ local function register_hard_node(name, desc, def) }) end -register_hard_node("cactusbrick", S("Cactus Brick")) -register_hard_node("coalstone_tile", S("Coal Stone Tile")) -register_hard_node("desertstone_tile", S("Desert Stone Tile")) -register_hard_node("hard_clay", S("Hardened Clay")) -register_hard_node("moonbrick", S("Moon Brick")) -register_hard_node("stone_tile", S("Stone Tile")) -register_hard_node("stone_rune", S("Runestone")) +register_hard_node("cactusbrick", S("Cactus Brick"), { groups = {cracky = 1}, sounds = default.node_sound_stone_defaults() }) +register_hard_node("coalstone_tile", S("Coal Stone Tile"), { groups = {cracky = 1}, sounds = default.node_sound_stone_defaults() }) +register_hard_node("desertstone_tile", S("Desert Stone Tile"), { groups = {cracky = 1}, sounds = default.node_sound_stone_defaults() }) +register_hard_node("hard_clay", S("Hardened Clay"), { groups = {cracky = 1}, sounds = default.node_sound_stone_defaults() }) +register_hard_node("moonbrick", S("Moon Brick"), { groups = {cracky = 1}, sounds = default.node_sound_stone_defaults() }) +register_hard_node("stone_tile", S("Stone Tile"), { groups = {cracky = 1}, sounds = default.node_sound_stone_defaults() }) +register_hard_node("stone_rune", S("Runestone"), { groups = {cracky = 1}, sounds = default.node_sound_stone_defaults() }) register_hard_node("packed_ice", S("Packed Ice"), { groups = {cracky = 1, puts_out_fire = 1, slippery = 3}, diff --git a/src/rope.lua b/src/rope.lua index 4380205..2a28bdd 100644 --- a/src/rope.lua +++ b/src/rope.lua @@ -1,5 +1,5 @@ local rope = {} -local S = minetest.get_translator("xdecor") +local S = xdecor.S -- Code by Mirko K. (modified by Temperest, Wulfsdad and kilbith) (License: GPL). function rope.place(itemstack, placer, pointed_thing) diff --git a/src/workbench.lua b/src/workbench.lua index 4c87c3e..701bbb7 100644 --- a/src/workbench.lua +++ b/src/workbench.lua @@ -3,7 +3,7 @@ local nodes = {} screwdriver = screwdriver or {} local min, ceil = math.min, math.ceil -local S = minetest.get_translator("xdecor") +local S = xdecor.S local FS = function(...) return minetest.formspec_escape(S(...)) end -- Nodes allowed to be cut