Attempts translations

This commit is contained in:
AliasAlreadyTaken 2024-07-08 01:16:42 +02:00
parent 104e332fa0
commit 7d05a27631
4 changed files with 36 additions and 12 deletions

View File

@ -39,9 +39,9 @@ local function get_target_nodename(node, pos, next_stages)
elseif ((stage_chance[3] ~= nil) and
(type(stage_chance[3].can_set) == "function") and
(stage_chance[3].can_set(pos) == false)) then
return node.name
return node.name, {}
else
return stage_chance[1]
return stage_chance[1], stage_chance
end
end
end
@ -55,19 +55,27 @@ local function on_timer(pos, elapsed)
local node = minetest.get_node(pos)
local stage = minetest.registered_nodes[node.name]._stage
local target_nodename
local timer = 0
local duration
if ((stage == nil) or (stage.next_stages == nil) or (stage.duration == nil)) then
yl_api_nodestages.remove_timer(pos)
return
end
local target_nodename
local target_nodeparams
local next_stage
local timer = 0
local duration
repeat
duration = stage.duration
timer = timer + duration
target_nodename = get_target_nodename(node, pos, stage.next_stages)
target_nodename, next_stage = get_target_nodename(node, pos,
stage.next_stages)
target_nodeparams = {
param1 = next_stage.param1,
param2 = next_stage.param2
}
if (target_nodename == yl_api_nodestages.error) then
-- Thing kaputt, stop it.
@ -85,12 +93,16 @@ local function on_timer(pos, elapsed)
stage = minetest.registered_nodes[target_nodename] and
minetest.registered_nodes[target_nodename]._stage or nil
end
until ((timer >= elapsed) or (stage == nil) or (stage.duration == 0) or (stage.duration == nil))
until ((timer >= elapsed) or (stage == nil) or (stage.duration == 0) or
(stage.duration == nil))
if (node.name == target_nodename) then
return true end
if (node.name == target_nodename) then return true end
minetest.set_node(pos, {name = target_nodename})
minetest.set_node(pos, {
name = target_nodename,
param1 = target_nodeparams.param1,
param2 = target_nodeparams.param2
})
local remaining = timer - elapsed
if (stage and stage.duration and (remaining > 0)) then

3
locale/template.txt Normal file
View File

@ -0,0 +1,3 @@
# textdomain: yl_api_nodestages
[MOD] @1 : @2=

View File

@ -0,0 +1,3 @@
# textdomain: yl_api_nodestages
[MOD] @1 : @2=[MOD] @1 : @2

View File

@ -3,7 +3,13 @@ local S = minetest.get_translator(yl_api_nodestages.modname)
local texts = {}
--function yl_api_nodestages.t(key, ...) return S(texts[key], ...) or "" end
function yl_api_nodestages.t(key, ...) return S(texts[key], ...) or "" end
function yl_api_nodestages.t(key, ...)
if (texts[key] == nil) then
minetest.log("warning","key " .. (key or "") .. " does not exist")
return key
end
return S(texts[key], ...) or ""
end
-- Fixed texts
@ -14,7 +20,7 @@ texts["get_filepath"] = "get_filepath : @1"
-- Translateable texts
texts["information_additional"] = "YL Food API"
texts["information_additional"] = "YL Nodestages API"
texts["api_sent_x_to_y"] = "Sent @1 to @2"