Spell Check and Lua Check

This commit is contained in:
Cooldude2606
2019-01-11 22:32:30 +00:00
parent 7110b76444
commit 082d9e5439
65 changed files with 760 additions and 724 deletions

View File

@@ -2,7 +2,7 @@
-- @module ExpGamingAdmin.Ban@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alais ThisModule
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')
@@ -27,11 +27,11 @@ AdminGui.add_button('Ban','utility/danger_icon',{'ExpGamingAdmin.tooltip-ban'},f
end)
function Admin.ban(player,by_player,reason)
local player = Game.get_player(player)
player = Game.get_player(player)
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
local reason = Admin.create_reason(reason,by_player_name)
reason = Admin.create_reason(reason,by_player_name)
Admin.set_banned(player,true)
if Sync then Sync.emit_embeded{
if Sync then Sync.emit_embedded{
title='Player Ban',
color=Color.to_hex(defines.textcolor.crit),
description='There was a player banned.',

View File

@@ -1,8 +1,8 @@
--- Adds a function to clear a players inventoy and move the items to spawn.
--- Adds a function to clear a players inventory and move the items to spawn.
-- @module ExpGamingAdmin.ClearInventory@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alais ThisModule
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')
@@ -13,7 +13,7 @@ local module_verbose = false
local ThisModule = {}
-- Function Define
local inventorys = {
local inventories = {
defines.inventory.player_main,
defines.inventory.player_quickbar,
defines.inventory.player_trash,
@@ -23,7 +23,7 @@ local inventorys = {
}
function Admin.move_item_to_spawn(item,surface,chests)
local chests = chests or surface.find_entities_filtered{area={{-10,-10},{10,10}},name='iron-chest'} or {}
chests = chests or surface.find_entities_filtered{area={{-10,-10},{10,10}},name='iron-chest'} or {}
local chest = nil
while not chest or not chest.get_inventory(defines.inventory.chest).can_insert(item) do
chest = table.remove(chests,1)
@@ -38,14 +38,14 @@ function Admin.move_item_to_spawn(item,surface,chests)
end
function Admin.move_inventory(player)
local player = Game.get_player(player)
player = Game.get_player(player)
if not player then return end
local chests = player.surface.find_entities_filtered{area={{-10,-10},{10,10}},name='iron-chest'} or {}
for _,_inventory in pairs(inventorys) do
for _,_inventory in pairs(inventories) do
local inventory = player.get_inventory(_inventory)
if inventory then
for item,count in pairs(inventory.get_contents()) do
local item = {name=item,count=count}
item = {name=item,count=count}
chests = Admin.move_item_to_spawn(item,player.surface,chests)
end
inventory.clear()

View File

@@ -16,7 +16,7 @@ commands.add_command('report', 'Reports a player', {
if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end
if Role.has_flag(player,'not_reportable') then player_return({'ExpGamingAdmin.cant-report',args.player.name}) return commands.error end
for _,report in pairs(global.addons.reports.reports) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player.name}) return commands.error end end
for _,report in pairs(global.addons.reports.varified) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player.name}) return commands.error end end
for _,report in pairs(global.addons.reports.verified) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player.name}) return commands.error end end
Admin.report(player,event.player_index,reason)
end)

View File

@@ -24,5 +24,5 @@ commands.add_command('clear-warnings', 'Clears a player\'s warnings', {
}, function(event,args)
local player = args.player
if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end
Admin.clear_warings(player,event.player_index)
Admin.clear_warnings(player,event.player_index)
end)

View File

@@ -2,7 +2,7 @@
-- @module ExpGamingAdmin.Gui@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alais AdminGui
-- @alias AdminGui
-- Module Require
local Admin = require('ExpGamingAdmin')
@@ -10,7 +10,6 @@ local Gui = require('ExpGamingCore.Gui')
local Role = require('ExpGamingCore.Role')
local Game = require('FactorioStdLib.Game')
local playerInfo -- ExpGamingPlayer.playerInfo@^4.0.0
local mod_gui = require('mod-gui')
-- Module Define
local module_verbose = false
@@ -42,7 +41,7 @@ function AdminGui.add_button(name,caption,tooltip,callback)
tooltip=tooltip
}:on_event('click',function(event)
local parent = event.element.parent
pre_select_player = parent.player and parent.player.caption or nil
local pre_select_player = parent.player and parent.player.caption or nil
callback(pre_select_player,event.player_index)
end)
end
@@ -68,12 +67,12 @@ function AdminGui.draw(frame,filter_buttons)
end
-- Gui Define
local function _players(_player,root_frame,state)
local function get_players(_player,root_frame,state)
local players = {'Select Player'}
local _players = state and game.players or game.connected_players
for _,player in pairs(_players) do
if player.name ~= _player.name then
if Admin.is_banned and Admin.is_banned(player) then else
if not Admin.is_banned or not Admin.is_banned(player) then
table.insert(players,player.name)
end
end
@@ -82,14 +81,14 @@ local function _players(_player,root_frame,state)
end
local online_check = Gui.inputs.add_checkbox('online-check-admin-commands',false,'Show Offline',false,function(player,element)
element.parent['player-drop-down-admin-commands'].items = _players(player,element.parent,true)
element.parent['player-drop-down-admin-commands'].items = get_players(player,element.parent,true)
element.parent['player-drop-down-admin-commands'].selected_index = 1
end,function(player,element)
element.parent['player-drop-down-admin-commands'].items = _players(player,element.parent,false)
element.parent['player-drop-down-admin-commands'].items = get_players(player,element.parent,false)
element.parent['player-drop-down-admin-commands'].selected_index = 1
end)
local player_drop_down = Gui.inputs.add_drop_down('player-drop-down-admin-commands',_players,1,function(player,selected,items,element)
local player_drop_down = Gui.inputs.add_drop_down('player-drop-down-admin-commands',get_players,1,function(player,selected,items,element)
element.parent.parent.player.caption = selected
local player_info_flow = element.parent.parent.info_flow
player_info_flow.clear()
@@ -142,7 +141,7 @@ Admin.center = Gui.center{
tooltip={'ExpGamingAdmin.tooltip'},
draw=function(self,frame,pre_select_player,pre_select_action)
frame.caption={'ExpGamingAdmin.name'}
local frame = frame.add{
frame = frame.add{
type='flow',
direction='horizontal'
}
@@ -166,7 +165,7 @@ Admin.center = Gui.center{
online_check:draw(dropdowns)
local _drop = player_drop_down:draw(dropdowns)
if pre_select_player then Gui.set_dropdown_index(_drop,pre_select_player.name) end
local _drop = action_drop_down:draw(dropdowns)
_drop = action_drop_down:draw(dropdowns)
Gui.set_dropdown_index(_drop,pre_select_action)
local _text = reason_input:draw(dropdowns)
if pre_select_action == 'Jail' or pre_select_action == 'Kick' or pre_select_action == 'Ban' then
@@ -174,7 +173,7 @@ Admin.center = Gui.center{
end
if pre_select_player then playerInfo(pre_select_player,player_info_flow,true) end
_text.style.width = 200
local label = dropdowns.add{
label = dropdowns.add{
name='warning',
type='label',
caption='',
@@ -183,17 +182,17 @@ Admin.center = Gui.center{
label.style.single_line = false
label.style.width = 200
take_action:draw(dropdowns)
local _caption = pre_select_player and pre_select_player.name or ''
local caption = pre_select_player and pre_select_player.name or ''
frame.add{
name='player',
type='label',
caption=_caption
caption=caption
}.style.visible = false
local _caption = pre_select_action or ''
caption = pre_select_action or ''
frame.add{
name='action',
type='label',
caption=_caption
caption=caption
}.style.visible = false
end
}

View File

@@ -2,14 +2,13 @@
-- @module ExpGamingAdmin.Jail@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alais ThisModule
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')
local AdminGui = require('ExpGamingAdmin.Gui')
local Server = require('ExpGamingCore.Server')
local Role = require('ExpGamingCore.Role')
local Game = require('FactorioStdLib.Game')
local Color -- FactorioStdLib.Color@^0.8.0
local Sync -- ExpGamingCore.Sync@^4.0.0
@@ -28,11 +27,11 @@ AdminGui.add_button('jail','utility/clock',{'ExpGamingAdmin.tooltip-jail'},funct
end)
function Admin.jail(player,by_player,reason)
local player, by_player = Admin.valid_players(player,by_player)
player, by_player = Admin.valid_players(player,by_player)
if not player then return end
local reason = Admin.create_reason(reason,by_player.name)
reason = Admin.create_reason(reason,by_player.name)
Admin.set_banned(player,'jail')
if Sync then Sync.emit_embeded{
if Sync then Sync.emit_embedded{
title='Player Jail',
color=Color.to_hex(defines.textcolor.med),
description='There was a player jailed.',

View File

@@ -2,7 +2,7 @@
-- @module ExpGamingAdmin.Kick@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alais ThisModule
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')
@@ -26,10 +26,10 @@ AdminGui.add_button('Kick','utility/warning_icon',{'ExpGamingAdmin.tooltip-kick'
end)
function Admin.kick(player,by_player,reason)
local player = Game.get_player(player)
player = Game.get_player(player)
reason = Admin.create_reason(reason,by_player_name)
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
local reason = Admin.create_reason(reason,by_player_name)
if Sync then Sync.emit_embeded{
if Sync then Sync.emit_embedded{
title='Player Kick',
color=Color.to_hex(defines.textcolor.high),
description='There was a player kicked.',

View File

@@ -2,11 +2,10 @@
-- @module ExpGamingAdmin.Reports@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alais ThisModule
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')
local Server = require('ExpGamingCore.Server')
local Role = require('ExpGamingCore.Role')
local Gui = require('ExpGamingCore.Gui')
local Game = require('FactorioStdLib.Game')
@@ -25,22 +24,22 @@ local ThisModule = {
-- Global Define
local global = global{
reports={},
varified={}
verified={}
}
-- Local Varibles
-- Local Variables
local report_to_warnings = 1 -- used in count_reports
local varified_to_warings = 3 -- used in count_reports
local verified_to_warnings = 3 -- used in count_reports
local reports_needed_for_jail = 6
-- Function Define
local function report_message(player,by_player,reason)
local player, by_player = Admin.valid_players(player,by_player)
player, by_player = Admin.valid_players(player,by_player)
if not player then return end
if Admin.is_banned(player,true) == 'report' then return end
Role.print(Role.meta.groups.User.lowest,{'ExpGamingAdmin.low-print',player.name,reason},defines.textcolor.info,true)
Role.print(Role.meta.groups.Admin.lowest,{'ExpGamingAdmin.high-print',player.name,by_player.name,reason},defines.textcolor.med)
if Sync then Sync.emit_embeded{
if Sync then Sync.emit_embedded{
title='Player Report',
color=Color.to_hex(defines.textcolor.med),
description='A player was reported.',
@@ -51,7 +50,7 @@ local function report_message(player,by_player,reason)
end
local function cheak_reports(player)
local player = Game.get_player(player)
player = Game.get_player(player)
if not player then return end
local reports = Admin.count_reports(player)
if reports >= reports_needed_for_jail and Role.get_highest(player).group.name ~= 'Jail' then
@@ -60,29 +59,29 @@ local function cheak_reports(player)
end
function Admin.count_reports(player)
local player = Game.get_player(player)
player = Game.get_player(player)
if not player then return 0 end
local _count = 0
if global.reports[player.name] then
for _,report in pairs(global.reports[player.name]) do
for _ in pairs(global.reports[player.name]) do
_count=_count+report_to_warnings
end
end
if global.varified[player.name] then
for _,report in pairs(global.varified[player.name]) do
_count=_count+varified_to_warings
if global.verified[player.name] then
for _ in pairs(global.verified[player.name]) do
_count=_count+verified_to_warnings
end
end
return _count
end
function Admin.report(player,by_player,reason)
local player, by_player = Admin.valid_players(player,by_player)
player, by_player = Admin.valid_players(player,by_player)
if not player or Role.has_flag(player,'not_reportable') then return end
if Admin.is_banned(by_player) or Role.has_flag(by_player,'is_jail') then return end
if Role.has_flag(by_player,'is_varified') then
global.varified[player.name] = global.varified[player.name] or {}
local reports = global.varified[player.name]
if Role.has_flag(by_player,'is_verified') then
global.verified[player.name] = global.verified[player.name] or {}
local reports = global.verified[player.name]
for _,value in pairs(reports) do
if value[1] == by_player.name then return end
end
@@ -100,12 +99,12 @@ function Admin.report(player,by_player,reason)
end
function Admin.clear_reports(player,by_player,no_emit)
local player, by_player = Admin.valid_players(player,by_player)
player, by_player = Admin.valid_players(player,by_player)
if not player then return end
global.reports[player.name]={}
global.varified[player.name]={}
global.verified[player.name]={}
if not no_emit and Sync then
Sync.emit_embeded{
Sync.emit_embedded{
title='Player Clear',
color=Color.to_hex(defines.textcolor.low),
description='A player had their reports cleared.',
@@ -160,4 +159,4 @@ Admin.report_btn = Gui.inputs{
end)
-- Module Return
return ThisModule
return ThisModule

View File

@@ -2,7 +2,7 @@
-- @module ExpGamingAdmin.Teleport@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alais ThisModule
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')

View File

@@ -2,7 +2,7 @@
-- @module ExpGamingAdmin.KicTempBan@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alais ThisModule
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')
@@ -27,7 +27,7 @@ function Admin.temp_ban(player,by_player,reason)
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
if not player or Admin.is_banned(player) then return end
Admin.set_banned(player,'temp')
if Sync then Sync.emit_embeded{
if Sync then Sync.emit_embedded{
title='Player Temp-Ban',
color=Color.to_hex(defines.textcolor.high),
description='A player was jailed.',

View File

@@ -2,7 +2,7 @@
-- @module ExpGamingAdmin.Warnings@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alais ThisModule
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')
@@ -12,7 +12,7 @@ local Game = require('FactorioStdLib.Game')
local Color -- FactorioStdLib.Color@^0.8.0
local Sync -- ExpGamingCore.Sync@^4.0.0
-- Local Varibles
-- Local Variables
local take_action = 8 -- the first admin given warning jumps to this number, this case kick-warn is giving
local remove_warnings_time = {}
local min_time_to_remove_warning = 18000 -- this is in ticks
@@ -61,10 +61,10 @@ local global = global{}
-- Function Define
local function give_punishment(player,by_player,reason)
local player, by_player = Admin.valid_players(player,by_player)
player, by_player = Admin.valid_players(player,by_player)
reason = reason or 'No Other Reason'
local warnings = Admin.get_warnings(player)
local punishment = punishments[warnings]
local reason = reason or 'No Other Reason'
if not punishment or punishment[1] == 'nothing' then return
elseif punishment[1] == 'message' then
local message = punishment[2]
@@ -85,14 +85,14 @@ local function give_punishment(player,by_player,reason)
end
function Admin.get_warnings(player)
local player = Game.get_player(player)
player = Game.get_player(player)
return global[player.name] or 0
end
function Admin.give_warning(player,by_player,reason,min)
local player, by_player = Admin.valid_players(player,by_player)
player, by_player = Admin.valid_players(player,by_player)
if not player then return end
local min = Game.get_player(by_player) and Game.get_player(by_player) ~= SERVER and take_action or min or 0
min = Game.get_player(by_player) and Game.get_player(by_player) ~= SERVER and take_action or min or 0
local warnings = Admin.get_warnings(player)
if warnings < min then warnings = min-1 end
warnings = warnings+1
@@ -104,12 +104,12 @@ function Admin.give_warning(player,by_player,reason,min)
give_punishment(player,by_player,reason)
end
function Admin.clear_warings(player,by_player,no_emit)
local player, by_player = Admin.valid_players(player,by_player)
function Admin.clear_warnings(player,by_player,no_emit)
player, by_player = Admin.valid_players(player,by_player)
if not player then return end
global[player.name]=nil
if not no_emit and Sync then
Sync.emit_embeded{
Sync.emit_embedded{
title='Player Clear',
color=Color.to_hex(defines.textcolor.low),
description='A player had their warnings cleared.',
@@ -138,4 +138,4 @@ script.on_event(defines.events.on_tick,function(event)
end)
-- Module Return
return ThisModule
return ThisModule

View File

@@ -2,7 +2,7 @@
-- @module ExpGamingAdmin@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alais Admin
-- @alias Admin
-- Module Require
local Game = require('FactorioStdLib.Game')
@@ -34,13 +34,13 @@ local global = global{
-- Function Define
function Admin.valid_players(player,by_player)
local player = Game.get_player(player)
local by_player = Game.get_player(by_player) or SERVER
player = Game.get_player(player)
by_player = Game.get_player(by_player) or SERVER
return player, by_player
end
function Admin.create_reason(reason,name)
local reason = reason or 'No Reason'
reason = reason or 'No Reason'
if not string.find(string.lower(reason),string.lower(name)) then reason = reason..' - '..name end
if Sync and Sync.info.date ~= '0000/00/00' and not string.find(string.lower(reason),Sync.info.date) then reason = reason..' - '..Sync.info.date end
if not string.find(string.lower(reason),'appeal') then reason = reason..' - Vist www.explosivegaming.nl to appeal.' end
@@ -48,20 +48,20 @@ function Admin.create_reason(reason,name)
end
function Admin.allowed(player)
local player = Game.get_player(player)
player = Game.get_player(player)
if Role then
return Role.allowed(player,'admin-commands')
else return player.admin end
end
function Admin.set_banned(player,set)
local player=Game.get_player(player)
player = Game.get_player(player)
if not player then return false end
global.banned[player.name] = set
end
function Admin.is_banned(player,detail)
local player=Game.get_player(player)
player = Game.get_player(player)
if not player then return false end
local banned = global.banned[player.name]
if banned == true then return true end
@@ -82,13 +82,13 @@ function Admin.take_action(action,player,by_player,reason)
end
function Admin.clear_player(player,by_player)
local player, by_player = Admin.valid_players(player,by_player)
player, by_player = Admin.valid_players(player,by_player)
if not player then return end
if Server and Admin.is_banned(player,true) == true then Server.interface(game.unban_player,true,player) end
if Admin.clear_warings then Admin.clear_warings(player,by_player,true) end
if Admin.clear_warnings then Admin.clear_warnings(player,by_player,true) end
if Admin.clear_reports then Admin.clear_reports(player,by_player,true) end
if Server and Role.has_flag(player,'is_jail') then Server.interface(Role.revert,true,player,by_player,2) end
if Sync then Sync.emit_embeded{
if Sync then Sync.emit_embedded{
title='Player Clear',
color=Color.to_hex(defines.textcolor.low),
description='A player had their reports and warnings cleared.',