No Errors on startup of modules

This commit is contained in:
Cooldude2606
2018-09-03 19:28:18 +01:00
parent e825dfe326
commit 480b548f5f
78 changed files with 631 additions and 138 deletions

View File

@@ -12,10 +12,26 @@ local Game = require('FactorioStdLib.Game@^0.8.0')
local Color = require('FactorioStdLib.Color@^0.8.0')
local Sync -- ExpGamingCore.Sync@^4.0.0
-- so it can be used during on_init
-- Local Varibles
local take_action = 8 -- below this number no action is taken, the first admin given warning jumps to this number
local remove_warnings_time = {}
local min_time_to_remove_warning = 18000 -- this is in ticks
local punishments = {
{'nothing'},
{'nothing'},
{'nothing'},
{'nothing'},
{'nothing'},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.message'},defines.textcolor.info},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.message'},defines.textcolor.info},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.kick-warn'},defines.textcolor.med},
{'kick'},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.temp-warn'},defines.textcolor.high},
{'temp-ban'},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.ban-warn'},defines.textcolor.high},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.last-warn'},defines.textcolor.crit},
{'ban'}
}
-- Module Define
local module_verbose = false
@@ -24,12 +40,13 @@ local ThisModule = {
if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end
if loaded_modules['ExpGamingAdmin.Reports@^4.0.0'] then
take_action = take_action + 1
table.insert(punishments,{'report',{'ExpGamingAdmin-Warnings@4-0-0.reported'},defines.text_color.med},take_action)
table.insert(punishments,take_action,{'report',{'ExpGamingAdmin-Warnings@4-0-0.reported'},defines.textcolor.med})
end
end,
on_post=function()
local highest = nil
for power,rank in pairs(Ranking.ranks) do
for _,rank in pairs(Ranking.ranks) do
local power = rank.power
if not highest and not rank:allowed('no-report') then highest = power-1 end
local _power = power; if highest then _power = power-highest end
if rank:allowed('no-report') then remove_warnings_time[power] = 0
@@ -41,24 +58,6 @@ local ThisModule = {
-- Global Define
local global = global{}
-- Local Varibles
local punishments = {
{'nothing'},
{'nothing'},
{'nothing'},
{'nothing'},
{'nothing'},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.message'},defines.text_color.info},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.message'},defines.text_color.info},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.kick-warn'},defines.text_color.med},
{'kick'},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.temp-warn'},defines.text_color.high},
{'temp-ban'},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.ban-warn'},defines.text_color.high},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.last-warn'},defines.text_color.crit},
{'ban'}
}
-- Function Define
local function valid_players(player,by_player)
local player = Game.get_player(player)
@@ -106,7 +105,7 @@ function Admin.give_warning(player,by_player,reason,min)
warnings = warnings+1
global[player.name] = warnings
if warnings > take_action then
player_return({'ExpGamingAdmin-Warnings@4-0-0.warning-given-by',by_player_name},defines.text_color.info,player)
player_return({'ExpGamingAdmin-Warnings@4-0-0.warning-given-by',by_player_name},defines.textcolor.info,player)
game.print({'ExpGamingAdmin-Warnings@4-0-0.player-warning',player.name,by_player_name,reason})
end
give_punishment(player,by_player,reason)
@@ -119,7 +118,7 @@ function Admin.clear_warings(player,by_player,no_emit)
if not no_emit and Sync then
Sync.emit_embeded{
title='Player Clear',
color=Color.to_hex(defines.text_color.low),
color=Color.to_hex(defines.textcolor.low),
description='A player had their warnings cleared.',
['Player:']='<<inline>>'..player.name,
['By:']='<<inline>>'..by_player_name,
@@ -137,7 +136,7 @@ script.on_event(defines.events.on_tick,function(event)
if (game.tick % time_to_remove) == 0 then
global[name]=warnings-1
if global.warnings[name] > 5 then
player_return({'ExpGamingAdmin-Warnings@4-0-0.remove-warn',global[name],tick_to_display_format(time_to_remove)},defines.text_color.low,name)
player_return({'ExpGamingAdmin-Warnings@4-0-0.remove-warn',global[name],tick_to_display_format(time_to_remove)},defines.textcolor.low,name)
end
end
end