From 325ed769df343c0e48eb5490642c8cb2845ba845 Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Sun, 2 Feb 2020 17:53:19 -0700 Subject: [PATCH] add documentation --- init.lua | 23 +++++++++++++++++++--- locale/template.pot | 47 +++++++++++++++++++++++++++++++++++++++++++++ locale/update.bat | 6 ++++++ 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 locale/template.pot create mode 100644 locale/update.bat diff --git a/init.lua b/init.lua index 0a00c2b..eb8d04b 100644 --- a/init.lua +++ b/init.lua @@ -9,6 +9,14 @@ local automatic = minetest.settings:get_bool("death_compass_automatic", false) local range_to_inactivate = 5 +local documentation = S("This does nothing in its current inert form. If you have this in your inventory when you die, however, it will follow you into your next life's inventory and point toward the location of your previous life's end.") +local durationdesc +if duration > 0 then + durationdesc = S("The Death Compass' guidance will only last for @1 seconds.", duration) +else + durationdesc = S("The Death Compass will point toward your previous corpse until you find it.") +end + -- set a position to the compass stack function set_target(stack, pos, name) local meta=stack:get_meta() @@ -124,7 +132,7 @@ end) for i = 0, 15 do local image = "death_compass_16_"..i..".png" local groups = {death_compass = 1, not_in_creative_inventory = 1} - minetest.register_tool("death_compass:dir"..i, { + minetest.register_craftitem("death_compass:dir"..i, { description = S("Death Compass"), inventory_image = image, wield_image = image, @@ -134,12 +142,21 @@ for i = 0, 15 do end if not automatic then - minetest.register_tool("death_compass:inactive", { - description = S("Inactive Death Compass"), + local display_doc = function(itemstack, user) + local player_name = user:get_player_name() + minetest.chat_send_player(player_name, documentation .. "\n" .. durationdesc) + end + + minetest.register_craftitem("death_compass:inactive", { + description = S("Death Compass"), + _doc_items_longdesc = documentation, + _doc_items_usagehelp = durationdesc, inventory_image = "death_compass_inactive.png", wield_image = "death_compass_inactive.png", stack_max = 1, groups = {death_compass = 1}, + on_place = display_doc, + on_secondary_use = display_doc, }) minetest.register_craft({ diff --git a/locale/template.pot b/locale/template.pot new file mode 100644 index 0000000..bd2c6d3 --- /dev/null +++ b/locale/template.pot @@ -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 , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-02-02 17:50-0700\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: death_compass\init.lua:12 +msgid "" +"This does nothing in its current inert form. If you have this in your " +"inventory when you die, however, it will follow you into your next life's " +"inventory and point toward the location of your previous life's end." +msgstr "" + +#: death_compass\init.lua:15 +msgid "The Death Compass' guidance will only last for @1 seconds." +msgstr "" + +#: death_compass\init.lua:17 +msgid "" +"The Death Compass will point toward your previous corpse until you find it." +msgstr "" + +#: death_compass\init.lua:96 +msgid "@1m to @2's corpse, @3s remaining" +msgstr "" + +#: death_compass\init.lua:99 +msgid "@1m to @2's corpse, died @3s ago" +msgstr "" + +#: death_compass\init.lua:136 +#: death_compass\init.lua:151 +msgid "Death Compass" +msgstr "" diff --git a/locale/update.bat b/locale/update.bat new file mode 100644 index 0000000..e87d44c --- /dev/null +++ b/locale/update.bat @@ -0,0 +1,6 @@ +@echo off +setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION +cd .. +set LIST= +for /r %%X in (*.lua) do set LIST=!LIST! %%X +..\intllib\tools\xgettext.bat %LIST% \ No newline at end of file