diff options
Diffstat (limited to 'currency')
-rw-r--r-- | currency/barter.lua | 28 | ||||
-rw-r--r-- | currency/craftitems.lua | 12 | ||||
-rw-r--r-- | currency/depends.txt | 4 | ||||
-rw-r--r-- | currency/income.lua | 8 | ||||
-rw-r--r-- | currency/init.lua | 20 | ||||
-rw-r--r-- | currency/intllib.lua | 45 | ||||
-rw-r--r-- | currency/locale/template.pot | 177 | ||||
-rw-r--r-- | currency/loot.lua | 30 | ||||
-rw-r--r-- | currency/safe.lua | 38 | ||||
-rw-r--r-- | currency/shop.lua | 44 |
10 files changed, 338 insertions, 68 deletions
diff --git a/currency/barter.lua b/currency/barter.lua index dad2e4a..1fb4f1b 100644 --- a/currency/barter.lua +++ b/currency/barter.lua @@ -1,5 +1,9 @@ barter = {}
+-- internationalization boilerplate
+local MP = minetest.get_modpath(minetest.get_current_modname())
+local S, NS = dofile(MP.."/intllib.lua")
+
barter.chest = {}
barter.chest.formspec = {
main = "size[8,9]"..
@@ -7,20 +11,20 @@ barter.chest.formspec = { "list[current_name;pl2;5,0;3,4;]"..
"list[current_player;main;0,5;8,4;]",
pl1 = {
- start = "button[3,1;1,1;pl1_start;Start]",
+ start = "button[3,1;1,1;pl1_start;" .. S("Start") .. "]",
player = function(name) return "label[3,0;"..name.."]" end,
- accept1 = "button[3,1;1,1;pl1_accept1;Confirm]"..
- "button[3,2;1,1;pl1_cancel;Cancel]",
- accept2 = "button[3,1;1,1;pl1_accept2;Exchange]"..
- "button[3,2;1,1;pl1_cancel;Cancel]",
+ accept1 = "button[3,1;1,1;pl1_accept1;" .. S("Confirm") .. "]"..
+ "button[3,2;1,1;pl1_cancel;" .. S("Cancel") .. "]",
+ accept2 = "button[3,1;1,1;pl1_accept2;" .. S("Exchange") .. "]"..
+ "button[3,2;1,1;pl1_cancel;" .. S("Cancel") .. "]",
},
pl2 = {
- start = "button[4,1;1,1;pl2_start;Start]",
+ start = "button[4,1;1,1;pl2_start;" .. S("Start") .. "]",
player = function(name) return "label[4,0;"..name.."]" end,
- accept1 = "button[4,1;1,1;pl2_accept1;Confirm]"..
- "button[4,2;1,1;pl2_cancel;Cancel]",
- accept2 = "button[4,1;1,1;pl2_accept2;Exchange]"..
- "button[4,2;1,1;pl2_cancel;Cancel]",
+ accept1 = "button[4,1;1,1;pl2_accept1;" .. S("Confirm") .. "]"..
+ "button[4,2;1,1;pl2_cancel;" .. S("Cancel") .. "]",
+ accept2 = "button[4,1;1,1;pl2_accept2;" .. S("Exchange") .. "]"..
+ "button[4,2;1,1;pl2_cancel;" .. S("Cancel") .. "]",
},
}
@@ -90,7 +94,7 @@ end minetest.register_node("currency:barter", {
drawtype = "nodebox",
- description = "Barter Table",
+ description = S("Barter Table"),
paramtype = "light",
paramtype2 = "facedir",
tiles = {"barter_top.png",
@@ -111,7 +115,7 @@ minetest.register_node("currency:barter", { sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
- meta:set_string("infotext", "Barter Table")
+ meta:set_string("infotext", S("Barter Table"))
meta:set_string("pl1","")
meta:set_string("pl2","")
barter.chest.update_formspec(meta)
diff --git a/currency/craftitems.lua b/currency/craftitems.lua index 47ad953..a8d7570 100644 --- a/currency/craftitems.lua +++ b/currency/craftitems.lua @@ -1,26 +1,30 @@ +-- internationalization boilerplate
+local MP = minetest.get_modpath(minetest.get_current_modname())
+local S, NS = dofile(MP.."/intllib.lua")
+
minetest.register_craftitem("currency:minegeld", {
- description = "1 MineGeld Note",
+ description = S("1 MineGeld Note"),
inventory_image = "minegeld.png",
stack_max = 30000,
groups = {minegeld = 1}
})
minetest.register_craftitem("currency:minegeld_5", {
- description = "5 MineGeld Note",
+ description = S("5 MineGeld Note"),
inventory_image = "minegeld_5.png",
stack_max = 30000,
groups = {minegeld = 1}
})
minetest.register_craftitem("currency:minegeld_10", {
- description = "10 MineGeld Note",
+ description = S("10 MineGeld Note"),
inventory_image = "minegeld_10.png",
stack_max = 30000,
groups = {minegeld = 1}
})
minetest.register_craftitem("currency:minegeld_bundle", {
- description = "Bundle of random Minegeld notes",
+ description = S("Bundle of random Minegeld notes"),
inventory_image = "minegeld_bundle.png",
stack_max = 30000,
})
diff --git a/currency/depends.txt b/currency/depends.txt index d3f04d8..b650e9b 100644 --- a/currency/depends.txt +++ b/currency/depends.txt @@ -1,2 +1,4 @@ default -pipeworks? +intllib? +loot? +pipeworks?
\ No newline at end of file diff --git a/currency/income.lua b/currency/income.lua index 2bb42bc..cbbd5d8 100644 --- a/currency/income.lua +++ b/currency/income.lua @@ -1,5 +1,9 @@ players_income = {} +-- internationalization boilerplate +local MP = minetest.get_modpath(minetest.get_current_modname()) +local S, NS = dofile(MP.."/intllib.lua") + local timer = 0 minetest.register_globalstep(function(dtime) timer = timer + dtime; @@ -11,7 +15,7 @@ minetest.register_globalstep(function(dtime) players_income[name] = 0 end players_income[name] = 1 - minetest.log("info", "[Currency] basic income for "..name.."") + minetest.log("info", "[Currency] "..S("basic income for @1", name)) end end end) @@ -27,7 +31,7 @@ earn_income = function(player) local inv = player:get_inventory() inv:add_item("main", {name="currency:minegeld_5", count=count}) players_income[name] = 0 - minetest.log("info", "[Currency] added basic income for "..name.." to inventory") + minetest.log("info", "[Currency] "..S("added basic income for @1 to inventory", name)) end end diff --git a/currency/init.lua b/currency/init.lua index 744fcad..fa85bd2 100644 --- a/currency/init.lua +++ b/currency/init.lua @@ -1,20 +1,24 @@ -minetest.log("info", " Currency mod loading... ")
local modpath = minetest.get_modpath("currency")
+-- internationalization boilerplate
+local S, NS = dofile(modpath.."/intllib.lua")
+
+minetest.log("info", S("Currency mod loading..."))
+
dofile(modpath.."/craftitems.lua")
-minetest.log("info", "[Currency] Craft_items Loaded!")
+minetest.log("info", "[Currency] "..S("Craft_items Loaded!"))
dofile(modpath.."/shop.lua")
-minetest.log("info", "[Currency] Shop Loaded!")
+minetest.log("info", "[Currency] "..S("Shop Loaded!"))
dofile(modpath.."/barter.lua")
-minetest.log("info", "[Currency] Barter Loaded!")
+minetest.log("info", "[Currency] "..S("Barter Loaded!"))
dofile(modpath.."/safe.lua")
-minetest.log("info", "[Currency] Safe Loaded!")
+minetest.log("info", "[Currency] "..S("Safe Loaded!"))
dofile(modpath.."/crafting.lua")
-minetest.log("info", "[Currency] Crafting Loaded!")
+minetest.log("info", "[Currency] "..S("Crafting Loaded!"))
if minetest.setting_getbool("creative_mode") then
- minetest.log("info", "[Currency] Creative mode in use, skipping basic income.")
+ minetest.log("info", "[Currency] "..S("Creative mode in use, skipping basic income."))
else
dofile(modpath.."/income.lua")
- minetest.log("info", "[Currency] Income Loaded!")
+ minetest.log("info", "[Currency] "..S("Income Loaded!"))
end
diff --git a/currency/intllib.lua b/currency/intllib.lua new file mode 100644 index 0000000..6669d72 --- /dev/null +++ b/currency/intllib.lua @@ -0,0 +1,45 @@ + +-- 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/currency/locale/template.pot b/currency/locale/template.pot new file mode 100644 index 0000000..f528214 --- /dev/null +++ b/currency/locale/template.pot @@ -0,0 +1,177 @@ +# 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-02-20 13:58-0700\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" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: barter.lua:14 barter.lua:22 +msgid "Start" +msgstr "" + +#: barter.lua:16 barter.lua:24 +msgid "Confirm" +msgstr "" + +#: barter.lua:17 barter.lua:19 barter.lua:25 barter.lua:27 +msgid "Cancel" +msgstr "" + +#: barter.lua:18 barter.lua:26 shop.lua:20 +msgid "Exchange" +msgstr "" + +#: barter.lua:97 barter.lua:118 +msgid "Barter Table" +msgstr "" + +#: craftitems.lua:6 +msgid "1 MineGeld Note" +msgstr "" + +#: craftitems.lua:13 +msgid "5 MineGeld Note" +msgstr "" + +#: craftitems.lua:20 +msgid "10 MineGeld Note" +msgstr "" + +#: craftitems.lua:27 +msgid "Bundle of random Minegeld notes" +msgstr "" + +#: income.lua:18 +msgid "basic income for @1" +msgstr "" + +#: income.lua:34 +msgid "added basic income for @1 to inventory" +msgstr "" + +#: init.lua:6 +msgid "Currency mod loading..." +msgstr "" + +#: init.lua:9 +msgid "Craft_items Loaded!" +msgstr "" + +#: init.lua:11 +msgid "Shop Loaded!" +msgstr "" + +#: init.lua:13 +msgid "Barter Loaded!" +msgstr "" + +#: init.lua:15 +msgid "Safe Loaded!" +msgstr "" + +#: init.lua:17 +msgid "Crafting Loaded!" +msgstr "" + +#: init.lua:20 +msgid "Creative mode in use, skipping basic income." +msgstr "" + +#: init.lua:23 +msgid "Income Loaded!" +msgstr "" + +#: safe.lua:29 +msgid "Safe" +msgstr "" + +#: safe.lua:44 +msgid "Safe (owned by @1)" +msgstr "" + +#: safe.lua:61 safe.lua:70 safe.lua:79 +msgid "@1 tried to access a safe belonging to @2 at @3" +msgstr "" + +#: safe.lua:86 +msgid "@1 moves stuff in safe at @2" +msgstr "" + +#: safe.lua:89 +msgid "@1 moves stuff to safe at @2" +msgstr "" + +#: safe.lua:92 +msgid "@1 takes stuff from safe at @2" +msgstr "" + +#: shop.lua:11 +msgid "Customer gives (pay here!)" +msgstr "" + +#: shop.lua:13 +msgid "Customer gets:" +msgstr "" + +#: shop.lua:15 +msgid "Owner wants:" +msgstr "" + +#: shop.lua:17 +msgid "Owner gives:" +msgstr "" + +#: shop.lua:26 +msgid "Customers gave:" +msgstr "" + +#: shop.lua:28 +msgid "Your stock:" +msgstr "" + +#: shop.lua:30 +msgid "You want:" +msgstr "" + +#: shop.lua:32 +msgid "In exchange, you give:" +msgstr "" + +#: shop.lua:34 +msgid "Owner, Use (E)+Place (right mouse button) for customer interface" +msgstr "" + +#: shop.lua:88 +msgid "Shop" +msgstr "" + +#: shop.lua:102 +msgid "Exchange shop (owned by @1)" +msgstr "" + +#: shop.lua:151 +msgid "This is your own shop, you can't exchange to yourself!" +msgstr "" + +#: shop.lua:188 +msgid "Exchanged!" +msgstr "" + +#: shop.lua:191 +msgid "Exchange can not be done, contact the shop owner." +msgstr "" + +#: shop.lua:193 +msgid "Exchange can not be done, check if you put all items!" +msgstr "" diff --git a/currency/loot.lua b/currency/loot.lua new file mode 100644 index 0000000..e687724 --- /dev/null +++ b/currency/loot.lua @@ -0,0 +1,30 @@ +if not minetest.get_modpath("loot") then + return +end + +loot.register_loot({ + weights = { generic = 50 }, + payload = { + stack = ItemStack("currency:minegeld"), + min_size = 1, + max_size = 250, + }, +}) + +loot.register_loot({ + weights = { generic = 50 }, + payload = { + stack = ItemStack("currency:minegeld_5"), + min_size = 1, + max_size = 50, + }, +}) + +loot.register_loot({ + weights = { generic = 50 }, + payload = { + stack = ItemStack("currency:minegeld_10"), + min_size = 1, + max_size = 10, + }, +})
\ No newline at end of file diff --git a/currency/safe.lua b/currency/safe.lua index 794e23a..1c53184 100644 --- a/currency/safe.lua +++ b/currency/safe.lua @@ -1,3 +1,7 @@ +-- internationalization boilerplate
+local MP = minetest.get_modpath(minetest.get_current_modname())
+local S, NS = dofile(MP.."/intllib.lua")
+
function default.get_safe_formspec(pos)
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
local formspec =
@@ -22,12 +26,12 @@ local function has_safe_privilege(meta, player) end
minetest.register_node("currency:safe", {
- description = "Safe",
+ description = S("Safe"),
inventory_image = "safe_front.png",
paramtype = "light",
paramtype2 = "facedir",
tiles = {"safe_side.png",
- "safe_side.png",
+ "safe_side.png",
"safe_side.png",
"safe_side.png",
"safe_side.png",
@@ -37,8 +41,7 @@ minetest.register_node("currency:safe", { after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
- meta:set_string("infotext", "Safe (owned by "..
- meta:get_string("owner")..")")
+ meta:set_string("infotext", S("Safe (owned by @1)", meta:get_string("owner")))
end,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
@@ -55,10 +58,8 @@ minetest.register_node("currency:safe", { allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos)
if not has_safe_privilege(meta, player) then
- minetest.log("action", player:get_player_name()..
- " tried to access a safe belonging to "..
- meta:get_string("owner").." at "..
- minetest.pos_to_string(pos))
+ minetest.log("action", S("@1 tried to access a safe belonging to @2 at @3",
+ player:get_player_name(), meta:get_string("owner"), minetest.pos_to_string(pos)))
return 0
end
return count
@@ -66,10 +67,8 @@ minetest.register_node("currency:safe", { allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
if not has_safe_privilege(meta, player) then
- minetest.log("action", player:get_player_name()..
- " tried to access a safe belonging to "..
- meta:get_string("owner").." at "..
- minetest.pos_to_string(pos))
+ minetest.log("action", S("@1 tried to access a safe belonging to @2 at @3",
+ player:get_player_name(), meta:get_string("owner"), minetest.pos_to_string(pos)))
return 0
end
return stack:get_count()
@@ -77,25 +76,20 @@ minetest.register_node("currency:safe", { allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
if not has_safe_privilege(meta, player) then
- minetest.log("action", player:get_player_name()..
- " tried to access a safe belonging to "..
- meta:get_string("owner").." at "..
- minetest.pos_to_string(pos))
+ minetest.log("action", S("@1 tried to access a safe belonging to @2 at @3",
+ player:get_player_name(), meta:get_string("owner"), minetest.pos_to_string(pos)))
return 0
end
return stack:get_count()
end,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
- minetest.log("action", player:get_player_name()..
- " moves stuff in safe at "..minetest.pos_to_string(pos))
+ minetest.log("action", S("@1 moves stuff in safe at @2", player:get_player_name(), minetest.pos_to_string(pos)))
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
- minetest.log("action", player:get_player_name()..
- " moves stuff to safe at "..minetest.pos_to_string(pos))
+ minetest.log("action", S("@1 moves stuff to safe at @2", player:get_player_name(), minetest.pos_to_string(pos)))
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
- minetest.log("action", player:get_player_name()..
- " takes stuff from safe at "..minetest.pos_to_string(pos))
+ minetest.log("action", S("@1 takes stuff from safe at @2", player:get_player_name(), minetest.pos_to_string(pos)))
end,
on_rightclick = function(pos, node, clicker)
local meta = minetest.get_meta(pos)
diff --git a/currency/shop.lua b/currency/shop.lua index 36765a3..301a08c 100644 --- a/currency/shop.lua +++ b/currency/shop.lua @@ -1,38 +1,44 @@ +-- internationalization boilerplate
+local MP = minetest.get_modpath(minetest.get_current_modname())
+local S, NS = dofile(MP.."/intllib.lua")
+
default.shop = {}
default.shop.current_shop = {}
default.shop.formspec = {
customer = function(pos)
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
local formspec = "size[8,9.5]"..
- "label[0,0;Customer gives (pay here !)]"..
+ "label[0,0;" .. S("Customer gives (pay here!)") .. "]"..
"list[current_player;customer_gives;0,0.5;3,2;]"..
- "label[0,2.5;Customer gets]"..
+ "label[0,2.5;" .. S("Customer gets:") .. "]"..
"list[current_player;customer_gets;0,3;3,2;]"..
- "label[5,0;Owner wants]"..
+ "label[5,0;" .. S("Owner wants:") .. "]"..
"list["..list_name..";owner_wants;5,0.5;3,2;]"..
- "label[5,2.5;Owner gives]"..
+ "label[5,2.5;" .. S("Owner gives:") .. "]"..
"list["..list_name..";owner_gives;5,3;3,2;]"..
"list[current_player;main;0,5.5;8,4;]"..
- "button[3,2;2,1;exchange;Exchange]"
+ "button[3,2;2,1;exchange;" .. S("Exchange") .. "]"
return formspec
end,
owner = function(pos)
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
local formspec = "size[8,9.5]"..
- "label[0,0;Customers gave:]"..
+ "label[0,0;" .. S("Customers gave:") .. "]"..
"list["..list_name..";customers_gave;0,0.5;3,2;]"..
- "label[0,2.5;Your stock:]"..
+ "label[0,2.5;" .. S("Your stock:") .. "]"..
"list["..list_name..";stock;0,3;3,2;]"..
- "label[5,0;You want:]"..
+ "label[5,0;" .. S("You want:") .. "]"..
"list["..list_name..";owner_wants;5,0.5;3,2;]"..
- "label[5,2.5;In exchange, you give:]"..
+ "label[5,2.5;" .. S("In exchange, you give:") .. "]"..
"list["..list_name..";owner_gives;5,3;3,2;]"..
- "label[0,5;Owner, Use(E)+Place(RMB) for customer interface]"..
+ "label[0,5;" .. S("Owner, Use (E)+Place (right mouse button) for customer interface") .. "]"..
"list[current_player;main;0,5.5;8,4;]"
return formspec
end,
}
+local have_pipeworks = minetest.global_exists("pipeworks")
+
default.shop.check_privilege = function(listname,playername,meta)
--[[if listname == "pl1" then
if playername ~= meta:get_string("pl1") then
@@ -81,10 +87,10 @@ default.shop.exchange = function(meta) end
minetest.register_node("currency:shop", {
- description = "Shop",
+ description = S("Shop"),
paramtype2 = "facedir",
tiles = {"shop_top.png",
- "shop_top.png",
+ "shop_top.png",
"shop_side.png",
"shop_side.png",
"shop_side.png",
@@ -95,7 +101,7 @@ minetest.register_node("currency:shop", { after_place_node = function(pos, placer, itemstack)
local owner = placer:get_player_name()
local meta = minetest.get_meta(pos)
- meta:set_string("infotext", "Exchange shop (owned by "..owner..")")
+ meta:set_string("infotext", S("Exchange shop (owned by @1)", owner))
meta:set_string("owner",owner)
--[[meta:set_string("pl1","")
meta:set_string("pl2","")]]
@@ -104,9 +110,9 @@ minetest.register_node("currency:shop", { inv:set_size("stock", 3*2)
inv:set_size("owner_wants", 3*2)
inv:set_size("owner_gives", 3*2)
- if minetest.get_modpath("pipeworks") then pipeworks.after_place(pos) end
+ if have_pipeworks then pipeworks.after_place(pos) end
end,
- after_dig_node = (pipeworks and pipeworks.after_dig),
+ after_dig_node = (have_pipeworks and pipeworks and pipeworks.after_dig),
tube = {
insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
@@ -160,7 +166,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields) local pos = default.shop.current_shop[name]
local meta = minetest.get_meta(pos)
if meta:get_string("owner") == name then
- minetest.chat_send_player(name,"This is your own shop, you can't exchange to yourself !")
+ minetest.chat_send_player(name,S("This is your own shop, you can't exchange to yourself!"))
else
local minv = meta:get_inventory()
local pinv = sender:get_inventory()
@@ -197,12 +203,12 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields) minv:remove_item("stock",item)
pinv:add_item("customer_gets",item)
end
- minetest.chat_send_player(name,"Exchanged!")
+ minetest.chat_send_player(name,S("Exchanged!"))
else
if owners_fault then
- minetest.chat_send_player(name,"Exchange can not be done, contact the shop owner.")
+ minetest.chat_send_player(name,S("Exchange can not be done, contact the shop owner."))
else
- minetest.chat_send_player(name,"Exchange can not be done, check if you put all items !")
+ minetest.chat_send_player(name,S("Exchange can not be done, check if you put all items!"))
end
end
end
|