mirror of
https://github.com/minetest-mods/warps.git
synced 2024-11-13 13:50:19 +01:00
Fix some handling issues and picking up/removal
This commit is contained in:
parent
ba6ade74b3
commit
b39c36d931
3
README
3
README
|
@ -17,7 +17,8 @@ A warpstone can be given or found in the creative inventory (item
|
|||
id: warps:warpstone). This warpstone can be placed on the ground
|
||||
and be programmed to warp players who punch it to a certain warp
|
||||
location (one of the warps in /listwarps). Right-clicking the item
|
||||
as a warp_admin user will allow you to program the warpstone.
|
||||
as a warp_admin user will allow you to program the warpstone. The
|
||||
warpstone can be removed by shift-punching the warp stone.
|
||||
|
||||
========
|
||||
|
||||
|
|
12
init.lua
12
init.lua
|
@ -145,6 +145,7 @@ minetest.register_node("warps:warpstone", {
|
|||
walkable = false,
|
||||
paramtype = "light",
|
||||
groups = { choppy=3 },
|
||||
light_source = 5,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.25, -0.5, -0.25, 0.25, 0.5, 0.25}
|
||||
|
@ -160,6 +161,9 @@ minetest.register_node("warps:warpstone", {
|
|||
minetest.chat_send_player(sender:get_player_name(), "You do not have permission to modify warp stones")
|
||||
return false
|
||||
end
|
||||
if not fields.destination then
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"field[destination;Warp Destination;" .. fields.destination .. "]")
|
||||
|
@ -167,10 +171,16 @@ minetest.register_node("warps:warpstone", {
|
|||
minetest.log("action", sender:get_player_name() .. " changed warp stone to \"" .. fields.destination .. "\"")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher, pointed_thingo)
|
||||
if puncher:get_player_control().sneak and minetest.check_player_privs(puncher:get_player_name(), {warp_admin = true}) then
|
||||
minetest.remove_node(pos)
|
||||
minetest.chat_send_player(puncher:get_player_name(), "Warp stone removed!")
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local destination = meta:get_string("warps_destination")
|
||||
if destination == "" then
|
||||
return false, "Warp stone not initialized"
|
||||
minetest.chat_send_player(puncher:get_player_name(), "Unknown warp location for this warp stone, cannot warp!")
|
||||
return false
|
||||
end
|
||||
for i = 1,table.getn(warps) do
|
||||
if warps[i].name == destination then
|
||||
|
|
Loading…
Reference in New Issue
Block a user