forked from nalc/nalc_game
		
	Move keys to a separate mod (Fix #1490)
This commit is contained in:
		| @@ -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): | ||||
|   | ||||
| @@ -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", | ||||
|   | ||||
| @@ -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. | ||||
|  | ||||
|   | ||||
| @@ -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. | ||||
|  | ||||
|   | ||||
| @@ -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. | ||||
|  | ||||
|   | ||||
| @@ -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. | ||||
|  | ||||
|   | ||||
| @@ -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. | ||||
|  | ||||
|   | ||||
| @@ -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. | ||||
|  | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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. | ||||
|  | ||||
|   | ||||
| @@ -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. | ||||
|   | ||||
| @@ -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 пересечёт защиту по росту. | ||||
|  | ||||
|   | ||||
| @@ -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. | ||||
|  | ||||
|   | ||||
| @@ -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. | ||||
|  | ||||
|   | ||||
| @@ -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生长时将与保护区域相交。 | ||||
|  | ||||
|   | ||||
| @@ -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將與增長的保護相交。 | ||||
|  | ||||
|   | ||||
| @@ -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.= | ||||
|   | ||||
| @@ -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", | ||||
|   | ||||
							
								
								
									
										21
									
								
								mods/keys/README.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								mods/keys/README.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| Minetest Game mod: keys | ||||
| ========================== | ||||
| See license.txt for license information. | ||||
|  | ||||
| Authors of source code | ||||
| ---------------------- | ||||
| Originally by celeron55, Perttu Ahola <celeron55@gmail.com> (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]. | ||||
							
								
								
									
										6
									
								
								mods/keys/aliases.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								mods/keys/aliases.lua
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| -- | ||||
| -- Aliases for backward compatibility | ||||
| -- | ||||
|  | ||||
| minetest.register_alias("default:key", "keys:key") | ||||
| minetest.register_alias("default:skeleton_key", "keys:skeleton_key") | ||||
							
								
								
									
										28
									
								
								mods/keys/crafting.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								mods/keys/crafting.lua
									
									
									
									
									
										Normal file
									
								
							| @@ -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, | ||||
| }) | ||||
							
								
								
									
										102
									
								
								mods/keys/craftitems.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										102
									
								
								mods/keys/craftitems.lua
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
| }) | ||||
							
								
								
									
										6
									
								
								mods/keys/init.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								mods/keys/init.lua
									
									
									
									
									
										Normal file
									
								
							| @@ -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") | ||||
							
								
								
									
										52
									
								
								mods/keys/license.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								mods/keys/license.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| License of source code | ||||
| ---------------------- | ||||
|  | ||||
| GNU Lesser General Public License, version 2.1 | ||||
| Copyright (C) 2011-2018 celeron55, Perttu Ahola <celeron55@gmail.com> | ||||
| 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/ | ||||
							
								
								
									
										5
									
								
								mods/keys/locale/keys.de.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								mods/keys/locale/keys.de.tr
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
							
								
								
									
										5
									
								
								mods/keys/locale/keys.eo.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								mods/keys/locale/keys.eo.tr
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| # textdomain: keys | ||||
|  | ||||
| Key=Ŝlosilo | ||||
| Key to @1's @2=Ŝlosilo por la @2 de @1 | ||||
| Skeleton Key=Skeleta Ŝlosilo | ||||
							
								
								
									
										5
									
								
								mods/keys/locale/keys.es.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								mods/keys/locale/keys.es.tr
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| # textdomain: keys | ||||
|  | ||||
| Key=Llave | ||||
| Key to @1's @2=Llave para @2 de @1 | ||||
| Skeleton Key=Llave esqueleto | ||||
							
								
								
									
										5
									
								
								mods/keys/locale/keys.fr.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								mods/keys/locale/keys.fr.tr
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| # textdomain: keys | ||||
|  | ||||
| Key=Clé | ||||
| Key to @1's @2=Clé pour @2 de @1 | ||||
| Skeleton Key=Squelette | ||||
							
								
								
									
										5
									
								
								mods/keys/locale/keys.id.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								mods/keys/locale/keys.id.tr
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| # textdomain: keys | ||||
|  | ||||
| Key=Kunci | ||||
| Key to @1's @2=Kunci @2 milik @1 | ||||
| Skeleton Key=Kunci Induk | ||||
							
								
								
									
										5
									
								
								mods/keys/locale/keys.it.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								mods/keys/locale/keys.it.tr
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| # textdomain: keys | ||||
|  | ||||
| Key=Chiave | ||||
| Key to @1's @2=Chiave per @2 di @1 | ||||
| Skeleton Key=Chiave dello Scheletro | ||||
							
								
								
									
										5
									
								
								mods/keys/locale/keys.jbo.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								mods/keys/locale/keys.jbo.tr
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
							
								
								
									
										5
									
								
								mods/keys/locale/keys.ms.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								mods/keys/locale/keys.ms.tr
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| # textdomain: keys | ||||
|  | ||||
| Key=Kunci | ||||
| Key to @1's @2=Kunci @2 milik @1 | ||||
| Skeleton Key=Kunci Induk | ||||
							
								
								
									
										5
									
								
								mods/keys/locale/keys.pt_BR.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								mods/keys/locale/keys.pt_BR.tr
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| # textdomain: keys | ||||
|  | ||||
| Key=Chave | ||||
| Key to @1's @2=Chave para @2 de @1 | ||||
| Skeleton Key=Chave de Mestra | ||||
							
								
								
									
										5
									
								
								mods/keys/locale/keys.ru.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								mods/keys/locale/keys.ru.tr
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| # textdomain: keys | ||||
|  | ||||
| Key=Ключ | ||||
| Key to @1's @2=Ключ к @2 от @1 | ||||
| Skeleton Key=Ключ Скелета | ||||
							
								
								
									
										5
									
								
								mods/keys/locale/keys.se.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								mods/keys/locale/keys.se.tr
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| # textdomain: keys | ||||
|  | ||||
| Key=Nyckel | ||||
| Key to @1's @2=Nyckel till @1s @2 | ||||
| Skeleton Key=Skelett Nyckel | ||||
							
								
								
									
										5
									
								
								mods/keys/locale/keys.zh_CN.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								mods/keys/locale/keys.zh_CN.tr
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| # textdomain: keys | ||||
|  | ||||
| Key=钥匙 | ||||
| Key to @1's @2=@1的@2的钥匙 | ||||
| Skeleton Key=万能钥匙 | ||||
							
								
								
									
										5
									
								
								mods/keys/locale/keys.zh_TW.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								mods/keys/locale/keys.zh_TW.tr
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| # textdomain: keys | ||||
|  | ||||
| Key=鑰匙 | ||||
| Key to @1's @2=@1的@2的鑰匙 | ||||
| Skeleton Key=萬能鑰匙 | ||||
							
								
								
									
										5
									
								
								mods/keys/locale/template.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								mods/keys/locale/template.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| # textdomain: keys | ||||
|  | ||||
| Key= | ||||
| Key to @1's @2= | ||||
| Skeleton Key= | ||||
							
								
								
									
										3
									
								
								mods/keys/mod.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								mods/keys/mod.conf
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| name = keys | ||||
| description = Minetest Game mod: keys | ||||
| depends = default | ||||
| Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 180 B | 
| Before Width: | Height: | Size: 187 B After Width: | Height: | Size: 187 B | 
		Reference in New Issue
	
	Block a user