Compare commits

...

5 Commits

Author SHA1 Message Date
fat115 046eccf148 fat115: added intllib support
* added intllib support
* and french translation

* one string translated
2017-08-05 15:20:23 +01:00
Tai @ Flex 9b8c3f76f3 fleshed out REAMDE details 2017-04-20 20:10:25 +01:00
Tai @ Flex 13dd3b9e79 Revert "Added Mailbox for Rent"
This reverts commit cd4375fc90.
2017-04-20 20:08:48 +01:00
Tai @ Flex 1ae5ef7bfc Revert "Preserve Facedir, added option to unrent mailboxes"
This reverts commit 0623a7dfef.
2017-04-20 20:08:44 +01:00
Tai @ Flex 52eb8f857f Revert "fleshed out REAMDE details"
This reverts commit cf1dc3895a.
2017-04-20 20:08:29 +01:00
9 changed files with 150 additions and 61 deletions

View File

@ -1 +1,2 @@
default
intllib?

View File

@ -3,6 +3,11 @@
GPL3 ]]
local mailbox = {}
-- Load support for intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
screwdriver = screwdriver or {}
@ -16,17 +21,16 @@ function mailbox.get_formspec(pos, owner, fs_type)
if fs_type == 1 then
return "size[8,9.5]" .. xbg .. default.get_hotbar_bg(0, 5.5) ..
"checkbox[0,0;books_only;Only allow written books;" .. selected .. "]" ..
"checkbox[0,0;books_only;"..S("Only allow written books")..";" .. selected .. "]" ..
"list[nodemeta:" .. spos .. ";mailbox;0,1;8,4;]" ..
"list[current_player;main;0,5.5;8,1;]" ..
"list[current_player;main;0,6.75;8,3;8]" ..
"listring[nodemeta:" .. spos .. ";mailbox]" ..
"listring[current_player;main]" ..
"button_exit[5,0;1,1;unrent;Unrent]"..
"listring[current_player;main]" ..
"button_exit[7,0;1,1;exit;X]"
else
return "size[8,5.5]" .. xbg .. default.get_hotbar_bg(0, 1.5) ..
"label[0,0;Send your goods\nto " .. owner .. " :]" ..
"label[0,0;"..S("Send your goods\nto: @1", owner).."]" ..
"list[nodemeta:" .. spos .. ";drop;3.5,0;1,1;]" ..
"list[current_player;main;0,1.5;8,1;]" ..
"list[current_player;main;0,2.75;8,3;8]" ..
@ -39,20 +43,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if not formname:match("mailbox:mailbox_") then
return
end
if fields.unrent then
local pos = minetest.string_to_pos(formname:sub(17))
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if inv:is_empty("mailbox") then
local node = minetest.get_node(pos)
node.name = "mailbox:mailbox_free"
minetest.swap_node(pos, node) -- preserve Facedir
-- minetest.swap_node(pos, {name = "mailbox:mailbox" })
mailbox.after_place_free(pos, player)
else
minetest.chat_send_player(player:get_player_name(), "Your mailbox is not empty!")
end
end
if fields.books_only then
local pos = minetest.string_to_pos(formname:sub(17))
local node = minetest.get_node(pos)
@ -72,30 +63,13 @@ mailbox.after_place_node = function(pos, placer, _)
local player_name = placer:get_player_name()
meta:set_string("owner", player_name)
meta:set_string("infotext", player_name.."'s Mailbox")
meta:set_string("infotext", S("@1's Mailbox", player_name))
local inv = meta:get_inventory()
inv:set_size("mailbox", 8*4)
inv:set_size("drop", 1)
end
mailbox.on_rightclick_free = function(pos, _, clicker, _)
local node = minetest.get_node(pos)
node.name = "mailbox:mailbox"
minetest.swap_node(pos, node) -- preserve Facedir
-- minetest.swap_node(pos, {name = "mailbox:mailbox" })
mailbox.after_place_node(pos, clicker)
end
mailbox.after_place_free = function(pos, placer, _)
local meta = minetest.get_meta(pos)
local player_name = placer:get_player_name()
-- meta:set_string("owner", player_name)
meta:set_string("infotext", "Free Mailbox, right-click to claim")
end
mailbox.on_rightclick = function(pos, _, clicker, _)
local meta = minetest.get_meta(pos)
local player = clicker:get_player_name()
@ -140,7 +114,7 @@ mailbox.allow_metadata_inventory_put = function(pos, listname, index, stack, pla
if inv:room_for_item("mailbox", stack) then
return -1
else
minetest.chat_send_player(player:get_player_name(), "Mailbox full.")
minetest.chat_send_player(player:get_player_name(), S("Mailbox full."))
return 0
end
end
@ -149,7 +123,7 @@ end
minetest.register_node("mailbox:mailbox", {
description = "Mailbox",
description = S("Mailbox"),
tiles = {
"mailbox_mailbox_top.png", "mailbox_mailbox_bottom.png",
"mailbox_mailbox_side.png", "mailbox_mailbox_side.png",
@ -166,30 +140,8 @@ minetest.register_node("mailbox:mailbox", {
allow_metadata_inventory_put = mailbox.allow_metadata_inventory_put,
})
minetest.register_node("mailbox:mailbox_free", {
description = "Mailbox for Rent",
tiles = {
"mailbox_mailbox_free_top.png", "mailbox_mailbox_free_bottom.png",
"mailbox_mailbox_free_side.png", "mailbox_mailbox_free_side.png",
"mailbox_mailbox_free.png", "mailbox_mailbox_free.png",
},
groups = {cracky = 3, oddly_breakable_by_hand = 1},
on_rotate = screwdriver.rotate_simple,
sounds = default.node_sound_defaults(),
paramtype2 = "facedir",
after_place_node = mailbox.after_place_free,
on_rightclick = mailbox.on_rightclick_free,
can_dig = mailbox.can_dig,
-- on_metadata_inventory_put = mailbox.on_metadata_inventory_put,
-- allow_metadata_inventory_put = mailbox.allow_metadata_inventory_put,
})
minetest.register_node("mailbox:letterbox", {
description = "Letterbox (you hacker you!)",
description = S("Letterbox (you hacker you!)"),
tiles = {
"mailbox_letterbox_top.png", "mailbox_letterbox_bottom.png",
"mailbox_letterbox_side.png", "mailbox_letterbox_side.png",

45
intllib.lua Normal file
View File

@ -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

47
locale/fr.po Normal file
View File

@ -0,0 +1,47 @@
# 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.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-08-04 11:31+0200\n"
"PO-Revision-Date: 2017-08-04 12:28+0200\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.12\n"
"Last-Translator: fat115 <fat115@framasoft.org>\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Language: fr\n"
#: init.lua
msgid "Only allow written books"
msgstr "Accepter uniquement les livres"
#: init.lua
msgid ""
"Send your goods\n"
"to: @1"
msgstr ""
"Envoyer vos biens\n"
"à @1"
#: init.lua
msgid "@1's Mailbox"
msgstr "Boite aux lettres de @1"
#: init.lua
msgid "Mailbox full."
msgstr "Boite aux lettres pleine"
#: init.lua
msgid "Mailbox"
msgstr "Boite aux lettres"
#: init.lua
msgid "Letterbox (you hacker you!)"
msgstr "Boite aux lettres (graine de pirate ! )"

44
locale/template.pot Normal file
View File

@ -0,0 +1,44 @@
# 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-08-04 11:30+0200\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"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: init.lua
msgid "Only allow written books"
msgstr ""
#: init.lua
msgid ""
"Send your goods\n"
"to: @1"
msgstr ""
#: init.lua
msgid "@1's Mailbox"
msgstr ""
#: init.lua
msgid "Mailbox full."
msgstr ""
#: init.lua
msgid "Mailbox"
msgstr ""
#: init.lua
msgid "Letterbox (you hacker you!)"
msgstr ""

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB