fix bug in lava depth reading, switch to built-in translator system

This commit is contained in:
FaceDeer 2020-02-16 01:46:01 -07:00
parent 0ef6f0fa94
commit f65fa6d331
6 changed files with 37 additions and 121 deletions

View File

@ -1,6 +1,5 @@
default?
doc?
intllib?
farming?
vines?
loot?

View File

@ -1,6 +1,5 @@
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
local modname = minetest.get_current_modname()
local S = minetest.get_translator(modname)
local data = {}
@ -16,10 +15,18 @@ else
particles = false
end
local longdesc
local usagehelp
if minetest.get_modpath("doc") then
longdesc = S("A spool of marked line with a weight on the end used for measuring depths.")
usagehelp = S("Build this item over the location whose depths you wish to plumb. Right click on it to take a reading. The sounding line will give a reading indicating how far down the sounding line encountered water (if any) and how far down the first solid obstruction is.\n\nIf lava is encountered this will be indicated by a burnt end on the line. Sounding lines can't measure the depth of lava, only how far it is to the lava's surface.\n\nIf the sounding line reports encountering an \"unknown void\" it has reached a region that has not yet been generated by map generation.")
end
minetest.register_node("sounding_line:sounding_line", {
description = S("Sounding Line"),
_doc_items_longdesc = S("A spool of marked line with a weight on the end used for measuring depths."),
_doc_items_usagehelp = S("Build this item over the location whose depths you wish to plumb. Right click on it to take a reading. The sounding line will give a reading indicating how far down the sounding line encountered water (if any) and how far down the first solid obstruction is.\n\nIf lava is encountered this will be indicated by a burnt end on the line. Sounding lines can't measure the depth of lava, only how far it is to the lava's surface.\n\nIf the sounding line reports encountering an \"unknown void\" it has reached a region that has not yet been generated by map generation."),
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usagehelp,
groups = {cracky = 3, oddly_breakable_by_hand=3},
drop = "sounding_line:sounding_line",
tiles = {"sounding_line_top.png","sounding_line_bottom.png",
@ -72,7 +79,7 @@ minetest.register_node("sounding_line:sounding_line", {
water_depth = pos.y - y
end
if not encountered_lava and minetest.get_item_group(name, "lava") > 0 then
end_depth = y - pos.y
end_depth = pos.y - y
encountered_lava = true
end
local def = minetest.registered_nodes[name]
@ -88,16 +95,26 @@ minetest.register_node("sounding_line:sounding_line", {
bottom = bottom - 15
end
local player_name = player:get_player_name()
local status = S("Most recent reading:")
if water_depth then
status = status .. "\n" .. string.format(S("Water %dm down"), water_depth)
local result = S("Water @1m down", water_depth)
minetest.chat_send_player(player_name, result)
status = status .. "\n" .. result
end
if encountered_lava then
status = status .. "\n" .. string.format(S("Line burned %dm down"), end_depth)
local result = S("Line burned @1m down", end_depth)
minetest.chat_send_player(player_name, result)
status = status .. "\n" .. result
elseif encountered_ignore then
status = status .. "\n" .. string.format(S("Unknown void %dm down"), end_depth)
local result = S("Unknown void @1m down", end_depth)
minetest.chat_send_player(player_name, result)
status = status .. "\n" .. result
else
status = status .. "\n" .. string.format(S("Obstruction %dm down"), end_depth)
local result = S("Obstruction @1m down", end_depth)
minetest.chat_send_player(player_name, result)
status = status .. "\n" .. result
end
local meta = minetest.get_meta(pos)

View File

@ -1,45 +0,0 @@
-- 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

View File

@ -1,65 +0,0 @@
# 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-05 12:32-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"
#: init.lua:13
msgid "Sounding Line"
msgstr ""
#: init.lua:14
msgid ""
"A spool of marked line with a weight on the end used for measuring depths."
msgstr ""
#: init.lua:15
msgid ""
"Build this item over the location whose depths you wish to plumb. Right "
"click on it to take a reading. The sounding line will give a reading "
"indicating how far down the sounding line encountered water (if any) and how "
"far down the first solid obstruction is.\n"
"\n"
"If lava is encountered this will be indicated by a burnt end on the line. "
"Sounding lines can't measure the depth of lava, only how far it is to the "
"lava's surface.\n"
"\n"
"If the sounding line reports encountering an \"unknown void\" it has reached "
"a region that has not yet been generated by map generation."
msgstr ""
#: init.lua:84
msgid "Most recent reading:"
msgstr ""
#: init.lua:86
#, c-format
msgid "Water %dm down"
msgstr ""
#: init.lua:89
#, c-format
msgid "Line burned %dm down"
msgstr ""
#: init.lua:91
#, c-format
msgid "Unknown void %dm down"
msgstr ""
#: init.lua:93
#, c-format
msgid "Obstruction %dm down"
msgstr ""

8
locale/template.txt Normal file
View File

@ -0,0 +1,8 @@
A spool of marked line with a weight on the end used for measuring depths.=
Build this item over the location whose depths you wish to plumb. Right click on it to take a reading. The sounding line will give a reading indicating how far down the sounding line encountered water (if any) and how far down the first solid obstruction is.@n@nIf lava is encountered this will be indicated by a burnt end on the line. Sounding lines can't measure the depth of lava, only how far it is to the lava's surface.@n@nIf the sounding line reports encountering an \"unknown void\" it has reached a region that has not yet been generated by map generation.=
Line burned @1m down=
Most recent reading:=
Obstruction @1m down=
Sounding Line=
Unknown void @1m down=
Water @1m down=

View File

@ -1 +1,3 @@
name = sounding_line
description = A tool for determining the depth of water or the depth of a hole.
optional_depends = default, doc, farming, vines, loot