Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minetest 0.4 compatibility solved #13

Closed
mckaygerhard opened this issue Oct 19, 2021 · 4 comments · Fixed by #14
Closed

minetest 0.4 compatibility solved #13

mckaygerhard opened this issue Oct 19, 2021 · 4 comments · Fixed by #14

Comments

@mckaygerhard
Copy link
Contributor

mckaygerhard commented Oct 19, 2021

i used this mod with 0.4.17.1 server (usage of 0.4 is more light rather than mineclone) to allow phone mt clients

it crash due the trasnlations susport only in 5.X so i patches with:

diff --git a/compat/mtg.lua b/compat/mtg.lua
index 0c534a6..e6ea7bc 100644
--- a/compat/mtg.lua
+++ b/compat/mtg.lua
@@ -1,4 +1,16 @@
-local S = minetest.get_translator(minetest.get_current_modname())
+local S
+if minetest.get_translator ~= nil then
+    S = minetest.get_translator(minetest.get_current_modname())
+else
+    -- mock the translator function for MT 0.4
+    S = function(str, ...)
+       local args={...}
+       return str:gsub(
+           "@%d+",
+           function(match) return args[tonumber(match:sub(2))] end
+       )
+    end
+end
 
 -- Armor
 --

in minetest it crash with log, that the patch solves the problem for all versions of minetest

2021-10-19 18:45:03: ERROR[Main]: ModError: Failed to load and run script from /var/games/minetest-server/.minetest/games/venenux/mods/lavastuff/init.lua:
2021-10-19 18:45:03: ERROR[Main]: ...er/.minetest/games/venenux/mods/lavastuff/compat/mtg.lua:1: attempt to call field 'get_translator' (a nil value)
2021-10-19 18:45:03: ERROR[Main]: stack traceback:
2021-10-19 18:45:03: ERROR[Main]: 	...er/.minetest/games/venenux/mods/lavastuff/compat/mtg.lua:1: in main chunk
2021-10-19 18:45:03: ERROR[Main]: 	[C]: in function 'dofile'
2021-10-19 18:45:03: ERROR[Main]: 	...t-server/.minetest/games/venenux/mods/lavastuff/init.lua:425: in main chunk
@LoneWolfHT
Copy link
Collaborator

heh, I have the necessary code in place for init.lua but I forgot when I did the compat files

@LoneWolfHT
Copy link
Collaborator

Might still not work, I haven't really kept 0.4.x in mind when adding features

@mckaygerhard
Copy link
Contributor Author

Might still not work, I haven't really kept 0.4.x in mind when adding features

is working @LoneWolfHT in my venenux sub.nasa-g0v server at subs.fusilsystem.com currently.. maybe i will move in future.. but is working in both 0.4 and 5.X

mckaygerhard added a commit to minenux/minetest-mod-lavastuff that referenced this issue Jan 19, 2022
* if translation is not supported use english on compat/mtg.lua
* improved the code of translation of the already init.lua
* this solves: closes minetest-mods#13
* this solves: closes https://codeberg.org/minenux/lavastuff/issues/1
* close https://codeberg.org/minenux/lavastuff/issues/1
mckaygerhard added a commit to minenux/minetest-mod-lavastuff that referenced this issue Jan 19, 2022
* real fix for minetest-mods#13
* use native translator or intlib property as must be, but mock if both fails
mckaygerhard added a commit to minenux/minetest-mod-lavastuff that referenced this issue Jan 19, 2022
* real fix for minetest-mods#13
* use native translator or intlib property as must be, but mock if both fails
@mckaygerhard
Copy link
Contributor Author

i pushed the #16 due the made by you @LoneWolfHT is incomplete after some test

LoneWolfHT added a commit that referenced this issue Feb 24, 2022
* added minetest 0.4 compatibility due the trasnlation missing support

* if translation is not supported use english on compat/mtg.lua
* improved the code of translation of the already init.lua
* this solves: closes #13
* this solves: closes https://codeberg.org/minenux/lavastuff/issues/1
* close https://codeberg.org/minenux/lavastuff/issues/1

* real fix for compatibility later trasnlations

* real fix for #13
* use native translator or intlib property as must be, but mock if both fails

* fix modname and use intlib depennds only in older engines

* autodetect mod name from minetest api
* added only intllib in depends.txt for older 0.4.X, mod.conf its for 5+
  so due 5+ has built in internationalization its not necesary in that file

* added the depends only when necesary for intllib

* Update init.lua usage or MODNAME and MODPATH

Co-authored-by: LoneWolfHT <lonewolf04361@gmail.com>

* puff also uage ot the MODNAME in get translator

* update luacheck as suggested by lonewolf

i dont know how to avoid the usage of those variables.. but he suggested to just put those .. #16 (comment)

* move intllib to others to do not fail in checks agains moderns engine

also added ',' at the en of the line

Co-authored-by: LoneWolfHT <lonewolf04361@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants