Fix issues found by luacheck

This commit is contained in:
rubenwardy 2019-08-28 18:54:24 +01:00
parent 450027c3b7
commit ebf4316594
6 changed files with 14 additions and 18 deletions

View file

@ -14,7 +14,8 @@ ignore = {"631"}
globals = {
"crafting", "vector", "table", "minetest", "worldedit", "ctf", "ctf_flag",
"ctf_colors", "hudkit", "default", "treasurer", "ChatCmdBuilder", "ctf_map",
"ctf_match", "ctf_stats", "ctf_treasure", "ctf_playertag", "chatplus"
"ctf_match", "ctf_stats", "ctf_treasure", "ctf_playertag", "chatplus", "irc",
"armor",
}
read_globals = {
@ -23,7 +24,6 @@ read_globals = {
"dump", "DIR_DELIM",
"sfinv", "creative",
"irc",
"VoxelArea", "ItemStack",
"Settings",
"prometheus", "hb",

View file

@ -63,11 +63,8 @@ function ctf.list_teams(name)
minetest.chat_send_player(name, "Teams:")
for tname, team in pairs(ctf.teams) do
if team and team.players then
local details = ""
local numPlayers = ctf.count_players_in_team(tname)
details = numPlayers .. " members"
local details = numPlayers .. " members"
if team.flags then
local numFlags = 0
for flagid, flag in pairs(team.flags) do
@ -233,7 +230,7 @@ function ctf.can_mod(player,team)
if privs then
if privs.ctf_admin == true then
return true
return true
end
end
@ -277,10 +274,10 @@ function ctf.autoalloc(name, alloc_mode)
local max_players = ctf.setting("maximum_in_team")
local mtot = false -- more than one team
for key, team in pairs(ctf.teams) do
if next(ctf.teams) then
mtot = true
break
end
if not mtot then
ctf.error("autoalloc", "No teams to allocate " .. name .. " to!")
return

View file

@ -327,7 +327,7 @@ minetest.register_chatcommand("t", {
chatplus.log("<" .. name .. "> ** ".. param .. " **")
end
tcolor = ctf_colors.get_color(ctf.player(name))
local tcolor = ctf_colors.get_color(ctf.player(name))
for username, to in pairs(team.players) do
minetest.chat_send_player(username,
minetest.colorize(tcolor.css, "<" .. name .. "> ** " .. param .. " **"))
@ -344,7 +344,6 @@ minetest.register_chatcommand("t", {
if minetest.global_exists("irc") then
function irc.playerMessage(name, message)
local tname = ctf.player(name).team
local color = ctf_colors.get_irc_color(ctf.player(name))
local clear = "\x0F"
if color then

View file

@ -38,7 +38,7 @@ end
function ctf_colors.set_skin(player, color)
if minetest.global_exists("armor") then
-- TODO: how should support for skin mods be done?
armor.textures[name].skin = "ctf_colors_skin_" .. color .. ".png"
armor.textures[player:get_player_name()].skin = "ctf_colors_skin_" .. color .. ".png"
armor:update_player_visuals(player)
else
player:set_properties({

View file

@ -81,8 +81,8 @@ function ctf_flag.player_drop_flag(name)
ctf.action("flag", name .. " dropped " .. flag_name)
minetest.chat_send_all(flag_name.." has returned.")
for i = 1, #ctf_flag.registered_on_drop do
ctf_flag.registered_on_drop[i](name, flag)
for j = 1, #ctf_flag.registered_on_drop do
ctf_flag.registered_on_drop[j](name, flag)
end
end
end
@ -124,7 +124,7 @@ function ctf_flag.update(pos)
minetest.set_node(top,{name="air"})
return
end
local topmeta = minetest.get_meta(top)
local flag_name = flag_team_data.name
if flag_name and flag_name ~= "" then
flagmeta:set_string("infotext", flag_name.." - "..flag_team_data.team)
@ -142,7 +142,7 @@ function ctf_flag.update(pos)
minetest.set_node(top,{name="ctf_flag:flag_top_"..ctf.team(flag_team_data.team).data.color})
end
topmeta = minetest.get_meta(top)
local topmeta = minetest.get_meta(top)
if flag_name and flag_name ~= "" then
topmeta:set_string("infotext", flag_name.." - "..flag_team_data.team)
else

View file

@ -71,8 +71,8 @@ local function do_capture(attname, flag, returned)
ctf_flag.delete(team, vector.new(flag))
ctf_flag.add(attacker.team, vector.new(flag))
else
minetest.set_node(pos,{name="air"})
ctf_flag.delete(team,pos)
minetest.set_node(flag,{name="air"})
ctf_flag.delete(team,flag)
end
for i = 1, #ctf_flag.registered_on_capture do