Commit 5d1c07e1 authored by Milan's avatar Milan
Browse files

restrict pads to owner, comment recipe for pads away

parent 8c54c845
......@@ -194,7 +194,7 @@ minetest.register_node("teleport_potion:potion", {
end,
})
-- teleport potion recipe
--[[ teleport potion recipe
minetest.register_craft({
output = "teleport_potion:potion",
recipe = {
......@@ -202,7 +202,7 @@ minetest.register_craft({
{"default:diamond", "vessels:glass_bottle", "default:diamond"},
{"", "default:diamond", ""},
},
})
})]]
-- teleport pad
minetest.register_node("teleport_potion:pad", {
......@@ -227,9 +227,15 @@ minetest.register_node("teleport_potion:pad", {
fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}
},
on_construct = function(pos)
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
end,
on_construct = function(pos, player)
local meta = minetest.get_meta(pos)
meta:set_string("owner", "")
-- text entry formspec
meta:set_string("formspec", "field[text;" .. S("Enter teleport coords (e.g. 200,20,-200,Home)") .. ";${text}]")
......@@ -258,17 +264,18 @@ minetest.register_node("teleport_potion:pad", {
local meta = minetest.get_meta(pos)
if teleport_potion.can_access(pos,sender) then
meta:set_int("x", coords.x)
meta:set_int("y", coords.y)
meta:set_int("z", coords.z)
meta:set_string("text", fields.text)
if coords.desc and coords.desc ~= "" then
meta:set_string("infotext", S("Teleport to @1", coords.desc))
meta:set_string("infotext", S("Teleport to @1", coords.desc.. " - graceful owner: "..meta:get_string("owner") or ""))
else
meta:set_string("infotext", S("Pad Active (@1,@2,@3)",
coords.x, coords.y, coords.z))
coords.x, coords.y, coords.z.. " - graceful owner: ".. meta:get_string("owner")))
end
minetest.sound_play("portal_open", {
......@@ -278,11 +285,32 @@ minetest.register_node("teleport_potion:pad", {
})
else
minetest.chat_send_player(name, S("Teleport Pad coordinates failed!"))
minetest.chat_send_player(name, S("Teleport Pad coordinates failed, make sure you own this pad / add valid coordinates."))
end
end
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local owner = meta:get_string('owner');
if ( owner and owner ~= '' and player:get_player_name() ~= owner ) then
return false
end
return true
end,
})
teleport_potion = {}
teleport_potion.can_access = function(pos,player)
local meta = minetest.env:get_meta(pos)
local name = player:get_player_name()
local privs = minetest.get_player_privs(name)
if name == meta:get_string("owner") or privs["server"] then
return true
end
return false
end
-- teleport pad recipe
minetest.register_craft({
output = 'teleport_potion:pad',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment