commit 89d3f3fa6e39d0cf04759eb2f433563584288e96 Author: Wuzzy Date: Thu Jun 8 15:34:18 2017 +0200 Initial commit diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..e1dc61a --- /dev/null +++ b/depends.txt @@ -0,0 +1,4 @@ +default? +screwdriver? +doc_items? +intllib? diff --git a/description.txt b/description.txt new file mode 100644 index 0000000..6afca8f --- /dev/null +++ b/description.txt @@ -0,0 +1 @@ +Adds shifted block variants which have their textures offset from their original. diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..7d2211c --- /dev/null +++ b/init.lua @@ -0,0 +1,100 @@ +-- Load support for intllib. +local MP = minetest.get_modpath(minetest.get_current_modname()) +local S, NS = dofile(MP.."/intllib.lua") + +-- doc_items support +local help_default +if minetest.get_modpath("doc_items") then + help_default = S("A shifted block is a variant of a block which has been visually moved by a half block length.") +end + +shifted_blocks = {} + +local on_rotate +if minetest.get_modpath("screwdriver") then + on_rotate = function(pos, node, user, mode, new_param2) + if mode == screwdriver.ROTATE_FACE then + if node.param2 == 0 then + node.param2 = 3 + elseif node.param2 ~= 14 then + node.param2 = 0 + end + minetest.set_node(pos, node) + return true + elseif mode == screwdriver.ROTATE_AXIS then + if node.param2 == 0 or node.param2 == 3 then + node.param2 = 14 + else + node.param2 = 0 + end + minetest.set_node(pos, node) + return true + else + return false + end + end +end + +-- Shifted blocks + +shifted_blocks.register_shifted_block = function(itemstring, original_block, description, side_texture, help, block_texture, no_craft) + local stone = side_texture or minetest.registered_nodes[original_block].tiles[1] + local normal = block_texture or minetest.registered_nodes[original_block].tiles[1] + + -- FIXME/TEST: Does this work with textures other than 16×16? + local combine = "[combine:16x16:-8,0="..normal..":8,0="..normal + + if minetest.get_modpath("doc_items") then + if help == nil then + help = help_default + end + else + help = nil + end + + minetest.register_node(itemstring, { + description = description, + _doc_items_longdesc = help, + on_rotate = on_rotate, + paramtype2 = "facedir", + -- TODO: Place node according to view direction (restrict param2 to 0 or 3) + place_param2 = 0, + tiles = {combine, combine, stone, stone, combine.."^[transformFX", combine}, + is_ground_content = false, + groups = minetest.registered_nodes[original_block].groups, + sounds = minetest.registered_nodes[original_block].sounds, + }) + + if not no_craft then + -- Recipes to add shifted block + minetest.register_craft({ + output = itemstring.." 2", + recipe = { { original_block, original_block } }, + }) + -- Reverse recipe + minetest.register_craft({ + output = original_block.." 2", + recipe = { { itemstring, itemstring} }, + }) + end +end + + +-- Register shifted blocks for Minetest Game + +if minetest.get_modpath("default") then + -- Stone blocks + shifted_blocks.register_shifted_block("shifted_blocks:stone_block_shifted", "default:stone_block", S("Shifted Stone Block"), "default_stone.png") + shifted_blocks.register_shifted_block("shifted_blocks:desert_stone_block_shifted", "default:desert_stone_block", S("Shifted Desert Stone Block"), "default_desert_stone.png") + shifted_blocks.register_shifted_block("shifted_blocks:sandstone_block_shifted", "default:sandstone_block", S("Shifted Sandstone Block"), "default_sandstone.png") + shifted_blocks.register_shifted_block("shifted_blocks:desert_sandstone_block_shifted", "default:desert_sandstone_block", S("Shifted Desert Sandstone Block"), "default_desert_sandstone.png") + shifted_blocks.register_shifted_block("shifted_blocks:silver_sandstone_block_shifted", "default:silver_sandstone_block", S("Shifted Silver Sandstone Block"), "default_silver_sandstone.png") + shifted_blocks.register_shifted_block("shifted_blocks:obsidian_block_shifted", "default:obsidian_block", S("Shifted Obsidian Block"), "default_obsidian.png") + + -- Metal blocks + shifted_blocks.register_shifted_block("shifted_blocks:gold_block_shifted", "default:goldblock", S("Shifted Gold Block")) + shifted_blocks.register_shifted_block("shifted_blocks:bronze_block_shifted", "default:bronzeblock", S("Shifted Bronze Block")) + shifted_blocks.register_shifted_block("shifted_blocks:tin_block_shifted", "default:tinblock", S("Shifted Tin Block")) + shifted_blocks.register_shifted_block("shifted_blocks:copper_block_shifted", "default:copperblock", S("Shifted Copper Block")) + shifted_blocks.register_shifted_block("shifted_blocks:steel_block_shifted", "default:steelblock", S("Shifted Steel Block")) +end diff --git a/intllib.lua b/intllib.lua new file mode 100644 index 0000000..6669d72 --- /dev/null +++ b/intllib.lua @@ -0,0 +1,45 @@ + +-- Fallback functions for when `intllib` is not installed. +-- Code released under Unlicense . + +-- 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/locale/de_DE.po b/locale/de_DE.po new file mode 100644 index 0000000..bf9c7f4 --- /dev/null +++ b/locale/de_DE.po @@ -0,0 +1,72 @@ +# 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. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-08 15:28+0200\n" +"PO-Revision-Date: 2017-06-08 15:32+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 2.0.1\n" +"Last-Translator: Wuzzy \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Language: de_DE\n" +"X-Poedit-SourceCharset: UTF-8\n" + +#: init.lua +msgid "" +"A shifted block is a variant of a block which has been visually moved by a " +"half block length." +msgstr "" +"Ein versetzter Block ist eine Blockvariante, welche um eine halbe " +"Blocklänge verschoben wurde." + +#: init.lua +msgid "Shifted Stone Block" +msgstr "Versetzter Steinblock" + +#: init.lua +msgid "Shifted Desert Stone Block" +msgstr "Versetzter Wüstensteinblock" + +#: init.lua +msgid "Shifted Sandstone Block" +msgstr "Versetzter Sandsteinblock" + +#: init.lua +msgid "Shifted Desert Sandstone Block" +msgstr "Versetzter Wüstensandsteinblock" + +#: init.lua +msgid "Shifted Silver Sandstone Block" +msgstr "Versetzter Silbersandsteinblock" + +#: init.lua +msgid "Shifted Obsidian Block" +msgstr "Versetzter Obsidianblock" + +#: init.lua +msgid "Shifted Gold Block" +msgstr "Versetzter Goldblock" + +#: init.lua +msgid "Shifted Bronze Block" +msgstr "Versetzter Bronzeblock" + +#: init.lua +msgid "Shifted Tin Block" +msgstr "Versetzter Zinnblock" + +#: init.lua +msgid "Shifted Copper Block" +msgstr "Versetzter Kupferblock" + +#: init.lua +msgid "Shifted Steel Block" +msgstr "Versetzter Stahlblock" diff --git a/locale/template.pot b/locale/template.pot new file mode 100644 index 0000000..4d58616 --- /dev/null +++ b/locale/template.pot @@ -0,0 +1,68 @@ +# 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: 2017-06-08 15:28+0200\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" + +#: init.lua +msgid "" +"A shifted block is a variant of a block which has been visually moved by a " +"half block length." +msgstr "" + +#: init.lua +msgid "Shifted Stone Block" +msgstr "" + +#: init.lua +msgid "Shifted Desert Stone Block" +msgstr "" + +#: init.lua +msgid "Shifted Sandstone Block" +msgstr "" + +#: init.lua +msgid "Shifted Desert Sandstone Block" +msgstr "" + +#: init.lua +msgid "Shifted Silver Sandstone Block" +msgstr "" + +#: init.lua +msgid "Shifted Obsidian Block" +msgstr "" + +#: init.lua +msgid "Shifted Gold Block" +msgstr "" + +#: init.lua +msgid "Shifted Bronze Block" +msgstr "" + +#: init.lua +msgid "Shifted Tin Block" +msgstr "" + +#: init.lua +msgid "Shifted Copper Block" +msgstr "" + +#: init.lua +msgid "Shifted Steel Block" +msgstr "" diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..873ff88 Binary files /dev/null and b/screenshot.png differ