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 = { globals = {
"crafting", "vector", "table", "minetest", "worldedit", "ctf", "ctf_flag", "crafting", "vector", "table", "minetest", "worldedit", "ctf", "ctf_flag",
"ctf_colors", "hudkit", "default", "treasurer", "ChatCmdBuilder", "ctf_map", "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 = { read_globals = {
@ -23,7 +24,6 @@ read_globals = {
"dump", "DIR_DELIM", "dump", "DIR_DELIM",
"sfinv", "creative", "sfinv", "creative",
"irc",
"VoxelArea", "ItemStack", "VoxelArea", "ItemStack",
"Settings", "Settings",
"prometheus", "hb", "prometheus", "hb",

View file

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

View file

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

View file

@ -38,7 +38,7 @@ end
function ctf_colors.set_skin(player, color) function ctf_colors.set_skin(player, color)
if minetest.global_exists("armor") then if minetest.global_exists("armor") then
-- TODO: how should support for skin mods be done? -- 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) armor:update_player_visuals(player)
else else
player:set_properties({ player:set_properties({

View file

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

View file

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