small fixes
* prevent teleport spamming * correct node placing
This commit is contained in:
parent
e5739954a1
commit
8c8266d48c
31
teleport.lua
31
teleport.lua
@ -1,5 +1,7 @@
|
|||||||
local C = telemosaic.config
|
local C = telemosaic.config
|
||||||
|
|
||||||
|
local recent_teleports = {}
|
||||||
|
|
||||||
local function hash_pos(pos)
|
local function hash_pos(pos)
|
||||||
return math.floor(pos.x + 0.5) .. ':' ..
|
return math.floor(pos.x + 0.5) .. ':' ..
|
||||||
math.floor(pos.y + 0.5) .. ':' ..
|
math.floor(pos.y + 0.5) .. ':' ..
|
||||||
@ -156,6 +158,13 @@ end
|
|||||||
|
|
||||||
-- teleports the player with given telemosaic pos
|
-- teleports the player with given telemosaic pos
|
||||||
function do_teleport(pos, player)
|
function do_teleport(pos, player)
|
||||||
|
|
||||||
|
-- prevent teleport spamming
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
if recent_teleports[player_name] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if is_err_beacon(pos) then
|
if is_err_beacon(pos) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -212,6 +221,14 @@ function do_teleport(pos, player)
|
|||||||
texture = "telemosaic_particle_arrival.png",
|
texture = "telemosaic_particle_arrival.png",
|
||||||
glow = 15,
|
glow = 15,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- prevent teleport spamming
|
||||||
|
recent_teleports[player_name] = true
|
||||||
|
minetest.after(1,
|
||||||
|
function(name)
|
||||||
|
recent_teleports[name] = nil
|
||||||
|
end,
|
||||||
|
player_name)
|
||||||
else
|
else
|
||||||
-- beacon is in error, one way or another.
|
-- beacon is in error, one way or another.
|
||||||
-- but don't swap it out - we won't get it back otherwise!
|
-- but don't swap it out - we won't get it back otherwise!
|
||||||
@ -254,19 +271,17 @@ local function beacon_rightclick(pos, node, player, itemstack, pointed_thing)
|
|||||||
count = 1, wear = 0,
|
count = 1, wear = 0,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
elseif is_protected_beacon(pos, player) then
|
elseif player:get_player_control().sneak then
|
||||||
return
|
|
||||||
else
|
|
||||||
if player:get_player_control().sneak then
|
|
||||||
if itemstack:get_definition().type == "node" then
|
|
||||||
-- normal place
|
-- normal place
|
||||||
return minetest.item_place_node(itemstack, player, pointed_thing)
|
local def = minetest.registered_nodes[itemstack:get_name()]
|
||||||
|
if def then
|
||||||
|
return def.on_place(itemstack, player, pointed_thing)
|
||||||
end
|
end
|
||||||
else
|
|
||||||
|
elseif not is_protected_beacon(pos, player) then
|
||||||
-- teleport when right-clicked
|
-- teleport when right-clicked
|
||||||
do_teleport(pos, player)
|
do_teleport(pos, player)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user