Compare commits

...

5 Commits

Author SHA1 Message Date
OgelGames b0fe7fa471 remove deprecated depends.txt 2022-05-20 12:05:48 +02:00
OgelGames 9d3c507a46 minor fixes (typos, grammar, whitespace) 2022-05-20 12:05:48 +02:00
OgelGames 61ba569aee fix pointless crafting recipe 2022-05-20 12:05:48 +02:00
Lejo1 e7ea4f5859
Fix new dependency 2022-02-02 16:25:36 +01:00
Lejo1 39e5b8f3d6
Update for 5.5.0 (mod name change) 2022-02-01 17:56:18 +01:00
4 changed files with 37 additions and 32 deletions

View File

@ -1,15 +1,13 @@
# Advaned Keys
# Advanced Keys
This mod replaces the skeleton_key with a multiple use skeleton_key.
So you can open multiple chests with it.
This mod replaces the single-use skeleton key with a multiple-use skeleton key, so you can open multiple chests with it.
It is also player specific so if you lost it nobody can access your chests.
Depends: default
Depends: default, keys
License: LGPL-2.1
Created by [Lejo](https://github.com/Lejo1)
Parts Derived from [minetest_game](https://github.com/minetest/minetest_game)
Parts derived from [minetest_game](https://github.com/minetest/minetest_game)

View File

@ -1 +0,0 @@
default

View File

@ -1,4 +1,4 @@
-- Overrides the Skeleton_key with a Advanced one.
-- Overrides the Skeleton_key with a Advanced one.
local function make_key_form(meta)
local ctable = {}
@ -39,27 +39,34 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
end)
minetest.unregister_item("default:skeleton_key")
-- Clear old key crafts (would otherwise be pointless gold to gold crafts)
minetest.clear_craft({
output = "keys:skeleton_key",
})
minetest.clear_craft({
type = "cooking",
recipe = "keys:skeleton_key",
})
-- register alias for existing keys (in this case a replacement ingot)
minetest.register_alias("default:skeleton_key", "default:gold_ingot")
-- Register alias for existing keys (in this case a replacement ingot)
minetest.register_alias_force("keys:skeleton_key", "default:gold_ingot")
minetest.override_item("default:key", {
minetest.override_item("keys:key", {
description = "Advanced Key",
inventory_image = "default_key.png",
inventory_image = "keys_key.png",
groups = {key = 1},
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
local meta = itemstack:get_meta()
local name = user:get_player_name()
if not meta:get_string("owner") or meta:get_string("owner") == "" then
meta:set_string("owner", name)
meta:set_string("description", "Key by "..name)
end
if meta:get_string("owner") ~= name then
minetest.chat_send_player(name, "You are not the owner of the key!")
return itemstack
end
local meta = itemstack:get_meta()
local name = user:get_player_name()
if not meta:get_string("owner") or meta:get_string("owner") == "" then
meta:set_string("owner", name)
meta:set_string("description", "Key by "..name)
end
if meta:get_string("owner") ~= name then
minetest.chat_send_player(name, "You are not the owner of the key!")
return itemstack
end
if pointed_thing.type ~= "node" then
minetest.show_formspec(name, "adv_keys:key_form", make_key_form(meta))
return itemstack
@ -77,7 +84,7 @@ minetest.override_item("default:key", {
return itemstack
end
-- make a new key secret in case the node callback needs it
-- Make a new key secret in case the node callback needs it
local random = math.random
local newsecret = string.format(
"%04x%04x%04x%04x",
@ -89,10 +96,10 @@ minetest.override_item("default:key", {
if secret then
meta:set_string(minetest.pos_to_string(pos), secret.." "..minetest.registered_nodes[node.name].description)
end
return itemstack
return itemstack
end,
on_place = function(itemstack, placer, pointed_thing)
local meta = itemstack:get_meta()
on_place = function(itemstack, placer, pointed_thing)
local meta = itemstack:get_meta()
local pos = pointed_thing.under
local node = minetest.get_node(pos)
local def = minetest.registered_nodes[node.name]
@ -110,20 +117,21 @@ minetest.override_item("default:key", {
local on_key_use = def.on_key_use
if meta:get_string("user") == placer:get_player_name() and meta:get_string(minetest.pos_to_string(pos)) ~= "" then
meta:set_string("secret", string.split(meta:get_string(minetest.pos_to_string(pos)), " ")[1])
meta:set_string("secret", string.split(meta:get_string(minetest.pos_to_string(pos)), " ")[1])
if on_key_use then
minetest.after(0.1, function()
on_key_use(pos, placer)
end)
end
else meta:set_string("secret", "no")
else
meta:set_string("secret", "no")
end
return itemstack
end
})
minetest.register_craft({
output = "default:key",
output = "keys:key",
recipe = {
{"default:gold_ingot", "", "default:gold_ingot"},
{"", "default:diamondblock", ""},

View File

@ -1,3 +1,3 @@
name = adv_keys
description = Replaces the Skeleton Key with one with multiple chests.
depends = default
description = Replaces the Skeleton Key with one that opens multiple chests.
depends = default,keys