From 40861c9e4f9700d70e202bdad515b0659bc7f766 Mon Sep 17 00:00:00 2001 From: Louis Royer <55180044+louisroyer@users.noreply.github.com> Date: Sun, 12 Jul 2020 14:30:11 +0200 Subject: [PATCH] Move keys to a separate mod (Fix #1490) --- mods/default/README.txt | 2 - mods/default/craftitems.lua | 75 ------------- mods/default/locale/default.de.tr | 3 - mods/default/locale/default.eo.tr | 3 - mods/default/locale/default.es.tr | 3 - mods/default/locale/default.fr.tr | 3 - mods/default/locale/default.id.tr | 3 - mods/default/locale/default.it.tr | 3 - mods/default/locale/default.jbo.tr | 3 - mods/default/locale/default.ms.tr | 3 - mods/default/locale/default.pt_BR.tr | 3 - mods/default/locale/default.ru.tr | 3 - mods/default/locale/default.se.tr | 3 - mods/default/locale/default.sk.tr | 3 - mods/default/locale/default.zh_CN.tr | 3 - mods/default/locale/default.zh_TW.tr | 3 - mods/default/locale/template.txt | 3 - mods/default/tools.lua | 40 ------- mods/keys/README.txt | 21 ++++ mods/keys/aliases.lua | 6 ++ mods/keys/crafting.lua | 28 +++++ mods/keys/craftitems.lua | 102 ++++++++++++++++++ mods/keys/init.lua | 6 ++ mods/keys/license.txt | 52 +++++++++ mods/keys/locale/keys.de.tr | 5 + mods/keys/locale/keys.eo.tr | 5 + mods/keys/locale/keys.es.tr | 5 + mods/keys/locale/keys.fr.tr | 5 + mods/keys/locale/keys.id.tr | 5 + mods/keys/locale/keys.it.tr | 5 + mods/keys/locale/keys.jbo.tr | 5 + mods/keys/locale/keys.ms.tr | 5 + mods/keys/locale/keys.pt_BR.tr | 5 + mods/keys/locale/keys.ru.tr | 5 + mods/keys/locale/keys.se.tr | 5 + mods/keys/locale/keys.zh_CN.tr | 5 + mods/keys/locale/keys.zh_TW.tr | 5 + mods/keys/locale/template.txt | 5 + mods/keys/mod.conf | 3 + .../textures/keys_key.png} | Bin .../textures/keys_key_skeleton.png} | Bin 41 files changed, 288 insertions(+), 162 deletions(-) create mode 100644 mods/keys/README.txt create mode 100644 mods/keys/aliases.lua create mode 100644 mods/keys/crafting.lua create mode 100644 mods/keys/craftitems.lua create mode 100644 mods/keys/init.lua create mode 100644 mods/keys/license.txt create mode 100644 mods/keys/locale/keys.de.tr create mode 100644 mods/keys/locale/keys.eo.tr create mode 100644 mods/keys/locale/keys.es.tr create mode 100644 mods/keys/locale/keys.fr.tr create mode 100644 mods/keys/locale/keys.id.tr create mode 100644 mods/keys/locale/keys.it.tr create mode 100644 mods/keys/locale/keys.jbo.tr create mode 100644 mods/keys/locale/keys.ms.tr create mode 100644 mods/keys/locale/keys.pt_BR.tr create mode 100644 mods/keys/locale/keys.ru.tr create mode 100644 mods/keys/locale/keys.se.tr create mode 100644 mods/keys/locale/keys.zh_CN.tr create mode 100644 mods/keys/locale/keys.zh_TW.tr create mode 100644 mods/keys/locale/template.txt create mode 100644 mods/keys/mod.conf rename mods/{default/textures/default_key.png => keys/textures/keys_key.png} (100%) rename mods/{default/textures/default_key_skeleton.png => keys/textures/keys_key_skeleton.png} (100%) diff --git a/mods/default/README.txt b/mods/default/README.txt index e848f906..949b9402 100644 --- a/mods/default/README.txt +++ b/mods/default/README.txt @@ -188,8 +188,6 @@ Gambit (CC BY-SA 3.0): default_snow.png default_snow_side.png default_snowball.png - default_key.png - default_key_skeleton.png default_book.png asl97 (CC BY-SA 3.0): diff --git a/mods/default/craftitems.lua b/mods/default/craftitems.lua index cf2795c3..46d78049 100644 --- a/mods/default/craftitems.lua +++ b/mods/default/craftitems.lua @@ -196,61 +196,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) player:set_wielded_item(stack) end) -minetest.register_craftitem("default:skeleton_key", { - description = S("Skeleton Key"), - inventory_image = "default_key_skeleton.png", - on_use = function(itemstack, user, pointed_thing) - if pointed_thing.type ~= "node" then - return itemstack - end - - local pos = pointed_thing.under - local node = minetest.get_node(pos) - - if not node then - return itemstack - end - - local node_reg = minetest.registered_nodes[node.name] - local on_skeleton_key_use = node_reg and node_reg.on_skeleton_key_use - if not on_skeleton_key_use then - return itemstack - end - - -- make a new key secret in case the node callback needs it - local random = math.random - local newsecret = string.format( - "%04x%04x%04x%04x", - random(2^16) - 1, random(2^16) - 1, - random(2^16) - 1, random(2^16) - 1) - - local secret, _, _ = on_skeleton_key_use(pos, user, newsecret) - - if secret then - local inv = minetest.get_inventory({type="player", name=user:get_player_name()}) - - -- update original itemstack - itemstack:take_item() - - -- finish and return the new key - local new_stack = ItemStack("default:key") - local meta = new_stack:get_meta() - meta:set_string("secret", secret) - meta:set_string("description", S("Key to @1's @2", user:get_player_name(), - minetest.registered_nodes[node.name].description)) - - if itemstack:get_count() == 0 then - itemstack = new_stack - else - if inv:add_item("main", new_stack):get_count() > 0 then - minetest.add_item(user:get_pos(), new_stack) - end -- else: added to inventory successfully - end - - return itemstack - end - end -}) -- -- Craftitem registry @@ -479,13 +424,6 @@ minetest.register_craft({ } }) -minetest.register_craft({ - output = "default:skeleton_key", - recipe = { - {"default:gold_ingot"}, - } -}) - minetest.register_craft({ output = "default:steel_ingot 9", recipe = { @@ -529,19 +467,6 @@ minetest.register_craft({ recipe = "default:gold_lump", }) -minetest.register_craft({ - type = "cooking", - output = "default:gold_ingot", - recipe = "default:key", - cooktime = 5, -}) - -minetest.register_craft({ - type = "cooking", - output = "default:gold_ingot", - recipe = "default:skeleton_key", - cooktime = 5, -}) minetest.register_craft({ type = "cooking", diff --git a/mods/default/locale/default.de.tr b/mods/default/locale/default.de.tr index c728008c..1abe24f8 100644 --- a/mods/default/locale/default.de.tr +++ b/mods/default/locale/default.de.tr @@ -12,8 +12,6 @@ Save=Speichern by @1=von @1 Page @1 of @2=Seite @1 von @2 "@1" by @2=„@1“ von @2 -Skeleton Key=Skelettschlüssel -Key to @1's @2=Schlüssel für @2 von @1 Blueberries=Blaubeeren Book=Buch Book with Text=Buch mit Text @@ -212,7 +210,6 @@ Bronze Sword=Bronzeschwert Steel Sword=Stahlschwert Mese Sword=Meseschwert Diamond Sword=Diamantschwert -Key=Schlüssel Torch=Fackel @1 will intersect protection on growth.=@1 wird bei Wachstum mit geschützter Zone überlappen. diff --git a/mods/default/locale/default.eo.tr b/mods/default/locale/default.eo.tr index 7aaa0bb9..83496566 100644 --- a/mods/default/locale/default.eo.tr +++ b/mods/default/locale/default.eo.tr @@ -12,8 +12,6 @@ Save=Konservu by @1=per @1 Page @1 of @2=Paĝo @1 el @2 "@1" by @2="@1" per @2 -Skeleton Key=Skeleta Ŝlosilo -Key to @1's @2=Ŝlosilo por la @2 de @1 Blueberries=Mirteloj Book=Libro Book with Text=Libro kun Teksto @@ -212,7 +210,6 @@ Bronze Sword=Bronza Glavo Steel Sword=Ŝtala Glavo Mese Sword=Mesea Glavo Diamond Sword=Diamanta Glavo -Key=Ŝlosilo Torch=Torĉo @1 will intersect protection on growth.=@1 sekcos protekto ĉe vegeto. diff --git a/mods/default/locale/default.es.tr b/mods/default/locale/default.es.tr index d8b07f50..da160dc3 100644 --- a/mods/default/locale/default.es.tr +++ b/mods/default/locale/default.es.tr @@ -12,8 +12,6 @@ Save=Guardar by @1=por @1 Page @1 of @2=Página @1 de @2 "@1" by @2="@1" por @2 -Skeleton Key=Llave esqueleto -Key to @1's @2=Llave para @2 de @1 Blueberries=Arándanos Book=Libro Book with Text=Libro escrito @@ -212,7 +210,6 @@ Bronze Sword=Espada de bronce Steel Sword=Espada de acero Mese Sword=Espada de mese Diamond Sword=Espada de diamante -Key=Llave Torch=Antorcha @1 will intersect protection on growth.=@1 intersectará con protección cuando crezca. diff --git a/mods/default/locale/default.fr.tr b/mods/default/locale/default.fr.tr index b2288f7e..71887400 100644 --- a/mods/default/locale/default.fr.tr +++ b/mods/default/locale/default.fr.tr @@ -12,8 +12,6 @@ Save=Sauvegarder by @1=de @1 Page @1 of @2=Page @1 sur @2 "@1" by @2=« @1 » de @2 -Skeleton Key=Squelette -Key to @1's @2=Clé pour @2 de @1 Blueberries=Myrtille Book=Livre Book with Text=Livre avec du texte @@ -212,7 +210,6 @@ Bronze Sword=Epée en bronze Steel Sword=Epée en acier Mese Sword=Epée en Mese Diamond Sword=Epée en diamant -Key=Clé Torch=Torche @1 will intersect protection on growth.=@1 chevauchera la zone protégée avec la croissance. diff --git a/mods/default/locale/default.id.tr b/mods/default/locale/default.id.tr index 3c02a050..91a901e6 100644 --- a/mods/default/locale/default.id.tr +++ b/mods/default/locale/default.id.tr @@ -12,8 +12,6 @@ Save=Simpan by @1=oleh @1 Page @1 of @2=Halaman @1 dari @2 "@1" by @2="@1" oleh @2 -Skeleton Key=Kunci Induk -Key to @1's @2=Kunci @2 milik @1 Blueberries=Blueberry Book=Buku Book with Text=Buku Tertulis @@ -212,7 +210,6 @@ Bronze Sword=Pedang Perunggu Steel Sword=Pedang Baja Mese Sword=Pedang Mese Diamond Sword=Pedang Berlian -Key=Kunci Torch=Obor @1 will intersect protection on growth.=@1 akan memotong perlindungan ketika tumbuh. diff --git a/mods/default/locale/default.it.tr b/mods/default/locale/default.it.tr index d134a29f..dcb5fd48 100644 --- a/mods/default/locale/default.it.tr +++ b/mods/default/locale/default.it.tr @@ -12,8 +12,6 @@ Save= by @1= Page @1 of @2= "@1" by @2="@1" di @2 -Skeleton Key=Chiave dello Scheletro -Key to @1's @2=Chiave per @2 di @1 Blueberries=Mirtilli Book=Libro Book with Text=Libro con testo @@ -212,7 +210,6 @@ Bronze Sword=Spada di bronzo Steel Sword=Spada d'acciaio Mese Sword=Spada di mese Diamond Sword=Spada di diamante -Key=Chiave Torch=Torcia @1 will intersect protection on growth.=@1 crescendo attraverserà la protezione. diff --git a/mods/default/locale/default.jbo.tr b/mods/default/locale/default.jbo.tr index 841142c0..22954d3c 100644 --- a/mods/default/locale/default.jbo.tr +++ b/mods/default/locale/default.jbo.tr @@ -12,8 +12,6 @@ Save=rejgau by @1=la'o zo'i.@1.zo'i te cukta Page @1 of @2=meirmoi fe li @1 li @2 le'i papri "@1" by @2=lo cukta be la'o gy.@1.gy. bei la'o zo'i.@2.zo'i -Skeleton Key=lo greku ckiku -Key to @1's @2=lo ckiku be @2 po la'o zo'i.@1.zo'i Blueberries=lo blajba Book=lo cukta Book with Text=lo cukta joi selci'a @@ -212,6 +210,5 @@ Bronze Sword=lo ransu cladakyxa'i Steel Sword=lo gasta cladakyxa'i Mese Sword=lo za'e kunrmese cladakyxa'i Diamond Sword=lo tabjme cladakyxa'i -Key=lo ckiku Torch=lo fagytergu'i @1 will intersect protection on growth.=.i @1 cu ba kruca lo bandu ca lo nu banro diff --git a/mods/default/locale/default.ms.tr b/mods/default/locale/default.ms.tr index 5ddfe9c8..cb0f4d21 100644 --- a/mods/default/locale/default.ms.tr +++ b/mods/default/locale/default.ms.tr @@ -12,8 +12,6 @@ Save=Simpan by @1=oleh @1 Page @1 of @2=Ms. @1 / @2 "@1" by @2="@1" oleh @2 -Skeleton Key=Kunci Induk -Key to @1's @2=Kunci @2 milik @1 Blueberries=Beri Biru Book=Buku Book with Text=Buku Bertulisan @@ -212,7 +210,6 @@ Bronze Sword=Pedang Gangsa Steel Sword=Pedang Keluli Mese Sword=Pedang Mese Diamond Sword=Pedang Intan -Key=Kunci Torch=Obor @1 will intersect protection on growth.=@1 akan masuk kawasan perlindungan lain apabila ia tumbuh. diff --git a/mods/default/locale/default.pt_BR.tr b/mods/default/locale/default.pt_BR.tr index 2aa5dac3..1c2049fd 100644 --- a/mods/default/locale/default.pt_BR.tr +++ b/mods/default/locale/default.pt_BR.tr @@ -12,8 +12,6 @@ Save=Salvar by @1=por @1 Page @1 of @2=Página @1 de @2 "@1" by @2="@1" por @2 -Skeleton Key=Chave de Mestra -Key to @1's @2=Chave para @2 de @1 Blueberries=Mirtilo Book=Livro Book with Text=Livro com Texto @@ -212,6 +210,5 @@ Bronze Sword=Espada de Bronze Steel Sword=Espada de Aço Mese Sword=Espada de Mese Diamond Sword=Espada de Diamante -Key=Chave Torch=Tocha @1 will intersect protection on growth.=@1 cruzará a proteção no crescimento. diff --git a/mods/default/locale/default.ru.tr b/mods/default/locale/default.ru.tr index 3b87dd5e..507841e0 100644 --- a/mods/default/locale/default.ru.tr +++ b/mods/default/locale/default.ru.tr @@ -12,8 +12,6 @@ Save=Сохранить by @1=@1 Page @1 of @2=Страница @1 из @2 "@1" by @2="@1" @2 -Skeleton Key=Ключ Скелета -Key to @1's @2=Ключ к @2 от @1 Blueberries=Черника Book=Книга Book with Text=Книга с Текстом @@ -212,7 +210,6 @@ Bronze Sword=Бронзовый Меч Steel Sword=Стальной Меч Mese Sword=Месе Меч Diamond Sword=Алмазный Меч -Key=Ключ Torch=Факел @1 will intersect protection on growth.=@1 пересечёт защиту по росту. diff --git a/mods/default/locale/default.se.tr b/mods/default/locale/default.se.tr index c6de58b9..b288c378 100644 --- a/mods/default/locale/default.se.tr +++ b/mods/default/locale/default.se.tr @@ -12,8 +12,6 @@ Save=Spara by @1=av @1 Page @1 of @2=Sida @1 av @2 "@1" by @2="@1" av @2 -Skeleton Key=Skelett Nyckel -Key to @1's @2=Nyckel till @1s @2 Blueberries=Blåbär Book=Bok Book with Text=Bok med text @@ -212,7 +210,6 @@ Bronze Sword=Brons Svärd Steel Sword=Stål Svärd Mese Sword=Mese Svärd Diamond Sword=Diamant Svärd -Key=Nyckel Torch=Fakla @1 will intersect protection on growth.=@1 kommer korsa skyddet mot tillväxt. diff --git a/mods/default/locale/default.sk.tr b/mods/default/locale/default.sk.tr index a6f7cbf5..d85f714b 100644 --- a/mods/default/locale/default.sk.tr +++ b/mods/default/locale/default.sk.tr @@ -12,8 +12,6 @@ Save=Uložiť by @1=od @1 Page @1 of @2=Strana @1 z @2 "@1" by @2=„@1“ z @2 -Skeleton Key=Základný kľuč -Key to @1's @2=Kľuč pre @2 hráča @1 Blueberries=Čučoriedky Book=Kniha Book with Text=Kniha s textom @@ -212,7 +210,6 @@ Bronze Sword=Bronzový meč Steel Sword=Oceľový meč Mese Sword=Mese meč Diamond Sword=Diamantový meč -Key=Kľúč Torch=Fakľa @1 will intersect protection on growth.=@1 prekročí pri raste chránenú zónu. diff --git a/mods/default/locale/default.zh_CN.tr b/mods/default/locale/default.zh_CN.tr index dd26fa13..56b1c5e6 100644 --- a/mods/default/locale/default.zh_CN.tr +++ b/mods/default/locale/default.zh_CN.tr @@ -12,8 +12,6 @@ Save=保存 by @1=由@1 Page @1 of @2=第@1页,共@2页。 "@1" by @2="@1" by @2 -Skeleton Key=万能钥匙 -Key to @1's @2=@1的@2的钥匙 Blueberries=蓝莓 Book=书 Book with Text=带文字的书 @@ -212,7 +210,6 @@ Bronze Sword=青铜剑 Steel Sword=铁剑 Mese Sword=黄石剑 Diamond Sword=钻石剑 -Key=钥匙 Torch=火把 @1 will intersect protection on growth.=@1生长时将与保护区域相交。 diff --git a/mods/default/locale/default.zh_TW.tr b/mods/default/locale/default.zh_TW.tr index 9d088d8d..94d5e183 100644 --- a/mods/default/locale/default.zh_TW.tr +++ b/mods/default/locale/default.zh_TW.tr @@ -12,8 +12,6 @@ Save=保存 by @1=由@1 Page @1 of @2=第@1頁,共@2頁。 "@1" by @2="@1" by @2 -Skeleton Key=萬能鑰匙 -Key to @1's @2=@1的@2的鑰匙 Blueberries=藍莓 Book=書 Book with Text=帶文字的書 @@ -212,7 +210,6 @@ Bronze Sword=青銅劍 Steel Sword=鐵劍 Mese Sword=黃石劍 Diamond Sword=鑽石劍 -Key=鑰匙 Torch=火把 @1 will intersect protection on growth.=@1將與增長的保護相交。 diff --git a/mods/default/locale/template.txt b/mods/default/locale/template.txt index 3b7b2979..13808e9d 100644 --- a/mods/default/locale/template.txt +++ b/mods/default/locale/template.txt @@ -12,8 +12,6 @@ Save= by @1= Page @1 of @2= "@1" by @2= -Skeleton Key= -Key to @1's @2= Blueberries= Book= Book with Text= @@ -212,6 +210,5 @@ Bronze Sword= Steel Sword= Mese Sword= Diamond Sword= -Key= Torch= @1 will intersect protection on growth.= diff --git a/mods/default/tools.lua b/mods/default/tools.lua index 44468c56..1a95a50d 100644 --- a/mods/default/tools.lua +++ b/mods/default/tools.lua @@ -452,46 +452,6 @@ for name, mat in pairs(craft_ingreds) do }) end -minetest.register_tool("default:key", { - description = S("Key"), - inventory_image = "default_key.png", - groups = {key = 1, not_in_creative_inventory = 1}, - stack_max = 1, - on_place = function(itemstack, placer, pointed_thing) - local under = pointed_thing.under - local node = minetest.get_node(under) - local def = minetest.registered_nodes[node.name] - if def and def.on_rightclick and - not (placer and placer:is_player() and - placer:get_player_control().sneak) then - return def.on_rightclick(under, node, placer, itemstack, - pointed_thing) or itemstack - end - if pointed_thing.type ~= "node" then - return itemstack - end - - local pos = pointed_thing.under - node = minetest.get_node(pos) - - if not node or node.name == "ignore" then - return itemstack - end - - local ndef = minetest.registered_nodes[node.name] - if not ndef then - return itemstack - end - - local on_key_use = ndef.on_key_use - if on_key_use then - on_key_use(pos, placer) - end - - return nil - end -}) - minetest.register_craft({ type = "fuel", recipe = "default:pick_wood", diff --git a/mods/keys/README.txt b/mods/keys/README.txt new file mode 100644 index 00000000..86591203 --- /dev/null +++ b/mods/keys/README.txt @@ -0,0 +1,21 @@ +Minetest Game mod: keys +========================== +See license.txt for license information. + +Authors of source code +---------------------- +Originally by celeron55, Perttu Ahola (LGPLv2.1+) +Various Minetest developers and contributors (LGPLv2.1+) + +Authors of media (textures, sounds, models and schematics) +---------------------------------------------------------- + +Textures +-------- +Gambit (CC BY-SA 3.0): + keys_key.png + keys_key_skeleton.png + +Features +-------- +This mod uses the key API as defined in game_api.txt section [Key API]. diff --git a/mods/keys/aliases.lua b/mods/keys/aliases.lua new file mode 100644 index 00000000..4297498b --- /dev/null +++ b/mods/keys/aliases.lua @@ -0,0 +1,6 @@ +-- +-- Aliases for backward compatibility +-- + +minetest.register_alias("default:key", "keys:key") +minetest.register_alias("default:skeleton_key", "keys:skeleton_key") diff --git a/mods/keys/crafting.lua b/mods/keys/crafting.lua new file mode 100644 index 00000000..b9b503a5 --- /dev/null +++ b/mods/keys/crafting.lua @@ -0,0 +1,28 @@ +-- +-- Crafting recipes +-- + +minetest.register_craft({ + output = "keys:skeleton_key", + recipe = { + {"default:gold_ingot"}, + } +}) + +-- +-- Cooking recipes +-- + +minetest.register_craft({ + type = "cooking", + output = "default:gold_ingot", + recipe = "keys:key", + cooktime = 5, +}) + +minetest.register_craft({ + type = "cooking", + output = "default:gold_ingot", + recipe = "keys:skeleton_key", + cooktime = 5, +}) diff --git a/mods/keys/craftitems.lua b/mods/keys/craftitems.lua new file mode 100644 index 00000000..e4187586 --- /dev/null +++ b/mods/keys/craftitems.lua @@ -0,0 +1,102 @@ +-- Load support for MT game translation. +local S = minetest.get_translator("keys") + +-- +-- Craftitems +-- + +minetest.register_craftitem("keys:skeleton_key", { + description = S("Skeleton Key"), + inventory_image = "keys_key_skeleton.png", + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type ~= "node" then + return itemstack + end + + local pos = pointed_thing.under + local node = minetest.get_node(pos) + + if not node then + return itemstack + end + + local node_reg = minetest.registered_nodes[node.name] + local on_skeleton_key_use = node_reg and node_reg.on_skeleton_key_use + if not on_skeleton_key_use then + return itemstack + end + + -- make a new key secret in case the node callback needs it + local random = math.random + local newsecret = string.format( + "%04x%04x%04x%04x", + random(2^16) - 1, random(2^16) - 1, + random(2^16) - 1, random(2^16) - 1) + + local secret, _, _ = on_skeleton_key_use(pos, user, newsecret) + + if secret then + local inv = minetest.get_inventory({type="player", name=user:get_player_name()}) + + -- update original itemstack + itemstack:take_item() + + -- finish and return the new key + local new_stack = ItemStack("keys:key") + local meta = new_stack:get_meta() + meta:set_string("secret", secret) + meta:set_string("description", S("Key to @1's @2", user:get_player_name(), + minetest.registered_nodes[node.name].description)) + + if itemstack:get_count() == 0 then + itemstack = new_stack + else + if inv:add_item("main", new_stack):get_count() > 0 then + minetest.add_item(user:get_pos(), new_stack) + end -- else: added to inventory successfully + end + + return itemstack + end + end +}) + +minetest.register_tool("keys:key", { + description = S("Key"), + inventory_image = "keys_key.png", + groups = {key = 1, not_in_creative_inventory = 1}, + stack_max = 1, + on_place = function(itemstack, placer, pointed_thing) + local under = pointed_thing.under + local node = minetest.get_node(under) + local def = minetest.registered_nodes[node.name] + if def and def.on_rightclick and + not (placer and placer:is_player() and + placer:get_player_control().sneak) then + return def.on_rightclick(under, node, placer, itemstack, + pointed_thing) or itemstack + end + if pointed_thing.type ~= "node" then + return itemstack + end + + local pos = pointed_thing.under + node = minetest.get_node(pos) + + if not node or node.name == "ignore" then + return itemstack + end + + local ndef = minetest.registered_nodes[node.name] + if not ndef then + return itemstack + end + + local on_key_use = ndef.on_key_use + if on_key_use then + on_key_use(pos, placer) + end + + return nil + end +}) diff --git a/mods/keys/init.lua b/mods/keys/init.lua new file mode 100644 index 00000000..6c2ed825 --- /dev/null +++ b/mods/keys/init.lua @@ -0,0 +1,6 @@ +-- Minetest mod: keys +local keys_path = minetest.get_modpath("keys") + +dofile(keys_path.."/craftitems.lua") +dofile(keys_path.."/crafting.lua") +dofile(keys_path.."/aliases.lua") diff --git a/mods/keys/license.txt b/mods/keys/license.txt new file mode 100644 index 00000000..95f02ef9 --- /dev/null +++ b/mods/keys/license.txt @@ -0,0 +1,52 @@ +License of source code +---------------------- + +GNU Lesser General Public License, version 2.1 +Copyright (C) 2011-2018 celeron55, Perttu Ahola +Copyright (C) 2011-2018 Various Minetest developers and contributors + +This program is free software; you can redistribute it and/or modify it under the terms +of the GNU Lesser General Public License as published by the Free Software Foundation; +either version 2.1 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU Lesser General Public License for more details: +https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html + + +Licenses of media (textures, models and sounds) +----------------------------------------------- + +Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) +Copyright (C) 2010-2018: + + Gambit + +You are free to: +Share — copy and redistribute the material in any medium or format. +Adapt — remix, transform, and build upon the material for any purpose, even commercially. +The licensor cannot revoke these freedoms as long as you follow the license terms. + +Under the following terms: + +Attribution — You must give appropriate credit, provide a link to the license, and +indicate if changes were made. You may do so in any reasonable manner, but not in any way +that suggests the licensor endorses you or your use. + +ShareAlike — If you remix, transform, or build upon the material, you must distribute +your contributions under the same license as the original. + +No additional restrictions — You may not apply legal terms or technological measures that +legally restrict others from doing anything the license permits. + +Notices: + +You do not have to comply with the license for elements of the material in the public +domain or where your use is permitted by an applicable exception or limitation. +No warranties are given. The license may not give you all of the permissions necessary +for your intended use. For example, other rights such as publicity, privacy, or moral +rights may limit how you use the material. + +For more details: +http://creativecommons.org/licenses/by-sa/3.0/ diff --git a/mods/keys/locale/keys.de.tr b/mods/keys/locale/keys.de.tr new file mode 100644 index 00000000..499a6ba7 --- /dev/null +++ b/mods/keys/locale/keys.de.tr @@ -0,0 +1,5 @@ +# textdomain: keys + +Key=Schlüssel +Key to @1's @2=Schlüssel für @2 von @1 +Skeleton Key=Skelettschlüssel diff --git a/mods/keys/locale/keys.eo.tr b/mods/keys/locale/keys.eo.tr new file mode 100644 index 00000000..e73f6c4e --- /dev/null +++ b/mods/keys/locale/keys.eo.tr @@ -0,0 +1,5 @@ +# textdomain: keys + +Key=Ŝlosilo +Key to @1's @2=Ŝlosilo por la @2 de @1 +Skeleton Key=Skeleta Ŝlosilo diff --git a/mods/keys/locale/keys.es.tr b/mods/keys/locale/keys.es.tr new file mode 100644 index 00000000..e408c32a --- /dev/null +++ b/mods/keys/locale/keys.es.tr @@ -0,0 +1,5 @@ +# textdomain: keys + +Key=Llave +Key to @1's @2=Llave para @2 de @1 +Skeleton Key=Llave esqueleto diff --git a/mods/keys/locale/keys.fr.tr b/mods/keys/locale/keys.fr.tr new file mode 100644 index 00000000..b1b9e6a8 --- /dev/null +++ b/mods/keys/locale/keys.fr.tr @@ -0,0 +1,5 @@ +# textdomain: keys + +Key=Clé +Key to @1's @2=Clé pour @2 de @1 +Skeleton Key=Squelette diff --git a/mods/keys/locale/keys.id.tr b/mods/keys/locale/keys.id.tr new file mode 100644 index 00000000..58f8fc55 --- /dev/null +++ b/mods/keys/locale/keys.id.tr @@ -0,0 +1,5 @@ +# textdomain: keys + +Key=Kunci +Key to @1's @2=Kunci @2 milik @1 +Skeleton Key=Kunci Induk diff --git a/mods/keys/locale/keys.it.tr b/mods/keys/locale/keys.it.tr new file mode 100644 index 00000000..ed7bb312 --- /dev/null +++ b/mods/keys/locale/keys.it.tr @@ -0,0 +1,5 @@ +# textdomain: keys + +Key=Chiave +Key to @1's @2=Chiave per @2 di @1 +Skeleton Key=Chiave dello Scheletro diff --git a/mods/keys/locale/keys.jbo.tr b/mods/keys/locale/keys.jbo.tr new file mode 100644 index 00000000..bd12f09b --- /dev/null +++ b/mods/keys/locale/keys.jbo.tr @@ -0,0 +1,5 @@ +# textdomain: keys + +Key=lo ckiku +Key to @1's @2=lo ckiku be @2 po la'o zo'i.@1.zo'i +Skeleton Key=lo greku ckiku diff --git a/mods/keys/locale/keys.ms.tr b/mods/keys/locale/keys.ms.tr new file mode 100644 index 00000000..58f8fc55 --- /dev/null +++ b/mods/keys/locale/keys.ms.tr @@ -0,0 +1,5 @@ +# textdomain: keys + +Key=Kunci +Key to @1's @2=Kunci @2 milik @1 +Skeleton Key=Kunci Induk diff --git a/mods/keys/locale/keys.pt_BR.tr b/mods/keys/locale/keys.pt_BR.tr new file mode 100644 index 00000000..ef9ca1ee --- /dev/null +++ b/mods/keys/locale/keys.pt_BR.tr @@ -0,0 +1,5 @@ +# textdomain: keys + +Key=Chave +Key to @1's @2=Chave para @2 de @1 +Skeleton Key=Chave de Mestra diff --git a/mods/keys/locale/keys.ru.tr b/mods/keys/locale/keys.ru.tr new file mode 100644 index 00000000..00b4e097 --- /dev/null +++ b/mods/keys/locale/keys.ru.tr @@ -0,0 +1,5 @@ +# textdomain: keys + +Key=Ключ +Key to @1's @2=Ключ к @2 от @1 +Skeleton Key=Ключ Скелета diff --git a/mods/keys/locale/keys.se.tr b/mods/keys/locale/keys.se.tr new file mode 100644 index 00000000..2d901df9 --- /dev/null +++ b/mods/keys/locale/keys.se.tr @@ -0,0 +1,5 @@ +# textdomain: keys + +Key=Nyckel +Key to @1's @2=Nyckel till @1s @2 +Skeleton Key=Skelett Nyckel diff --git a/mods/keys/locale/keys.zh_CN.tr b/mods/keys/locale/keys.zh_CN.tr new file mode 100644 index 00000000..57f632ae --- /dev/null +++ b/mods/keys/locale/keys.zh_CN.tr @@ -0,0 +1,5 @@ +# textdomain: keys + +Key=钥匙 +Key to @1's @2=@1的@2的钥匙 +Skeleton Key=万能钥匙 diff --git a/mods/keys/locale/keys.zh_TW.tr b/mods/keys/locale/keys.zh_TW.tr new file mode 100644 index 00000000..c97879ca --- /dev/null +++ b/mods/keys/locale/keys.zh_TW.tr @@ -0,0 +1,5 @@ +# textdomain: keys + +Key=鑰匙 +Key to @1's @2=@1的@2的鑰匙 +Skeleton Key=萬能鑰匙 diff --git a/mods/keys/locale/template.txt b/mods/keys/locale/template.txt new file mode 100644 index 00000000..9fbf62fd --- /dev/null +++ b/mods/keys/locale/template.txt @@ -0,0 +1,5 @@ +# textdomain: keys + +Key= +Key to @1's @2= +Skeleton Key= diff --git a/mods/keys/mod.conf b/mods/keys/mod.conf new file mode 100644 index 00000000..8b8d6693 --- /dev/null +++ b/mods/keys/mod.conf @@ -0,0 +1,3 @@ +name = keys +description = Minetest Game mod: keys +depends = default diff --git a/mods/default/textures/default_key.png b/mods/keys/textures/keys_key.png similarity index 100% rename from mods/default/textures/default_key.png rename to mods/keys/textures/keys_key.png diff --git a/mods/default/textures/default_key_skeleton.png b/mods/keys/textures/keys_key_skeleton.png similarity index 100% rename from mods/default/textures/default_key_skeleton.png rename to mods/keys/textures/keys_key_skeleton.png