Bugfixes
• Make sure sent chat messages aren't chatcommands (fixes #2) • Add checks to cloaking.cloak() and cloaking.uncloak().
This commit is contained in:
parent
ad11b33cee
commit
271e978d98
|
@ -14,7 +14,7 @@ minetest.register_chatcommand("cloak", {
|
||||||
victim = player
|
victim = player
|
||||||
end
|
end
|
||||||
|
|
||||||
p = cloaking.get_player_by_name(victim)
|
local p = cloaking.get_player_by_name(victim)
|
||||||
if not p then
|
if not p then
|
||||||
return false, "Could not find a player with the name '" .. victim .. "'!"
|
return false, "Could not find a player with the name '" .. victim .. "'!"
|
||||||
end
|
end
|
||||||
|
|
14
core.lua
14
core.lua
|
@ -87,7 +87,7 @@ local override_chatcommands = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_chat_message(function(name)
|
minetest.register_on_chat_message(function(name)
|
||||||
if cloaked_players[name] then
|
if message:sub(1, 1) ~= "/" and cloaked_players[name] then
|
||||||
minetest.chat_send_player(name, "You cannot use chat while cloaked." ..
|
minetest.chat_send_player(name, "You cannot use chat while cloaked." ..
|
||||||
" Please use /uncloak if you want to use chat.")
|
" Please use /uncloak if you want to use chat.")
|
||||||
return true
|
return true
|
||||||
|
@ -111,6 +111,10 @@ cloaking.cloak = function(player)
|
||||||
end
|
end
|
||||||
local victim = player:get_player_name()
|
local victim = player:get_player_name()
|
||||||
|
|
||||||
|
if cloaked_players[victim] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
player:set_properties({visual_size = {x = 0, y = 0}, collisionbox = {0,0,0,0,0,0}})
|
player:set_properties({visual_size = {x = 0, y = 0}, collisionbox = {0,0,0,0,0,0}})
|
||||||
player:set_nametag_attributes({text = " "})
|
player:set_nametag_attributes({text = " "})
|
||||||
|
|
||||||
|
@ -140,11 +144,16 @@ cloaking.uncloak = function(player)
|
||||||
end
|
end
|
||||||
local victim = player:get_player_name()
|
local victim = player:get_player_name()
|
||||||
|
|
||||||
|
if not cloaked_players[victim] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
player:set_properties({visual_size = {x = 1, y = 1}, collisionbox = {-0.25,-0.85,-0.25,0.25,0.85,0.25}})
|
player:set_properties({visual_size = {x = 1, y = 1}, collisionbox = {-0.25,-0.85,-0.25,0.25,0.85,0.25}})
|
||||||
player:set_nametag_attributes({text = victim})
|
player:set_nametag_attributes({text = victim})
|
||||||
|
|
||||||
cloaked_players[victim] = false
|
cloaked_players[victim] = false
|
||||||
|
|
||||||
|
-- In singleplayer, there is no joined the game message by default.
|
||||||
if victim == "singleplayer" then
|
if victim == "singleplayer" then
|
||||||
minetest.chat_send_all("*** " .. victim .. " joined the game.")
|
minetest.chat_send_all("*** " .. victim .. " joined the game.")
|
||||||
end
|
end
|
||||||
|
@ -168,8 +177,7 @@ end
|
||||||
|
|
||||||
cloaking.delayed_uncloak = function(player)
|
cloaking.delayed_uncloak = function(player)
|
||||||
local victim = player:get_player_name()
|
local victim = player:get_player_name()
|
||||||
if cloaked ~= 'cloaking' and
|
if cloaked_players[victim] then
|
||||||
cloaked_players[victim] then
|
|
||||||
minetest.after(0.5, function()
|
minetest.after(0.5, function()
|
||||||
cloaked_players[victim] = nil
|
cloaked_players[victim] = nil
|
||||||
if areas and areas.hud and areas.hud[victim] then
|
if areas and areas.hud and areas.hud[victim] then
|
||||||
|
|
Loading…
Reference in New Issue