Fixed Existing Lua Check Errors

This commit is contained in:
Cooldude2606
2020-05-26 18:21:10 +01:00
parent 2aaeb06be3
commit 32507492b8
76 changed files with 1622 additions and 1617 deletions

View File

@@ -8,17 +8,17 @@
local Warnings = require 'modules.control.warnings' --- @dep modules.control.warnings
-- This will add a warning to the player
Warnings.add_warning('MrBiter','Cooldude2606','Killed too many biters')
Warnings.add_warning('MrBiter', 'Cooldude2606', 'Killed too many biters')
-- This will remove a warning from a player, second name is just who is doing the action
Warnings.remove_warning('MrBiter','Cooldude2606')
Warnings.remove_warning('MrBiter', 'Cooldude2606')
-- Script warning as similar to normal warning but are designed to have no effect for a short amount of time
-- this is so it can be used for greifer protection without being too agressive
Warnings.add_script_warning('MrBiter','Killed too many biters')
Warnings.add_script_warning('MrBiter', 'Killed too many biters')
-- Both normal and script warnings can also be cleared, this will remove all warnings
Warnings.clear_warnings('MrBiter','Cooldude2606')
Warnings.clear_warnings('MrBiter', 'Cooldude2606')
]]
local Event = require 'utils.event' --- @dep utils.event
@@ -65,7 +65,7 @@ local user_script_warnings = Warnings.user_script_warnings
Global.register({
user_warnings = user_warnings,
user_script_warnings = user_script_warnings
},function(tbl)
}, function(tbl)
Warnings.user_warnings = tbl.user_warnings
Warnings.user_script_warnings = tbl.user_script_warnings
user_warnings = Warnings.user_warnings
@@ -92,7 +92,7 @@ end
-- @tparam string by_player_name the name of the player who is doing the action
-- @tparam[opt='Non given.'] string reason the reason that the player is being warned
-- @treturn number the number of warnings that the player has
function Warnings.add_warning(player,by_player_name,reason)
function Warnings.add_warning(player, by_player_name, reason)
player = valid_player(player)
if not player then return end
if not by_player_name then return end
@@ -105,7 +105,7 @@ function Warnings.add_warning(player,by_player_name,reason)
user_warnings[player.name] = warnings
end
table.insert(warnings,{
table.insert(warnings, {
tick = game.tick,
by_player_name = by_player_name,
reason = reason
@@ -113,7 +113,7 @@ function Warnings.add_warning(player,by_player_name,reason)
local warning_count = #warnings
script.raise_event(Warnings.events.on_warning_added,{
script.raise_event(Warnings.events.on_warning_added, {
name = Warnings.events.on_warning_added,
tick = game.tick,
player_index = player.index,
@@ -126,11 +126,11 @@ function Warnings.add_warning(player,by_player_name,reason)
if action then
local _type = type(action)
if _type == 'function' then
action(player,by_player_name,warning_count)
action(player, by_player_name, warning_count)
elseif _type == 'table' then
local current = table.deepcopy(action)
table.insert(current,2,by_player_name)
table.insert(current,3,warning_count)
table.insert(current, 2,by_player_name)
table.insert(current, 3,warning_count)
player.print(current)
elseif type(action) == 'string' then
player.print(action)
@@ -145,8 +145,8 @@ end
-- @tparam string warning_by_name the name of the player who made the warning
-- @tparam string removed_by_name the name of the player who is doing the action
-- @tparam number warning_count the number of warnings that the player how has
local function warning_removed_event(player,warning_by_name,removed_by_name,warning_count)
script.raise_event(Warnings.events.on_warning_removed,{
local function warning_removed_event(player, warning_by_name, removed_by_name, warning_count)
script.raise_event(Warnings.events.on_warning_removed, {
name = Warnings.events.on_warning_removed,
tick = game.tick,
player_index = player.index,
@@ -160,7 +160,7 @@ end
-- @tparam LuaPlayer player the player to remove a warning from
-- @tparam string by_player_name the name of the player who is doing the action
-- @treturn number the number of warnings that the player has
function Warnings.remove_warning(player,by_player_name)
function Warnings.remove_warning(player, by_player_name)
player = valid_player(player)
if not player then return end
if not by_player_name then return end
@@ -168,9 +168,9 @@ function Warnings.remove_warning(player,by_player_name)
local warnings = user_warnings[player.name]
if not warnings then return end
local warning = table.remove(warnings,1)
local warning = table.remove(warnings, 1)
warning_removed_event(player,warning.by_player_name,by_player_name,#warnings)
warning_removed_event(player, warning.by_player_name, by_player_name, #warnings)
return #warnings
end
@@ -179,7 +179,7 @@ end
-- @tparam LuaPlayer player the player to clear the warnings from
-- @tparam string by_player_name the name of the player who is doing the action
-- @treturn boolean true when warnings were cleared succesfully
function Warnings.clear_warnings(player,by_player_name)
function Warnings.clear_warnings(player, by_player_name)
player = valid_player(player)
if not player then return end
if not by_player_name then return end
@@ -188,8 +188,8 @@ function Warnings.clear_warnings(player,by_player_name)
if not warnings then return end
local warning_count = #warnings
for n,warning in pairs(warnings) do
warning_removed_event(player,warning.by_player_name,by_player_name,warning_count-n)
for n, warning in pairs(warnings) do
warning_removed_event(player, warning.by_player_name, by_player_name, warning_count-n)
end
user_warnings[player.name] = nil
@@ -215,7 +215,7 @@ end
-- @tparam LuaPlayer player the player to add a script warning to
-- @tparam[opt='Non given.'] string reason the reason that the player is being warned
-- @treturn number the number of script warnings that the player has
function Warnings.add_script_warning(player,reason)
function Warnings.add_script_warning(player, reason)
player = valid_player(player)
if not player then return end
@@ -227,14 +227,14 @@ function Warnings.add_script_warning(player,reason)
user_script_warnings[player.name] = warnings
end
table.insert(warnings,{
table.insert(warnings, {
tick = game.tick,
reason = reason
})
local warning_count = #warnings
script.raise_event(Warnings.events.on_script_warning_added,{
script.raise_event(Warnings.events.on_script_warning_added, {
name = Warnings.events.on_script_warning_added,
tick = game.tick,
player_index = player.index,
@@ -243,7 +243,7 @@ function Warnings.add_script_warning(player,reason)
})
if warning_count > config.script_warning_limit then
Warnings.add_warning(player,'<server>',reason)
Warnings.add_warning(player, '<server>', reason)
end
return warning_count
@@ -252,8 +252,8 @@ end
--- Script warning removed event tigger due to it being looped in clear script warnings
-- @tparam LuaPlayer player the player who is having a script warning removed
-- @tparam number warning_count the number of warning that the player has
local function script_warning_removed_event(player,warning_count)
script.raise_event(Warnings.events.on_script_warning_removed,{
local function script_warning_removed_event(player, warning_count)
script.raise_event(Warnings.events.on_script_warning_removed, {
name = Warnings.events.on_script_warning_removed,
tick = game.tick,
player_index = player.index,
@@ -271,7 +271,7 @@ function Warnings.remove_script_warning(player)
local warnings = user_script_warnings[player.name]
if not warnings then return end
table.remove(warnings,1)
table.remove(warnings, 1)
script_warning_removed_event(player)
@@ -288,8 +288,8 @@ function Warnings.clear_script_warnings(player)
if not warnings then return end
local warning_count = #warnings
for n,_ in pairs(warnings) do
script_warning_removed_event(player,warning_count-n)
for n, _ in pairs(warnings) do
script_warning_removed_event(player, warning_count-n)
end
user_script_warnings[player.name] = nil
@@ -298,11 +298,11 @@ end
-- script warnings are removed after a certain amount of time to make them even more lienient
local script_warning_cool_down = config.script_warning_cool_down*3600
Event.on_nth_tick(script_warning_cool_down/4,function()
Event.on_nth_tick(script_warning_cool_down/4, function()
local cutoff = game.tick - script_warning_cool_down
for player_name,script_warnings in pairs(user_script_warnings) do
for player_name, script_warnings in pairs(user_script_warnings) do
if #script_warnings > 0 then
for _,warning in pairs(script_warnings) do
for _, warning in pairs(script_warnings) do
if warning.tick < cutoff then
Warnings.remove_script_warning(player_name)
end