mirror of
https://github.com/TeTpaAka/quests.git
synced 2024-12-23 01:00:40 +01:00
Added intllib support
This commit is contained in:
parent
25a89f844d
commit
5f481f7a74
13
core.lua
13
core.lua
@ -1,3 +1,12 @@
|
|||||||
|
-- Boilerplate to support localized strings if intllib mod is installed.
|
||||||
|
local S
|
||||||
|
if minetest.get_modpath("intllib") then
|
||||||
|
S = intllib.Getter()
|
||||||
|
else
|
||||||
|
-- If you don't use insertions (@1, @2, etc) you can use this:
|
||||||
|
S = function(s) return s end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- registers a quest for later use
|
-- registers a quest for later use
|
||||||
--
|
--
|
||||||
@ -19,8 +28,8 @@ function quests.register_quest(questname, quest)
|
|||||||
return false -- The quest was not registered since there already a quest with that name
|
return false -- The quest was not registered since there already a quest with that name
|
||||||
end
|
end
|
||||||
quests.registered_quests[questname] =
|
quests.registered_quests[questname] =
|
||||||
{ title = quest.title or "missing title",
|
{ title = quest.title or S("missing title"),
|
||||||
description = quest.description or "missing description",
|
description = quest.description or S("missing description"),
|
||||||
max = quest.max or 1,
|
max = quest.max or 1,
|
||||||
autoaccept = quest.autoaccept or false,
|
autoaccept = quest.autoaccept or false,
|
||||||
callback = quest.callback, }
|
callback = quest.callback, }
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
intllib?
|
@ -1,3 +1,13 @@
|
|||||||
|
-- Boilerplate to support localized strings if intllib mod is installed.
|
||||||
|
local S
|
||||||
|
if minetest.get_modpath("intllib") then
|
||||||
|
S = intllib.Getter()
|
||||||
|
else
|
||||||
|
-- If you don't use insertions (@1, @2, etc) you can use this:
|
||||||
|
S = function(s) return s end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- construct the questlog
|
-- construct the questlog
|
||||||
function quests.create_formspec(playername, tab)
|
function quests.create_formspec(playername, tab)
|
||||||
local queststringlist = {}
|
local queststringlist = {}
|
||||||
@ -30,32 +40,32 @@ function quests.create_formspec(playername, tab)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
local formspec = "size[7,10]"..
|
local formspec = "size[7,10]"..
|
||||||
"tabheader[0,0;header;Open quests,Finished quests,Failed quests;" .. tab .. "]"
|
"tabheader[0,0;header;" .. S("Open quests") .. "," .. S("Finished quests") .. "," .. S("Failed quests") .. ";" .. tab .. "]"
|
||||||
if (no_quests) then
|
if (no_quests) then
|
||||||
formspec = formspec .. "label[0.25,0.25;There are no quests in this category.]"
|
formspec = formspec .. "label[0.25,0.25;" .. S("There are no quests in this category.") .. "]"
|
||||||
else
|
else
|
||||||
formspec = formspec .. "textlist[0.25,0.25;6.5,7.5;questlist;"..table.concat(queststringlist, ",") .. ";1;false]"
|
formspec = formspec .. "textlist[0.25,0.25;6.5,7.5;questlist;"..table.concat(queststringlist, ",") .. ";1;false]"
|
||||||
end
|
end
|
||||||
if (quests.formspec_lists[playername].tab == "1") then
|
if (quests.formspec_lists[playername].tab == "1") then
|
||||||
formspec = formspec .."button[0.25,8;3,.7;abort;Abort quest]"
|
formspec = formspec .."button[0.25,8;3,.7;abort;" .. S("Abort quest") .. "]"
|
||||||
end
|
end
|
||||||
formspec = formspec .. "button[3.75,8;3,.7;config;Configure]"..
|
formspec = formspec .. "button[3.75,8;3,.7;config;" .. S("Configure") .. "]"..
|
||||||
"button[.25,9;3,.7;info;Info]"..
|
"button[.25,9;3,.7;info;" .. S("Info") .. "]"..
|
||||||
"button_exit[3.75,9;3,.7;exit;Exit]"
|
"button_exit[3.75,9;3,.7;exit;" .. S("Exit") .. "]"
|
||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
|
||||||
-- construct the configuration
|
-- construct the configuration
|
||||||
function quests.create_config(playername)
|
function quests.create_config(playername)
|
||||||
local formspec = "size[7,3]" ..
|
local formspec = "size[7,3]" ..
|
||||||
"checkbox[.25,.25;enable;Enable HUD;"
|
"checkbox[.25,.25;enable;" .. S("Enable HUD") .. ";"
|
||||||
if(quests.hud[playername] ~= nil) then
|
if(quests.hud[playername] ~= nil) then
|
||||||
formspec = formspec .. "true"
|
formspec = formspec .. "true"
|
||||||
else
|
else
|
||||||
formspec = formspec .. "false"
|
formspec = formspec .. "false"
|
||||||
end
|
end
|
||||||
formspec = formspec .. "]"..
|
formspec = formspec .. "]"..
|
||||||
"button[.25,1.25;3,.7;return;Return]"
|
"button[.25,1.25;3,.7;return;" .. S("Return") .. "]"
|
||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -69,12 +79,12 @@ function quests.create_info(playername, questname)
|
|||||||
"textarea[.5,1.5;6,4.5;description;;" .. quests.registered_quests[questname].description .. "]"
|
"textarea[.5,1.5;6,4.5;description;;" .. quests.registered_quests[questname].description .. "]"
|
||||||
|
|
||||||
if (quests.formspec_lists[playername].tab == "1") then
|
if (quests.formspec_lists[playername].tab == "1") then
|
||||||
formspec = formspec .. "button[.5,6;3,.7;abort;Abort quest]"
|
formspec = formspec .. "button[.5,6;3,.7;abort;" .. S("Abort quest") .. "]"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
formspec = formspec .. "No quest specified.]"
|
formspec = formspec .. S("No quest specified.") .. "]"
|
||||||
end
|
end
|
||||||
formspec = formspec .. "button[3.25,6;3,.7;return;Return]"
|
formspec = formspec .. "button[3.25,6;3,.7;return;" .. S("Return") .. "]"
|
||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -86,7 +96,7 @@ end
|
|||||||
-- chatcommand to see a full list of quests:
|
-- chatcommand to see a full list of quests:
|
||||||
minetest.register_chatcommand("quests", {
|
minetest.register_chatcommand("quests", {
|
||||||
params = "",
|
params = "",
|
||||||
description = "Show all open quests",
|
description = S("Show all open quests"),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
minetest.show_formspec(name, "quests:questlog", quests.create_formspec(name))
|
minetest.show_formspec(name, "quests:questlog", quests.create_formspec(name))
|
||||||
return true
|
return true
|
||||||
|
11
hud.lua
11
hud.lua
@ -1,3 +1,12 @@
|
|||||||
|
-- Boilerplate to support localized strings if intllib mod is installed.
|
||||||
|
local S
|
||||||
|
if minetest.get_modpath("intllib") then
|
||||||
|
S = intllib.Getter()
|
||||||
|
else
|
||||||
|
-- If you don't use insertions (@1, @2, etc) you can use this:
|
||||||
|
S = function(s) return s end
|
||||||
|
end
|
||||||
|
|
||||||
local show_max = 10 -- the maximum visible quests.
|
local show_max = 10 -- the maximum visible quests.
|
||||||
|
|
||||||
local hud_config = { position = {x = 1, y = 0.2},
|
local hud_config = { position = {x = 1, y = 0.2},
|
||||||
@ -16,7 +25,7 @@ function quests.show_hud(playername)
|
|||||||
position = {x = hud_config.position.x, y = hud_config.position.y},
|
position = {x = hud_config.position.x, y = hud_config.position.y},
|
||||||
offset = {x = hud_config.offset.x, y = hud_config.offset.y},
|
offset = {x = hud_config.offset.x, y = hud_config.offset.y},
|
||||||
number = hud_config.number,
|
number = hud_config.number,
|
||||||
text = "Quests:" }
|
text = S("Quests:") }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
15
locale/de.txt
Normal file
15
locale/de.txt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
missing description = fehlende Beschreibung
|
||||||
|
missing title = fehlender Titel
|
||||||
|
Quests: = Quests:
|
||||||
|
Abort quest = Quest abbrechen
|
||||||
|
Configure = Konfigurieren
|
||||||
|
Enable HUD = HUD einschalten
|
||||||
|
Exit = Verlassen
|
||||||
|
Failed quests = Gescheiterte Quests
|
||||||
|
Finished quests = Beendete Quests
|
||||||
|
Info = Info
|
||||||
|
No quest specified. = Keine Quest ausgewählt.
|
||||||
|
Open quests = Offene Quests
|
||||||
|
Return = Zurück
|
||||||
|
Show all open quests = Zeige alle offenen Quests
|
||||||
|
There are no quests in this category. = Es gibt keine Quests in dieser Kategorie.
|
15
locale/template.txt
Normal file
15
locale/template.txt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
missing description =
|
||||||
|
missing title =
|
||||||
|
Quests: =
|
||||||
|
Abort quest =
|
||||||
|
Configure =
|
||||||
|
Enable HUD =
|
||||||
|
Exit =
|
||||||
|
Failed quests =
|
||||||
|
Finished quests =
|
||||||
|
Info =
|
||||||
|
No quest specified. =
|
||||||
|
Open quests =
|
||||||
|
Return =
|
||||||
|
Show all open quests =
|
||||||
|
There are no quests in this category. =
|
Loading…
Reference in New Issue
Block a user