mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Converted Modules To Use Roles
This commit is contained in:
@@ -6,6 +6,9 @@
|
|||||||
local moduleIndex = require("/modules/index")
|
local moduleIndex = require("/modules/index")
|
||||||
local Manager = {}
|
local Manager = {}
|
||||||
|
|
||||||
|
-- this is a constant that is used to represent the server
|
||||||
|
SERVER = setmetatable({index=0,name='<server>',online_time=0,afk_time=0,print=print},{__index=function(tbl,key) if type(game.player[key]) == 'function' then return function() end else return nil end end})
|
||||||
|
|
||||||
--- Setup for metatable of the Manager to force read only nature
|
--- Setup for metatable of the Manager to force read only nature
|
||||||
-- @usage Manager() -- runs Manager.loadModdules()
|
-- @usage Manager() -- runs Manager.loadModdules()
|
||||||
-- @usage Manager[name] -- returns module by that name
|
-- @usage Manager[name] -- returns module by that name
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[player-list]
|
[ExpGamingPlayer-playerList]
|
||||||
tooltip=Toggle player list, right click player for more info
|
tooltip=Toggle player list, right click player for more info
|
||||||
format-nil=__1__ - __2__
|
format-nil=__1__ - __2__
|
||||||
format=__1__ - __2__ - __3__
|
format=__1__ - __2__ - __3__
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
--- Allows control over decon rights, if ExpGamingCore.Ranking is not installed it will allow admins to instant remove trees and thats it.
|
--- Allows control over decon rights, if ExpGamingCore.Role is not installed it will allow admins to instant remove trees and thats it.
|
||||||
-- @module DeconControl@4.0.0
|
-- @module DeconControl@4.0.0
|
||||||
-- @author Cooldude2606
|
-- @author Cooldude2606
|
||||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||||
@@ -7,13 +7,13 @@
|
|||||||
-- Module Require
|
-- Module Require
|
||||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
local Server = require('ExpGamingCore.Server@^4.0.0')
|
local Server = require('ExpGamingCore.Server@^4.0.0')
|
||||||
local Ranking -- ExpGamingCore.Ranking@^4.0.0
|
local Role -- ExpGamingCore.Role@^4.0.0
|
||||||
|
|
||||||
-- Module Define
|
-- Module Define
|
||||||
local module_verbose = false
|
local module_verbose = false
|
||||||
local ThisModule = {
|
local ThisModule = {
|
||||||
on_init=function()
|
on_init=function()
|
||||||
if loaded_modules['ExpGamingCore.Ranking@^4.0.0'] then Ranking = require('ExpGamingCore.Ranking@^4.0.0') end
|
if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,13 +35,12 @@ Event.register(-1,function(event)
|
|||||||
if not chache then
|
if not chache then
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
if not Ranking then
|
if not Role then
|
||||||
if player.admin then self.data.chache[event.player_index] = {'tree-decon',false}
|
if player.admin then self.data.chache[event.player_index] = {'tree-decon',false}
|
||||||
else self.data.chache[event.player_index] = {'decon',false} end
|
else self.data.chache[event.player_index] = {'decon',false} end
|
||||||
else
|
else
|
||||||
local rank = Ranking.get_rank(player)
|
if Role.allowed(player,'tree-decon') then self.data.chache[event.player_index] = {'tree-decon',false}
|
||||||
if rank:allowed('tree-decon') then self.data.chache[event.player_index] = {'tree-decon',false}
|
elseif not Role.allowed(player,'decon') then self.data.chache[event.player_index] = {'no-decon',false}
|
||||||
elseif not rank:allowed('decon') then self.data.chache[event.player_index] = {'no-decon',false}
|
|
||||||
else self.data.chache[event.player_index] = {'decon',false} end
|
else self.data.chache[event.player_index] = {'decon',false} end
|
||||||
end
|
end
|
||||||
chache = self.data.chache[event.player_index]
|
chache = self.data.chache[event.player_index]
|
||||||
@@ -58,8 +57,7 @@ Event.register(-1,function(event)
|
|||||||
chache[2] = true
|
chache[2] = true
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
player_return({'tree-decon.player-print'},defines.textcolor.crit,player)
|
player_return({'tree-decon.player-print'},defines.textcolor.crit,player)
|
||||||
local rank = Ranking.get_group('Admin').lowest
|
Role.print(Role.meta.groups.Admin.lowest,{'tree-decon.rank-print',player.name},defines.textcolor.info)
|
||||||
Ranking.print(rank,{'tree-decon.rank-print',player.name},defines.textcolor.info)
|
|
||||||
if Admin then Admin.give_warning(player,'<server>','Trying To Decon The Base') end
|
if Admin then Admin.give_warning(player,'<server>','Trying To Decon The Base') end
|
||||||
end
|
end
|
||||||
self.data.clear = game.tick + 10
|
self.data.clear = game.tick + 10
|
||||||
|
|||||||
@@ -6,14 +6,14 @@
|
|||||||
|
|
||||||
-- Module Require
|
-- Module Require
|
||||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
local Ranking -- ExpGamingCore.Ranking@^4.0.0
|
local Role -- ExpGamingCore.Role@^4.0.0
|
||||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||||
|
|
||||||
-- Module Define
|
-- Module Define
|
||||||
local module_verbose = false
|
local module_verbose = false
|
||||||
local Admin = {
|
local Admin = {
|
||||||
on_init=function()
|
on_init=function()
|
||||||
if loaded_modules['ExpGamingCore.Ranking@^4.0.0'] then Ranking = require('ExpGamingCore.Ranking@^4.0.0') end
|
if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end
|
||||||
if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end
|
if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end
|
||||||
if loaded_modules['ExpGamingCore.Server@^4.0.0'] then require('ExpGamingCore.Server@^4.0.0').add_module_to_interface('Admin','ExpGamingAdmin.AdminLib') end
|
if loaded_modules['ExpGamingCore.Server@^4.0.0'] then require('ExpGamingCore.Server@^4.0.0').add_module_to_interface('Admin','ExpGamingAdmin.AdminLib') end
|
||||||
end,
|
end,
|
||||||
@@ -41,9 +41,8 @@ end
|
|||||||
|
|
||||||
function Admin.allowed(player)
|
function Admin.allowed(player)
|
||||||
local player = Game.get_player(player)
|
local player = Game.get_player(player)
|
||||||
if Ranking then
|
if Role then
|
||||||
local lowest_admin_power = Ranking.get_group('Admin').lowest.power
|
return Role.allowed(player,'admin-commands')
|
||||||
return lowest_admin_power >= Ranking.get_rank(player).power
|
|
||||||
else return player.admin end
|
else return player.admin end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -79,7 +78,7 @@ function Admin.clear_player(player,by_player)
|
|||||||
if Admin.is_banned(player,true) == true then Server.interface(game.unban_player,true,player,by_player) end
|
if Admin.is_banned(player,true) == true then Server.interface(game.unban_player,true,player,by_player) end
|
||||||
if Admin.clear_warings then Admin.clear_warings(player,by_player,true) end
|
if Admin.clear_warings then Admin.clear_warings(player,by_player,true) end
|
||||||
if Admin.clear_reports then Admin.clear_reports(player,by_player,true) end
|
if Admin.clear_reports then Admin.clear_reports(player,by_player,true) end
|
||||||
if Ranking.get_rank(player).group.name == 'Jail' then Server.interface(Ranking.revert,true,player,by_player) end
|
if 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_embeded{
|
||||||
title='Player Clear',
|
title='Player Clear',
|
||||||
color=Color.to_hex(defines.textcolor.low),
|
color=Color.to_hex(defines.textcolor.low),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local Admin = Admin
|
local Admin = Admin
|
||||||
local Ranking = require('ExpGamingCore.Ranking')
|
local Role = require('ExpGamingCore.Role')
|
||||||
|
|
||||||
--- Used to jail a player which stops them from moving
|
--- Used to jail a player which stops them from moving
|
||||||
-- @command jail
|
-- @command jail
|
||||||
@@ -11,8 +11,8 @@ commands.add_command('jail', 'Jails a player', {
|
|||||||
}, function(event,args)
|
}, function(event,args)
|
||||||
local player = args.player
|
local player = args.player
|
||||||
local reason = args.reason
|
local reason = args.reason
|
||||||
if Ranking.get_rank(player):allowed('no-report') then player_return({'ExpGamingAdmin.cant-report',args.player}) return commands.error end
|
if Role.allowed(player,'no-report') then player_return{'ExpGamingAdmin.cant-report',args.player} return commands.error end
|
||||||
if Admin.is_banned(player) then player_return({'commands.cant-report-ban',args.player}) return commands.error end
|
if Admin.is_banned(player) then player_return{'commands.cant-report-ban',args.player} return commands.error end
|
||||||
Admin.jail(player,event.player_index,reason)
|
Admin.jail(player,event.player_index,reason)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -24,5 +24,5 @@ commands.add_command('unjail', 'Returns a player\'s old rank', {
|
|||||||
}, function(event,args)
|
}, function(event,args)
|
||||||
local player = args.player
|
local player = args.player
|
||||||
if Admin.is_banned(player) then player_return({'commands.cant-report-ban',args.player}) return commands.error end
|
if Admin.is_banned(player) then player_return({'commands.cant-report-ban',args.player}) return commands.error end
|
||||||
Server.interface(Ranking.revert,true,player,event.player_index)
|
Server.interface(Role.revert,true,player,event.player_index,2)
|
||||||
end)
|
end)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
local Admin = Admin
|
local Admin = Admin
|
||||||
local Ranking = require('ExpGamingCore.Ranking@^4.0.0')
|
local Role = require('ExpGamingCore.Role@^4.0.0')
|
||||||
|
|
||||||
--- Reports a player
|
--- Reports a player
|
||||||
-- @command report
|
-- @command report
|
||||||
@@ -13,7 +13,7 @@ commands.add_command('report', 'Reports a player', {
|
|||||||
local player = args.player
|
local player = args.player
|
||||||
local reason = args.reason
|
local reason = args.reason
|
||||||
if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player}) return commands.error end
|
if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player}) return commands.error end
|
||||||
if Ranking.get_rank(player):allowed('no-report') then player_return({'ExpGamingAdmin.cant-report',args.player}) return commands.error end
|
if Role.allowed(player,'no-report') then player_return({'ExpGamingAdmin.cant-report',args.player}) 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}) return commands.error end end
|
for _,report in pairs(global.addons.reports.reports) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player}) 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}) 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}) return commands.error end end
|
||||||
Admin.report(player,event.player_index,reason)
|
Admin.report(player,event.player_index,reason)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local Admin = Admin
|
local Admin = Admin
|
||||||
local Ranking = require('ExpGamingCore.Ranking@^4.0.0')
|
local Role = require('ExpGamingCore.Role@^4.0.0')
|
||||||
|
|
||||||
--- Gives a warning to a player
|
--- Gives a warning to a player
|
||||||
-- @command warn
|
-- @command warn
|
||||||
@@ -11,8 +11,8 @@ commands.add_command('warn', 'Gives a player a warning', {
|
|||||||
}, function(event,args)
|
}, function(event,args)
|
||||||
local player = args.player
|
local player = args.player
|
||||||
local reason = args.reason
|
local reason = args.reason
|
||||||
if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player}) return commands.error end
|
if Admin.is_banned(player) then player_return{'ExpGamingAdmin.cant-report-ban',args.player} return commands.error end
|
||||||
if Ranking.get_rank(player):allowed('no-report') then player_return({'ExpGamingAdmin.cant-report',args.player}) return commands.error end
|
if Role.allowed(player,'no-report') then player_return{'ExpGamingAdmin.cant-report',args.player} return commands.error end
|
||||||
Admin.give_warning(player,event.player_index,reason)
|
Admin.give_warning(player,event.player_index,reason)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
-- Module Require
|
-- Module Require
|
||||||
local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0')
|
local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0')
|
||||||
local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
||||||
local Ranking = require('ExpGamingCore.Ranking@^4.0.0')
|
local Role = require('ExpGamingCore.Role@^4.0.0')
|
||||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
local playerInfo -- ExpGamingPlayer@^4.0.0
|
local playerInfo -- ExpGamingPlayer@^4.0.0
|
||||||
|
|
||||||
@@ -89,9 +89,9 @@ local player_drop_down = Gui.inputs.add_drop_down('player-drop-down-admin-comman
|
|||||||
player_info_flow.clear()
|
player_info_flow.clear()
|
||||||
if selected == 'Select Player' then return
|
if selected == 'Select Player' then return
|
||||||
else get_player_info(selected,player_info_flow,true) end
|
else get_player_info(selected,player_info_flow,true) end
|
||||||
local rank = Ranking.get_rank(player)
|
local role = Role.get_highest(player)
|
||||||
local _rank = Ranking.get_rank(selected)
|
local _role = Role.get(selected)
|
||||||
if rank.power >= _rank.power then element.parent.warning.caption = {'ExpGamingAdmin.warning'}
|
if role.index >= _role.index then element.parent.warning.caption = {'ExpGamingAdmin.warning'}
|
||||||
else element.parent.warning.caption = '' end
|
else element.parent.warning.caption = '' end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -118,12 +118,12 @@ local take_action = Gui.inputs.add{
|
|||||||
caption={'ExpGamingAdmin.take-action'}
|
caption={'ExpGamingAdmin.take-action'}
|
||||||
}:on_event('click',function(event)
|
}:on_event('click',function(event)
|
||||||
local dropdowns = event.element.parent
|
local dropdowns = event.element.parent
|
||||||
local rank = Ranking.get_rank(event.player_index)
|
local role = Role.get_highest(event.player_index)
|
||||||
local _action= dropdowns.parent.action.caption ~= 'Select Action' and dropdowns.parent.action.caption or nil
|
local _action= dropdowns.parent.action.caption ~= 'Select Action' and dropdowns.parent.action.caption or nil
|
||||||
local _player = Game.get_player(dropdowns.parent.player.caption)
|
local _player = Game.get_player(dropdowns.parent.player.caption)
|
||||||
if not _player or not _action then dropdowns.warning.caption = {'ExpGamingAdmin.invalid'} return end
|
if not _player or not _action then dropdowns.warning.caption = {'ExpGamingAdmin.invalid'} return end
|
||||||
local _rank = Ranking.get_rank(_player)
|
local _role = Role.get_highest(_player)
|
||||||
if rank.power >= _rank.power then dropdowns.warning.caption = {'ExpGamingAdmin.rank-high'} return end
|
if role.index >= _role.index then dropdowns.warning.caption = {'ExpGamingAdmin.rank-high'} return end
|
||||||
local _reason = dropdowns['reason-input-admin-commands'] and dropdowns['reason-input-admin-commands'].text
|
local _reason = dropdowns['reason-input-admin-commands'] and dropdowns['reason-input-admin-commands'].text
|
||||||
if (_action == 'Jail' or _action == 'Kick' or _action == 'Ban' or _action == 'Temp Ban') and (_reason == 'Enter Reason' or string.len(_reason) < 20) then return end
|
if (_action == 'Jail' or _action == 'Kick' or _action == 'Ban' or _action == 'Temp Ban') and (_reason == 'Enter Reason' or string.len(_reason) < 20) then return end
|
||||||
Admin.take_action(_action,_player,event.player_index,_reason)
|
Admin.take_action(_action,_player,event.player_index,_reason)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
--- Adds a jail function to the admin set, require ExpGamingRanking to work.
|
--- Adds a jail function to the admin set, require ExpGamingRole to work.
|
||||||
-- @module ExpGamingAdmin.Jail@4.0.0
|
-- @module ExpGamingAdmin.Jail@4.0.0
|
||||||
-- @author Cooldude2606
|
-- @author Cooldude2606
|
||||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0')
|
local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0')
|
||||||
local AdminGui = require('ExpGamingAdmin.Gui@^4.0.0')
|
local AdminGui = require('ExpGamingAdmin.Gui@^4.0.0')
|
||||||
local Server = require('ExpGamingCore.Server@^4.0.0')
|
local Server = require('ExpGamingCore.Server@^4.0.0')
|
||||||
local Ranking = require('ExpGamingCore.Ranking@^4.0.0')
|
local Role = require('ExpGamingCore.Role@^4.0.0')
|
||||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
local Color -- FactorioStdLib.Color@^0.8.0
|
local Color -- FactorioStdLib.Color@^0.8.0
|
||||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||||
@@ -40,8 +40,9 @@ function Admin.jail(player,by_player,reason)
|
|||||||
['Reason:']=reason
|
['Reason:']=reason
|
||||||
} end
|
} end
|
||||||
if Admin.move_inventory then Admin.move_inventory(player) end
|
if Admin.move_inventory then Admin.move_inventory(player) end
|
||||||
Ranking.meta.last_jail = player.name
|
Role.meta.last_jail = player.name
|
||||||
Server.interface(Ranking.give_rank,true,player,'Jail',by_player_name)
|
Server.interface(Role.unassign,true,player,Role.get(player),by_player_name)
|
||||||
|
Server.interface(Role.assign,true,player,'Jail',by_player_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
Admin.add_action('Jail',Admin.jail)
|
Admin.add_action('Jail',Admin.jail)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
-- Module Require
|
-- Module Require
|
||||||
local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0')
|
local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0')
|
||||||
local Server = require('ExpGamingCore.Server@^4.0.0')
|
local Server = require('ExpGamingCore.Server@^4.0.0')
|
||||||
local Ranking = require('ExpGamingCore.Ranking@^4.0.0')
|
local Role = require('ExpGamingCore.Role@^4.0.0')
|
||||||
local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
||||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
local Color = require('FactorioStdLib.Color@^0.8.0')
|
local Color = require('FactorioStdLib.Color@^0.8.0')
|
||||||
@@ -40,13 +40,11 @@ local function valid_players(player,by_player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function report_message(player,by_player,reason)
|
local function report_message(player,by_player,reason)
|
||||||
local low_rank = Ranking.get_group('User').highest
|
|
||||||
local high_rank = Ranking.get_group('Admin').lowest
|
|
||||||
local player, by_player_name = valid_players(player,by_player)
|
local player, by_player_name = valid_players(player,by_player)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
if Admin.is_banned(player,true) == 'report' then return end
|
if Admin.is_banned(player,true) == 'report' then return end
|
||||||
Ranking.print(low_rank,{'ExpGamingAdmin.low-print',player.name,reason},defines.textcolor.info,true)
|
Role.print(Role.meta.groups.User.lowest,{'ExpGamingAdmin.low-print',player.name,reason},defines.textcolor.info,true)
|
||||||
Ranking.print(high_rank,{'ExpGamingAdmin.high-print',player.name,by_player_name,reason},defines.textcolor.med)
|
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_embeded{
|
||||||
title='Player Report',
|
title='Player Report',
|
||||||
color=Color.to_hex(defines.textcolor.med),
|
color=Color.to_hex(defines.textcolor.med),
|
||||||
@@ -61,7 +59,7 @@ local function cheak_reports(player)
|
|||||||
local player = Game.get_player(player)
|
local player = Game.get_player(player)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
local reports = Admin.count_reports(player)
|
local reports = Admin.count_reports(player)
|
||||||
if reports >= reports_needed_for_jail and global.actions[player.name] ~= 'report-jail' and Ranking.get_rank(player).group.name ~= 'Jail' then
|
if reports >= reports_needed_for_jail and global.actions[player.name] ~= 'report-jail' and Role.get_highest(player).group.name ~= 'Jail' then
|
||||||
global.actions[player.name] = actions.report
|
global.actions[player.name] = actions.report
|
||||||
Admin.jail(player,'<server>','Too many user reports. Contact an Admin to be unjailed.')
|
Admin.jail(player,'<server>','Too many user reports. Contact an Admin to be unjailed.')
|
||||||
end
|
end
|
||||||
@@ -86,9 +84,9 @@ end
|
|||||||
|
|
||||||
function Admin.report(player,by_player,reason)
|
function Admin.report(player,by_player,reason)
|
||||||
local player, by_player_name = valid_players(player,by_player)
|
local player, by_player_name = valid_players(player,by_player)
|
||||||
if not player or Ranking.get_rank(player):allowed('no-report') then return end
|
if not player or Role.allowed(player,'no-report') then return end
|
||||||
if Admin.is_banned(by_player) or Ranking.get_group(by_player).name == 'Jail' then return end
|
if Admin.is_banned(by_player) or Role.has_flag(by_player,'is_jail') then return end
|
||||||
if Ranking.get_rank(by_player):allowed('varified') then
|
if Role.has_flag(by_player,'is_varified') then
|
||||||
global.varified[player.name] = global.varified[player.name] or {}
|
global.varified[player.name] = global.varified[player.name] or {}
|
||||||
local reports = global.varified[player.name]
|
local reports = global.varified[player.name]
|
||||||
for _,value in pairs(reports) do
|
for _,value in pairs(reports) do
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
--- Adds a temp ban function to the admin set, requires ExpGamingCore.Ranking to work.
|
--- Adds a temp ban function to the admin set, requires ExpGamingCore.Role to work.
|
||||||
-- @module ExpGamingAdmin.KicTempBan@4.0.0
|
-- @module ExpGamingAdmin.KicTempBan@4.0.0
|
||||||
-- @author Cooldude2606
|
-- @author Cooldude2606
|
||||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
-- Module Require
|
-- Module Require
|
||||||
local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0')
|
local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0')
|
||||||
local Server = require('ExpGamingCore.Server@^4.0.0')
|
local Server = require('ExpGamingCore.Server@^4.0.0')
|
||||||
local Ranking = require('ExpGamingCore.Ranking@^4.0.0')
|
local Role = require('ExpGamingCore.Role@^4.0.0')
|
||||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
local Color = require('FactorioStdLib.Color@^0.8.0')
|
local Color = require('FactorioStdLib.Color@^0.8.0')
|
||||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||||
@@ -36,8 +36,9 @@ function Admin.temp_ban(player,by_player,reason)
|
|||||||
} end
|
} end
|
||||||
game.print({'ExpGamingAdmin.temp-ban',player.name,by_player_name,reason},defines.textcolor.info)
|
game.print({'ExpGamingAdmin.temp-ban',player.name,by_player_name,reason},defines.textcolor.info)
|
||||||
if Admin.move_inventory then Admin.move_inventory(player) end
|
if Admin.move_inventory then Admin.move_inventory(player) end
|
||||||
Ranking.meta.last_jail = player.name
|
Role.meta.last_jail = player.name
|
||||||
Server.interface(Ranking.give_rank,true,player,'Jail',by_player_name)
|
Server.interface(Role.unassign,true,player,Role.get(player),by_player_name)
|
||||||
|
Server.interface(Role.assign,true,player,'Jail',by_player_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
Admin.add_action('Temp Ban',Admin.temp_ban)
|
Admin.add_action('Temp Ban',Admin.temp_ban)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
-- Module Require
|
-- Module Require
|
||||||
local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0')
|
local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0')
|
||||||
local Server = require('ExpGamingCore.Server@^4.0.0')
|
local Server = require('ExpGamingCore.Server@^4.0.0')
|
||||||
local Ranking = require('ExpGamingCore.Ranking@^4.0.0')
|
local Role = require('ExpGamingCore.Role@^4.0.0')
|
||||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
local Color = require('FactorioStdLib.Color@^0.8.0')
|
local Color = require('FactorioStdLib.Color@^0.8.0')
|
||||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||||
@@ -45,11 +45,11 @@ local ThisModule = {
|
|||||||
end,
|
end,
|
||||||
on_post=function()
|
on_post=function()
|
||||||
local highest = nil
|
local highest = nil
|
||||||
for _,rank in pairs(Ranking.ranks) do
|
for _,role in pairs(Role.roles) do
|
||||||
local power = rank.power
|
local power = role.index
|
||||||
if not highest and not rank:allowed('no-report') then highest = power-1 end
|
if not highest and not role.not_reportable then highest = power-1 end
|
||||||
local _power = power; if highest then _power = power-highest end
|
local _power = power; if highest then _power = power-highest end
|
||||||
if rank:allowed('no-report') then remove_warnings_time[power] = 0
|
if role.not_reportable then remove_warnings_time[power] = 0
|
||||||
else remove_warnings_time[power] = min_time_to_remove_warning*_power end
|
else remove_warnings_time[power] = min_time_to_remove_warning*_power end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -131,8 +131,8 @@ script.on_event(defines.events.on_tick,function(event)
|
|||||||
if (game.tick % min_time_to_remove_warning) == 0 then
|
if (game.tick % min_time_to_remove_warning) == 0 then
|
||||||
for name,warnings in pairs(global) do
|
for name,warnings in pairs(global) do
|
||||||
if warnings > 0 then
|
if warnings > 0 then
|
||||||
local rank = Ranking.get_rank(name)
|
local role = Role.get(name)
|
||||||
local time_to_remove = remove_warnings_time[rank.power]
|
local time_to_remove = remove_warnings_time[role.index]
|
||||||
if (game.tick % time_to_remove) == 0 then
|
if (game.tick % time_to_remove) == 0 then
|
||||||
global[name]=warnings-1
|
global[name]=warnings-1
|
||||||
if global.warnings[name] > 5 then
|
if global.warnings[name] > 5 then
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
-- Module Require
|
-- Module Require
|
||||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
local Ranking -- ExpGamingCore.Ranking@^4.0.0
|
local Role -- ExpGamingCore.Role@^4.0.0
|
||||||
|
|
||||||
-- Local Varibles
|
-- Local Varibles
|
||||||
-- lots of these are jokes, but some have uses
|
-- lots of these are jokes, but some have uses
|
||||||
@@ -113,7 +113,7 @@ local commands = {
|
|||||||
local module_verbose = false
|
local module_verbose = false
|
||||||
local ThisModule = {
|
local ThisModule = {
|
||||||
on_init=function()
|
on_init=function()
|
||||||
if loaded_modules['ExpGamingCore.Ranking@^4.0.0'] then Ranking = require('ExpGamingCore.Ranking@^4.0.0') end
|
if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ script.on_event(defines.events.on_console_chat,function(event)
|
|||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
local player_message = event.message:lower():gsub("%s+", "")
|
local player_message = event.message:lower():gsub("%s+", "")
|
||||||
local allowed = Ranking and Ranking.get_rank(player):allowed('global-chat') or player.admin
|
local allowed = Role and Role.allowed(player,'global-chat') or player.admin
|
||||||
for to_find,message in pairs(messages) do
|
for to_find,message in pairs(messages) do
|
||||||
if player_message:match(command_syntax..to_find) then
|
if player_message:match(command_syntax..to_find) then
|
||||||
if allowed then
|
if allowed then
|
||||||
@@ -131,7 +131,7 @@ script.on_event(defines.events.on_console_chat,function(event)
|
|||||||
else player_return({'ExpGamingBot-autoChat.rank-error'},nil,player) end
|
else player_return({'ExpGamingBot-autoChat.rank-error'},nil,player) end
|
||||||
elseif player_message:match(to_find) then
|
elseif player_message:match(to_find) then
|
||||||
if is_type(message,'function') then message=message(player) end
|
if is_type(message,'function') then message=message(player) end
|
||||||
player_return({'ExpGamingBot-autoChat.message',message},nil,player)
|
if not allowed then player_return({'ExpGamingBot-autoChat.message',message},nil,player) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for to_find,message in pairs(commands) do
|
for to_find,message in pairs(commands) do
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
-- Module Require
|
-- Module Require
|
||||||
local Server = require('ExpGamingCore.Server')
|
local Server = require('ExpGamingCore.Server')
|
||||||
local Game = require('FactorioStdLib.Game')
|
local Game = require('FactorioStdLib.Game')
|
||||||
local Ranking -- ExpGamingCore.Ranking@4.0.0
|
local Role -- ExpGamingCore.Role@4.0.0
|
||||||
local Sync -- ExpGamingCore.Sync@4.0.0
|
local Sync -- ExpGamingCore.Sync@4.0.0
|
||||||
|
|
||||||
-- Local Varibles
|
-- Local Varibles
|
||||||
@@ -16,7 +16,7 @@ local Sync -- ExpGamingCore.Sync@4.0.0
|
|||||||
local module_verbose = false
|
local module_verbose = false
|
||||||
local ThisModule = {
|
local ThisModule = {
|
||||||
on_init=function()
|
on_init=function()
|
||||||
if loaded_modules['ExpGamingCore.Ranking@^4.0.0'] then Ranking = require('ExpGamingCore.Ranking@^4.0.0') end
|
if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end
|
||||||
if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end
|
if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end
|
||||||
end,
|
end,
|
||||||
on_post=function()
|
on_post=function()
|
||||||
@@ -31,8 +31,8 @@ script.on_init(function(event)
|
|||||||
timeout=54000, -- 3240000 = 15 hours dont make the mistake i did, 54000 is 15 minutes
|
timeout=54000, -- 3240000 = 15 hours dont make the mistake i did, 54000 is 15 minutes
|
||||||
reopen=true,
|
reopen=true,
|
||||||
data={
|
data={
|
||||||
high_rank= 'Owner',
|
high_role= 'Owner',
|
||||||
low_rank= 'Regular',
|
low_role= 'Regular',
|
||||||
low={
|
low={
|
||||||
{'ExpGamingBot-autoMessage.join-us'},
|
{'ExpGamingBot-autoMessage.join-us'},
|
||||||
{'ExpGamingBot-autoMessage.discord'},
|
{'ExpGamingBot-autoMessage.discord'},
|
||||||
@@ -43,7 +43,7 @@ script.on_init(function(event)
|
|||||||
}
|
}
|
||||||
}:on_event('timeout',function(self)
|
}:on_event('timeout',function(self)
|
||||||
local data = self.data
|
local data = self.data
|
||||||
if not data.high_rank or not data.low_rank
|
if not data.high_role or not data.low_role
|
||||||
or not data.low then self.reopen = false return end
|
or not data.low then self.reopen = false return end
|
||||||
game.print{'ExpGamingBot-autoMessage.message',{'ExpGamingBot-autoMessage.players-online',#game.connected_players}}
|
game.print{'ExpGamingBot-autoMessage.message',{'ExpGamingBot-autoMessage.players-online',#game.connected_players}}
|
||||||
game.print{'ExpGamingBot-autoMessage.message',{'ExpGamingBot-autoMessage.map-time',tick_to_display_format(game.tick)}}
|
game.print{'ExpGamingBot-autoMessage.message',{'ExpGamingBot-autoMessage.map-time',tick_to_display_format(game.tick)}}
|
||||||
@@ -52,10 +52,10 @@ script.on_init(function(event)
|
|||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
local data = self.data
|
local data = self.data
|
||||||
if not data.high_rank or not data.low_rank
|
if not data.high_role or not data.low_role
|
||||||
or not data.low then self.reopen = false return end
|
or not data.low then self.reopen = false return end
|
||||||
-- idk but this stoped working for no appent reason so i added more checks for nil values
|
-- idk but this stoped working for no appent reason so i added more checks for nil values
|
||||||
if Ranking and Ranking.get_rank(player).power <= Ranking.get_rank(data.low_rank).power or player.admin then return end
|
if Role and Role.get_highest(player).index <= Role.get(data.low_role).index or player.admin then return end
|
||||||
for _,message in pairs(data.low) do
|
for _,message in pairs(data.low) do
|
||||||
player_return({'ExpGamingBot-autoMessage.message',message},nil,player)
|
player_return({'ExpGamingBot-autoMessage.message',message},nil,player)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ script.on_event(defines.events.on_player_respawned,function(event)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- overided by ExpGamingCore.Ranking if present
|
-- overided by ExpGamingCore.Role if present
|
||||||
script.on_event(defines.events.on_pre_player_died,function(event)
|
script.on_event(defines.events.on_pre_player_died,function(event)
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
if player.admin then
|
if player.admin then
|
||||||
@@ -54,26 +54,26 @@ end)
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
on_init= function(self)
|
on_init= function(self)
|
||||||
if loaded_modules['ExpGamingCore.Ranking@^4.0.0'] then
|
if loaded_modules['ExpGamingCore.Role@^4.0.0'] then
|
||||||
local Ranking = require('ExpGamingCore.Ranking@^4.0.0')
|
local Role = require('ExpGamingCore.Role@^4.0.0')
|
||||||
-- instant respawn
|
-- instant respawn
|
||||||
script.on_event(defines.events.on_pre_player_died,function(event)
|
script.on_event(defines.events.on_pre_player_died,function(event)
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
if Ranking.get_rank(player):allowed('bonus-respawn') then
|
if Role.allowed(player,'bonus-respawn') then
|
||||||
player.ticks_to_respawn = 120
|
player.ticks_to_respawn = 120
|
||||||
-- manually dispatch death event because it is not fired when ticks_to_respawn is set pre death
|
-- manually dispatch death event because it is not fired when ticks_to_respawn is set pre death
|
||||||
Event.dispatch{
|
script.raise_event(defines.events.on_player_died,{
|
||||||
name=defines.events.on_player_died,
|
name=defines.events.on_player_died,
|
||||||
tick=event.tick,
|
tick=event.tick,
|
||||||
player_index=event.player_index,
|
player_index=event.player_index,
|
||||||
cause = event.cause
|
cause = event.cause
|
||||||
}
|
})
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
-- either clears or adds default when rank changed
|
-- either clears or adds default when rank changed
|
||||||
script.on_event(defines.events.rank_change,function(event)
|
script.on_event(defines.events.role_change,function(event)
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
if event.new_rank:allowed('bonus') then
|
if Role.allowed(player,'bonus') then
|
||||||
for _,setting in pairs(settings) do player[key] = setting*0.2 end
|
for _,setting in pairs(settings) do player[key] = setting*0.2 end
|
||||||
global[player.index]=20
|
global[player.index]=20
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
|
|
||||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
local Ranking = require('ExpGamingCore.Ranking@^4.0.0')
|
local Role = require('ExpGamingCore.Role@^4.0.0')
|
||||||
|
|
||||||
-- Set an item to true to disallow it from being repaired
|
-- Set an item to true to disallow it from being repaired
|
||||||
local disallow = {
|
local disallow = {
|
||||||
@@ -46,9 +46,9 @@ commands.add_command('repair', 'Repairs all destoryed and damaged entites in an
|
|||||||
}, function(event,args)
|
}, function(event,args)
|
||||||
local range = args.range
|
local range = args.range
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
local rank = Ranking.get_rank(player)
|
local role = Role.get_highest(player)
|
||||||
local highest_admin_power = Ranking.get_group('Admin').highest.power-1
|
local highest_admin_power = Role.meta.groups.Admin.highest-1
|
||||||
local max_range = rank.power-highest_admin_power > 0 and const/(rank.power-highest_admin_power) or nil
|
local max_range = role.index-highest_admin_power > 0 and const/(role.index-highest_admin_power) or nil
|
||||||
local center = player and player.position or {x=0,y=0}
|
local center = player and player.position or {x=0,y=0}
|
||||||
if not range or max_range and range > max_range then player_return({'commands.invalid-range',0,math.floor(max_range)}) return commands.error end
|
if not range or max_range and range > max_range then player_return({'commands.invalid-range',0,math.floor(max_range)}) return commands.error end
|
||||||
local area = {{center.x-range,center.y-range},{center.x+range,center.y+range}}
|
local area = {{center.x-range,center.y-range},{center.x+range,center.y+range}}
|
||||||
|
|||||||
@@ -4,14 +4,13 @@
|
|||||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||||
|
|
||||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
local Ranking -- ExpGamingCore.Ranking@^4.0.0
|
local Role -- ExpGamingCore.Role@^4.0.0
|
||||||
|
|
||||||
-- Module Define
|
-- Module Define
|
||||||
local module_verbose = false
|
local module_verbose = false
|
||||||
local ThisModule = {
|
local ThisModule = {
|
||||||
on_init=function()
|
on_init=function()
|
||||||
if loaded_modules['ExpGamingCore.Ranking@^4.0.0'] then Ranking = require('ExpGamingCore.Ranking@^4.0.0') end
|
if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end
|
||||||
--code
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,9 +21,9 @@ commands.add_command('tag', 'Give yourself a custom tag. Use "" to have more tha
|
|||||||
['tag'] = {true,'string-len',20}
|
['tag'] = {true,'string-len',20}
|
||||||
}, function(event,args)
|
}, function(event,args)
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
if Ranking then
|
if Role then
|
||||||
local rank = Ranking.get_rank(player)
|
local role = Role.get_highest(player)
|
||||||
player.tag = rank.tag..' - '..args.tag
|
player.tag = role.tag..' - '..args.tag
|
||||||
else player.tag = args.tag end
|
else player.tag = args.tag end
|
||||||
player_return('Your tag has been set. Use /tag-clear to remove your tag')
|
player_return('Your tag has been set. Use /tag-clear to remove your tag')
|
||||||
end)
|
end)
|
||||||
@@ -36,10 +35,11 @@ commands.add_command('tag-clear', 'Removes a custom tag.', {
|
|||||||
['player'] = {false,'player-rank'}
|
['player'] = {false,'player-rank'}
|
||||||
}, function(event,args)
|
}, function(event,args)
|
||||||
local player = args.player or game.player
|
local player = args.player or game.player
|
||||||
if Ranking then
|
if Role then
|
||||||
local rank = Ranking.get_rank(player)
|
local role = Role.get_highest(player)
|
||||||
player.tag = rank.tag
|
player.tag = role.tag
|
||||||
else player.tag = '' end
|
else player.tag = '' end
|
||||||
player_return('Your tag has been removed.')
|
player_return('Your tag has been removed.')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
return ThisModule
|
||||||
@@ -50,9 +50,9 @@ setmetatable(commands,{
|
|||||||
-- @field player converts the input into a valid player
|
-- @field player converts the input into a valid player
|
||||||
-- @field player_online converts the input to a player if the player is online
|
-- @field player_online converts the input to a player if the player is online
|
||||||
-- @field player_alive converts the input to a player if the player is online and alive
|
-- @field player_alive converts the input to a player if the player is online and alive
|
||||||
-- @field player_rank converts the input to a player if the player is a lower rank than the user or if the person is not admin and the user is
|
-- @field player_role converts the input to a player if the player is a lower rank than the user or if the person is not admin and the user is
|
||||||
-- @field player_rank-online converts the input to a player if the player is a lower rank than the user and online
|
-- @field player_role-online converts the input to a player if the player is a lower rank than the user and online
|
||||||
-- @field player_rank_alive converts the input to a player if the player is a lower rank than the user and online and alive
|
-- @field player_role_alive converts the input to a player if the player is a lower rank than the user and online and alive
|
||||||
commands.validate = {
|
commands.validate = {
|
||||||
['boolean']=function(value,event) local value = value.lower() if value == 'true' or valule == 'yes' or value == 'y' or value == '1' then return true else return false end end,
|
['boolean']=function(value,event) local value = value.lower() if value == 'true' or valule == 'yes' or value == 'y' or value == '1' then return true else return false end end,
|
||||||
['string']=function(value,event) return tostring(value) end,
|
['string']=function(value,event) return tostring(value) end,
|
||||||
@@ -129,7 +129,7 @@ function commands.validate_args(event)
|
|||||||
if not arg and not data[1] then return commands.error('invalid-inputs') end
|
if not arg and not data[1] then return commands.error('invalid-inputs') end
|
||||||
if data[2] == 'string-inf' then rtn[name] = table.concat(words,' ',index) break end
|
if data[2] == 'string-inf' then rtn[name] = table.concat(words,' ',index) break end
|
||||||
local valid = is_type(data[2],'function') and data[2] or commands.validate[data[2]] or error('Invalid type for command: "'..command.name..'/'..name..'"')
|
local valid = is_type(data[2],'function') and data[2] or commands.validate[data[2]] or error('Invalid type for command: "'..command.name..'/'..name..'"')
|
||||||
local temp_tbl = table.deep_copy(data) table.remove(temp_tbl,1) table.remove(temp_tbl,2)
|
local temp_tbl = table.deepcopy(data) table.remove(temp_tbl,1) table.remove(temp_tbl,1)
|
||||||
local value, err = valid(arg,event,unpack(temp_tbl))
|
local value, err = valid(arg,event,unpack(temp_tbl))
|
||||||
if value == commands.error then return value, err end
|
if value == commands.error then return value, err end
|
||||||
rtn[name] = value
|
rtn[name] = value
|
||||||
|
|||||||
@@ -177,11 +177,11 @@ function Gui:on_init()
|
|||||||
self.left:on_init(); self.left.on_init = nil
|
self.left:on_init(); self.left.on_init = nil
|
||||||
self.toolbar:on_init(); self.toolbar.on_init = nil
|
self.toolbar:on_init(); self.toolbar.on_init = nil
|
||||||
if loaded_modules['ExpGamingCore.Server'] then verbose('ExpGamingCore.Server is installed; Loading server src') require(module_path..'/src/server',{Gui=Gui}) end
|
if loaded_modules['ExpGamingCore.Server'] then verbose('ExpGamingCore.Server is installed; Loading server src') require(module_path..'/src/server',{Gui=Gui}) end
|
||||||
if loaded_modules['ExpGamingCore.Ranking'] then
|
if loaded_modules['ExpGamingCore.Role'] then
|
||||||
verbose('ExpGamingCore.Ranking is installed; Loading ranking src')
|
verbose('ExpGamingCore.Role is installed; Loading ranking src')
|
||||||
script.on_event('on_rank_change',function(event)
|
script.on_event('on_role_change',function(event)
|
||||||
Gui.toolbar.on_rank_change(event)
|
Gui.toolbar.on_role_change(event)
|
||||||
Gui.center.on_rank_change(event)
|
Gui.center.on_role_change(event)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
script.on_event('on_player_joined_game',function(event)
|
script.on_event('on_player_joined_game',function(event)
|
||||||
|
|||||||
@@ -209,5 +209,5 @@ center._events = {[defines.events.on_gui_closed]=function(event)
|
|||||||
if event.element and event.element.valid then event.element.destroy() end
|
if event.element and event.element.valid then event.element.destroy() end
|
||||||
end}
|
end}
|
||||||
|
|
||||||
center.on_rank_change = center.clear
|
center.on_role_change = center.clear
|
||||||
return center
|
return center
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
local Game = require('FactorioStdLib.Game')
|
local Game = require('FactorioStdLib.Game')
|
||||||
local Color = require('FactorioStdLib.Color')
|
local Color = require('FactorioStdLib.Color')
|
||||||
local Ranking -- this is optional and is hanndled by it being present, it is loaded on init
|
local Role -- this is optional and is hanndled by it being present, it is loaded on init
|
||||||
local mod_gui = require("mod-gui")
|
local mod_gui = require("mod-gui")
|
||||||
local Gui = Gui -- this is to force gui to remain in the ENV
|
local Gui = Gui -- this is to force gui to remain in the ENV
|
||||||
|
|
||||||
@@ -150,14 +150,14 @@ function left._left.toggle(event)
|
|||||||
if not success then error(err)
|
if not success then error(err)
|
||||||
elseif err == true then open = true
|
elseif err == true then open = true
|
||||||
elseif global.over_ride_left_can_open then
|
elseif global.over_ride_left_can_open then
|
||||||
if is_type(Ranking,'table') and Ranking.meta.rank_count > 0 then
|
if is_type(Role,'table') then
|
||||||
if Ranking.get_rank(player):allowed(_left.name) then open = true
|
if Role.allowed(player,_left.name) then open = true
|
||||||
else open = {gui.unauthorized} end
|
else open = {gui.unauthorized} end
|
||||||
else open = true end
|
else open = true end
|
||||||
else open = err end
|
else open = err end
|
||||||
else
|
else
|
||||||
if is_type(Ranking,'table') and Ranking.meta.rank_count > 0 then
|
if is_type(Role,'table') then
|
||||||
if Ranking.get_rank(player):allowed(_left.name) then open = true
|
if Role.allowed(player,_left.name) then open = true
|
||||||
else open = {gui.unauthorized} end
|
else open = {gui.unauthorized} end
|
||||||
else open = true end
|
else open = true end
|
||||||
end
|
end
|
||||||
@@ -181,7 +181,7 @@ left.on_player_joined_game = function(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function left:on_init()
|
function left:on_init()
|
||||||
if loaded_modules['ExpGamingCore.Ranking'] then Ranking = require('ExpGamingCore.Ranking') end
|
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
|
||||||
end
|
end
|
||||||
|
|
||||||
return left
|
return left
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
-- @function _comment
|
-- @function _comment
|
||||||
|
|
||||||
local Game = require('FactorioStdLib.Game')
|
local Game = require('FactorioStdLib.Game')
|
||||||
local Ranking -- this is optional and is hanndled by it being present, it is loaded on init
|
local Role -- this is optional and is hanndled by it being present, it is loaded on init
|
||||||
local mod_gui = require("mod-gui")
|
local mod_gui = require("mod-gui")
|
||||||
local Gui = Gui -- this is to force gui to remain in the ENV
|
local Gui = Gui -- this is to force gui to remain in the ENV
|
||||||
|
|
||||||
@@ -39,9 +39,8 @@ function toolbar.draw(player)
|
|||||||
toolbar_frame.clear()
|
toolbar_frame.clear()
|
||||||
if not Gui.data.toolbar then return end
|
if not Gui.data.toolbar then return end
|
||||||
for name,button in pairs(Gui.data.toolbar) do
|
for name,button in pairs(Gui.data.toolbar) do
|
||||||
if is_type(Ranking,'table') and Ranking.meta.rank_count > 0 then
|
if is_type(Role,'table') then
|
||||||
local rank = Ranking.get_rank(player)
|
if Role.allowed(player,name) then
|
||||||
if rank:allowed(name) then
|
|
||||||
button:draw(toolbar_frame)
|
button:draw(toolbar_frame)
|
||||||
end
|
end
|
||||||
else button:draw(toolbar_frame) end
|
else button:draw(toolbar_frame) end
|
||||||
@@ -49,9 +48,9 @@ function toolbar.draw(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function toolbar:on_init()
|
function toolbar:on_init()
|
||||||
if loaded_modules['ExpGamingCore.Ranking'] then Ranking = require('ExpGamingCore.Ranking') end
|
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
|
||||||
end
|
end
|
||||||
|
|
||||||
toolbar.on_rank_change = toolbar.draw
|
toolbar.on_role_change = toolbar.draw
|
||||||
toolbar.on_player_joined_game = toolbar.draw
|
toolbar.on_player_joined_game = toolbar.draw
|
||||||
return toolbar
|
return toolbar
|
||||||
@@ -1,492 +0,0 @@
|
|||||||
--- A full ranking system for factorio.
|
|
||||||
-- @module ExpGamingCore.Ranking
|
|
||||||
-- @alias Ranking
|
|
||||||
-- @author Cooldude2606
|
|
||||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
|
||||||
|
|
||||||
local Game = require('FactorioStdLib.Game')
|
|
||||||
local Color = require('FactorioStdLib.Color')
|
|
||||||
|
|
||||||
local Ranking = {}
|
|
||||||
local module_verbose = false --true|false
|
|
||||||
|
|
||||||
--- Global Table
|
|
||||||
-- @table global
|
|
||||||
-- @field old contains the previous rank a use had before a rank change
|
|
||||||
-- @field preset contains the preset ranks that users will recive apon joining
|
|
||||||
-- @field last_change contains the name of the player who last had there rank chagned
|
|
||||||
local global = global{old={},preset={},last_change=nil}
|
|
||||||
|
|
||||||
--- Called when there is a rank change for a user
|
|
||||||
-- @event on_rank_change
|
|
||||||
-- @field name the rank id
|
|
||||||
-- @field tick the tick which the event was raised on
|
|
||||||
-- @field player_index the player whos rank was changed
|
|
||||||
-- @field by_player_index the player who changed the rank, 0 means server
|
|
||||||
-- @field new_rank the name of the rank that was given
|
|
||||||
-- @field old_rank the name of the rank the player had
|
|
||||||
script.generate_event_name('on_rank_change')
|
|
||||||
|
|
||||||
--- Outputs as a string all the ranks and the loaded order
|
|
||||||
-- @usage Ranking.output_ranks(player) -- prints to player
|
|
||||||
-- @tparam[opt=server] ?player_name|player_index|LuaPlayer player the player that the info will be printed to, nil will print to server
|
|
||||||
-- @todo show inheritance of ranks
|
|
||||||
function Ranking.output_ranks(player)
|
|
||||||
local player = Game.get_player(player) or game.player or nil
|
|
||||||
local function output(rank)
|
|
||||||
local admin = 'No'; if rank.is_root then admin = 'Root' elseif rank.is_admin then admin = 'Yes' end
|
|
||||||
local rtn = string.format('%s) %q %s > Admin: %s Group: %q AFK: %s Time: %s',
|
|
||||||
rank.power,rank.name,rank.tag,admin,rank.group,tostring(rank.base_afk_time),tostring(rank.time))
|
|
||||||
player_return(rtn,rank.colour,player)
|
|
||||||
end
|
|
||||||
local function recur(_rank)
|
|
||||||
for name,rank in pairs(_rank.children) do output(Ranking.ranks[rank]) end
|
|
||||||
for name,rank in pairs(_rank.children) do recur(Ranking.ranks[rank]) end
|
|
||||||
end
|
|
||||||
local root = Ranking.get_rank(Ranking.meta.root)
|
|
||||||
output(root)
|
|
||||||
recur(root)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Contains the location of all the ranks, readonly during runtime
|
|
||||||
-- @table Ranking.ranks
|
|
||||||
Ranking.ranks = setmetatable({},{
|
|
||||||
__metatable=false,
|
|
||||||
__index=table.autokey,
|
|
||||||
__newindex=function(tbl,key,value) if game then error('Can not create new ranks during runtime',2) else rawset(tbl,key,value) end end,
|
|
||||||
__len=function(tbl)
|
|
||||||
local rtn = 0
|
|
||||||
for name,rank in pairs(tbl) do
|
|
||||||
rtn=rtn+1
|
|
||||||
end
|
|
||||||
return rtn
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
--- Contains the location of all the rank groups, readonly during runtime
|
|
||||||
-- @table Ranking.ranks
|
|
||||||
Ranking.groups = setmetatable({},{
|
|
||||||
__metatable=false,
|
|
||||||
__index=table.autokey,
|
|
||||||
__newindex=function(tbl,key,value) if game then error('Can not create new rank groups during runtime',2) else rawset(tbl,key,value) end end,
|
|
||||||
__len=function(tbl)
|
|
||||||
local rtn = 0
|
|
||||||
for name,rank in pairs(tbl) do
|
|
||||||
rtn=rtn+1
|
|
||||||
end
|
|
||||||
return rtn
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
--- Contains some meta data about the ranks
|
|
||||||
-- @table Ranking.meta
|
|
||||||
-- @field default this is the name of the default rank
|
|
||||||
-- @field root this is the name of the root rank
|
|
||||||
-- @field time_ranks a list of all ranks which have a time requirement
|
|
||||||
-- @field time_highest the power of the highest rank that has a time requirement
|
|
||||||
-- @field time_lowest the lowest amount of time required for a time rank
|
|
||||||
Ranking.meta = setmetatable({},{
|
|
||||||
__metatable=false,
|
|
||||||
__call=function(tbl)
|
|
||||||
local count = 0
|
|
||||||
rawset(tbl,'time_ranks',{})
|
|
||||||
for name,rank in pairs(Ranking.ranks) do
|
|
||||||
count=count+1
|
|
||||||
if not rawget(tbl,'default') and rank.is_default then rawset(tbl,'default',rank.name) end
|
|
||||||
if not rawget(tbl,'root') and rank.is_root then rawset(tbl,'root',rank.name) end
|
|
||||||
if rank.time then
|
|
||||||
table.insert(tbl.time_ranks,rank.name)
|
|
||||||
if not rawget(tbl,'time_highest') or rank.power < tbl.time_highest then if rank.power then rawset(tbl,'time_highest',rank.power) end end
|
|
||||||
if not rawget(tbl,'time_lowest') or rank.time < tbl.time_lowest then rawset(tbl,'time_lowest',rank.time) end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
rawset(tbl,'rank_count',count)
|
|
||||||
if not rawget(tbl,'default') then error('No default rank') end
|
|
||||||
if not rawget(tbl,'root') then error('No root rank') end
|
|
||||||
end,
|
|
||||||
__index=function(tbl,key)
|
|
||||||
tbl()
|
|
||||||
return rawget(tbl,key)
|
|
||||||
end,
|
|
||||||
__newindex=function() error('Ranking metadata is read only',2) end
|
|
||||||
})
|
|
||||||
|
|
||||||
--- Used to set the prset ranks that will be given to players
|
|
||||||
-- @usage Ranking._base_preset{name=rank_name,nameTwo=rank_name_two} -- sets player name to have rank rank_name on join
|
|
||||||
-- @tparam table ranks table of player names with the player name as the key and rank name as the value
|
|
||||||
function Ranking._base_preset(ranks)
|
|
||||||
if not is_type(ranks,'table') then error('Ranking._base_preset was not given a table',2) end
|
|
||||||
global.preset = ranks
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns a rank object given a player or rank name
|
|
||||||
-- @usage Ranking.get_rank(game.player) -- returns player's rank
|
|
||||||
-- @usage Ranking.get_rank('admin') -- returns rank by the name of admin
|
|
||||||
-- @tparam ?player|player_index|player_name|rank_name|Ranking._rank|'server'|'root' mixed what rank to get
|
|
||||||
-- @treturn[1] table the rank that is linked to mixed
|
|
||||||
-- @treturn[2] nil there was no rank found
|
|
||||||
function Ranking.get_rank(mixed)
|
|
||||||
if not mixed then return error('Ranking.get_rank recived no paramerters') end
|
|
||||||
local ranks = Ranking.ranks
|
|
||||||
local _return = false
|
|
||||||
if is_type(mixed,'table') then
|
|
||||||
-- is it a player, then get player rank; if it is a rank then return the rank
|
|
||||||
if mixed.index then _return = game.players[mixed.index] and ranks[mixed.permission_group.name] or nil
|
|
||||||
else _return = mixed.group and mixed or nil end
|
|
||||||
else
|
|
||||||
-- if it is a player name/index, then get player rank; if it is a rank name, get that rank; if it is server or root; return root rank; else nil
|
|
||||||
_return = game and game.players[mixed] and ranks[game.players[mixed].permission_group.name]
|
|
||||||
or table.autokey(ranks,mixed) and table.autokey(ranks,mixed)
|
|
||||||
or string.find(mixed,'server') and Ranking.get_rank(Ranking.meta.root)
|
|
||||||
or string.find(mixed,'root') and Ranking.get_rank(Ranking.meta.root)
|
|
||||||
or nil
|
|
||||||
end
|
|
||||||
return _return
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the group object used to sort ranks given group name or rank
|
|
||||||
-- @usage Ranking.get_group(game.player) -- returns player's rank group
|
|
||||||
-- @usage Ranking.get_group('root') -- returns group by name of root
|
|
||||||
-- @tparam ?player|player_index|player_name|rank_name|rank|'server'|'root'|group_name|group mixed what group to get
|
|
||||||
-- @see Ranking.get_rank
|
|
||||||
-- @treturn[1] table the group that is linked to mixed
|
|
||||||
-- @treturn[2] nil there was no rank group found
|
|
||||||
function Ranking.get_group(mixed)
|
|
||||||
if not mixed then return error('Ranking.get_group recived no paramerters') end
|
|
||||||
local groups = Ranking.groups
|
|
||||||
local rank = Ranking.get_rank(mixed)
|
|
||||||
-- if it is a table see if it is a group, return the group; if it is a string, return group by that name; if there is a rank found, return the ranks group
|
|
||||||
return is_type(mixed,'table') and not mixed.__self and mixed.ranks and mixed
|
|
||||||
or is_type(mixed,'string') and table.autokey(groups,mixed)
|
|
||||||
or rank and rank.group
|
|
||||||
or nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Prints to all rank of greater/lower power of the rank given
|
|
||||||
-- @usage Ranking.print('admin','We got a grifer')
|
|
||||||
-- @todo change to use parent and child ranks rather than power
|
|
||||||
-- @tparam ?Ranking._rank|pointerToRank rank_base the rank that acts as the cut off point (rank is always included)
|
|
||||||
-- @param rtn what do you want to return to the players
|
|
||||||
-- @tparam[opt=defines.color.white] defines.color colour the colour that will be used to print
|
|
||||||
-- @tparam[opt=false] boolean below if true print to children rather than parents
|
|
||||||
function Ranking.print(rank_base,rtn,colour,below)
|
|
||||||
local colour = colour or defines.color.white
|
|
||||||
local rank_base = Ranking.get_rank(rank_base)
|
|
||||||
local ranks = Ranking._ranks()
|
|
||||||
if below then
|
|
||||||
for power,rank in pairs(ranks) do
|
|
||||||
if rank_base.power <= power then rank:print(rtn,colour,true) end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
for power,rank in pairs(ranks) do
|
|
||||||
if rank_base.power >= power then rank:print(rtn,colour) end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Gives a user a rank
|
|
||||||
-- @usage Ranking.give_rank(1,'admin')
|
|
||||||
-- @tparam ?LuaPlayer|pointerToPlayer player the player to give the rank to
|
|
||||||
-- @tparam[opt=default] ?Ranking._rank|pointerToRank rank the rank to give to the player
|
|
||||||
-- @tparam[opt='server'] ?LuaPlayer|pointerToPlayer by_player the player who is giving the rank
|
|
||||||
-- @tparam[opt=game.tick] number tick the tick that the rank is being given on, used as pass though
|
|
||||||
function Ranking.give_rank(player,rank,by_player,tick)
|
|
||||||
local print_colour = defines.textcolor.info
|
|
||||||
local tick = tick or game.tick
|
|
||||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or game.player and game.player.name or is_type(by_player,'string') and by_player or 'server'
|
|
||||||
local rank = Ranking.get_rank(rank) or Ranking.get_rank(Ranking.meta.default)
|
|
||||||
local player = Game.get_player(player) or error('No player given to Ranking.give_rank',2)
|
|
||||||
local old_rank = Ranking.get_rank(player) or Ranking.get_rank(Ranking.meta.default)
|
|
||||||
local message = 'ranking.rank-down'
|
|
||||||
-- messaging
|
|
||||||
if old_rank.name == rank.name then return end
|
|
||||||
if rank.power < old_rank.power then message = 'ranking.rank-up' player.play_sound{path='utility/achievement_unlocked'}
|
|
||||||
else player.play_sound{path='utility/game_lost'} end
|
|
||||||
if player.online_time > 60 or by_player_name ~= 'server' then game.print({message,player.name,rank.name,by_player_name},print_colour) end
|
|
||||||
if rank.group ~= 'User' then player_return({'ranking.rank-given',rank.name},print_colour,player) end
|
|
||||||
if player.tag ~= old_rank.tag then player_return({'ranking.tag-reset'},print_colour,player) end
|
|
||||||
-- rank change
|
|
||||||
player.permission_group = game.permissions.get_group(rank.name)
|
|
||||||
player.tag = rank.tag
|
|
||||||
if old_rank.group ~= 'Jail' then global.old[player.index] = old_rank.name end
|
|
||||||
player.admin = rank.is_admin or false
|
|
||||||
player.spectator = rank.is_spectator or false
|
|
||||||
local by_player_index = by_player_name == 'server' and 0 or Game.get_player(by_player_name).index
|
|
||||||
script.raise_event(defines.events.on_rank_change,{
|
|
||||||
name=defines.events.on_rank_change,
|
|
||||||
tick=tick,
|
|
||||||
player_index=player.index,
|
|
||||||
by_player_index=by_player_index,
|
|
||||||
new_rank=rank.name,
|
|
||||||
old_rank=old_rank.name
|
|
||||||
})
|
|
||||||
-- logs to file if rank is chagned after first join
|
|
||||||
if player.online_time > 60 then
|
|
||||||
game.write_file('ranking-change.json',
|
|
||||||
table.json({
|
|
||||||
tick=tick,
|
|
||||||
play_time=player.online_time,
|
|
||||||
player_name=player.name,
|
|
||||||
by_player_name=by_player_name,
|
|
||||||
new_rank=rank.name,
|
|
||||||
old_rank=old_rank.name
|
|
||||||
})..'\n'
|
|
||||||
, true, 0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Revert the last change to a players rank
|
|
||||||
-- @usage Ranking.revert(1) -- reverts the rank of player with index 1
|
|
||||||
-- @tparam ?LuaPlayer|pointerToPlayer player the player to revert the rank of
|
|
||||||
-- @param[opt=nil] by_player the player who is doing the revert
|
|
||||||
function Ranking.revert(player,by_player)
|
|
||||||
local player = Game.get_player(player)
|
|
||||||
Ranking.give_rank(player,global.old[player.index],by_player)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Given that the player has a rank in the preset table it is given; also will attempt to promote players if a time requirement is met
|
|
||||||
-- @usage Ranking.find_preset(1) -- attemps to find the preset for player with index 1
|
|
||||||
-- @tparam ?LuaPlayer|pointerToPlayer player the player to test for an auto rank
|
|
||||||
-- @tparam[opt=nil] number tick the tick it happens on
|
|
||||||
function Ranking.find_preset(player,tick)
|
|
||||||
local presets = global.preset
|
|
||||||
local meta_data = Ranking.meta
|
|
||||||
local default = Ranking.get_rank(meta_data.default)
|
|
||||||
local player = Game.get_player(player)
|
|
||||||
local current_rank = Ranking.get_rank(player) or {power=-1,group='not jail'}
|
|
||||||
local ranks = {default}
|
|
||||||
-- users in rank group jail are ingroned
|
|
||||||
if current_rank.group == 'Jail' then return end
|
|
||||||
-- looks in preset table for player name
|
|
||||||
if presets[string.lower(player.name)] then
|
|
||||||
local rank = Ranking.get_rank(presets[string.lower(player.name)])
|
|
||||||
table.insert(ranks,rank)
|
|
||||||
end
|
|
||||||
-- if the player mets check requirements then play time is checked
|
|
||||||
if current_rank.power > meta_data.time_highest and tick_to_min(player.online_time) > meta_data.time_lowest then
|
|
||||||
for _,rank_name in pairs(meta_data.time_ranks) do
|
|
||||||
local rank = Ranking.get_rank(rank_name)
|
|
||||||
if tick_to_min(player.online_time) > rank.time then
|
|
||||||
table.insert(ranks,rank)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- if the new rank is closer to root then it is the new rank
|
|
||||||
local _rank = current_rank
|
|
||||||
for _,rank in pairs(ranks) do
|
|
||||||
if rank.power < _rank.power or _rank.power == -1 then _rank = rank end
|
|
||||||
end
|
|
||||||
-- this new rank is given to the player
|
|
||||||
if _rank.name == current_rank.name then return end
|
|
||||||
if _rank.name == default.name then
|
|
||||||
player.tag = _rank.tag
|
|
||||||
player.permission_group = game.permissions.get_group(_rank.name)
|
|
||||||
else
|
|
||||||
Ranking.give_rank(player,_rank,nil,tick)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- The class for the ranks
|
|
||||||
-- @type Rank
|
|
||||||
-- @alias Ranking._rank
|
|
||||||
-- @field name the name that is given to the rank, must be unique
|
|
||||||
-- @field short_hand the shorter way of displaying this rank, can be used by other modules
|
|
||||||
-- @field tag the tag that player in this rank will be given
|
|
||||||
-- @field colour the colour that modules should display this rank as in guis
|
|
||||||
-- @field parent the name of the rank that permissions are inherited from, allow comes from children, disallow given to children
|
|
||||||
-- @field base_afk_time a relative number that the rank should be given that other modules can use for relitive importance
|
|
||||||
-- @field time the time that is requied for this rank to be given, can be nil for manal only
|
|
||||||
-- @field allow a list of permissions that this rank is allowed
|
|
||||||
-- @field disallow a list of acctions that is blocked by the ingame permission system
|
|
||||||
-- @field is_default will be given to all players if no other rank is set for them
|
|
||||||
-- @field is_admin will promote player to ingame admin if flag set (will auto demote if not set)
|
|
||||||
-- @field is_spectator will auto set the spectator option for the player (will cleat option if not set)
|
|
||||||
-- @field is_root rank is always allowed all action, when present in root group will become the root child that all ranks are indexed from
|
|
||||||
Ranking._rank = {}
|
|
||||||
|
|
||||||
--- Is this rank allowed to open this gui or use this command etc.
|
|
||||||
-- @usage rank:allowed('interface') -- does the rank have permision for 'interface'
|
|
||||||
-- @tparam teh action to test for
|
|
||||||
-- @treturn boolean is it allowed
|
|
||||||
function Ranking._rank:allowed(action)
|
|
||||||
return self.allow[action] or self.is_root or false
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Get all the players in this rank
|
|
||||||
-- @usage rank:get_players()
|
|
||||||
-- @tparam[opt=false] boolean online get only online players
|
|
||||||
-- @treturn table a table of all players in this rank
|
|
||||||
function Ranking._rank:get_players(online)
|
|
||||||
local players = game.permissions.get_group(self.name).players
|
|
||||||
local _return = {}
|
|
||||||
if online then
|
|
||||||
for _,player in pairs(players) do if player.connected then table.insert(_return,player) end end
|
|
||||||
else _return = players end
|
|
||||||
return _return
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Print a message to all players of this rank
|
|
||||||
-- @usage rank:print('foo') -- prints to all members of this rank
|
|
||||||
-- @param rtn any value you want to return
|
|
||||||
-- @tparam[opt=defines.color.white] define.color colour the colour that will be used to print
|
|
||||||
-- @tparam[opt=false] boolean show_default weather to use the default rank name for the print, used as a pass though
|
|
||||||
function Ranking._rank:print(rtn,colour,show_default)
|
|
||||||
local colour = colour or defines.color.white
|
|
||||||
local default = Ranking.get_rank(Ranking.meta.default)
|
|
||||||
for _,player in pairs(self:get_players(true)) do
|
|
||||||
if self.name == default.name or show_default then player_return({'ranking.all-rank-print',rtn},colour,player)
|
|
||||||
else player_return({'ranking.rank-print',self.name,rtn},colour,player) end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Allows for a clean way to edit rank objects
|
|
||||||
-- @usage rank:edit('allow',{'interface'}) -- allows this rank to use 'interface'
|
|
||||||
-- @tparam string key the key to edit, often allow or disallow
|
|
||||||
-- @param value the new value to be set
|
|
||||||
function Ranking._rank:edit(key,value)
|
|
||||||
if game then return end
|
|
||||||
verbose('Edited Rank: '..self.group..'/'..self.name..'/'..key)
|
|
||||||
if key == 'disallow' then self.disallow = table.merge(self.disallow,value,true)
|
|
||||||
elseif key == 'allow' then self.allow = table.merge(self.allow,value)
|
|
||||||
else self[key] = value end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- The class for the rank groups, the way to allow modules to idex a group that is always present, ranks will always look to there group as a parent
|
|
||||||
-- @type Group
|
|
||||||
-- @alias Ranking._group
|
|
||||||
-- @field name the name that is given to the rank group, must be unique
|
|
||||||
-- @field parent the name of the group that permissions are inherited from
|
|
||||||
-- @field allow a list of permissions that this rank is allowed
|
|
||||||
-- @field disallow a list of acctions that is blocked by the ingame permission system
|
|
||||||
Ranking._group = {}
|
|
||||||
|
|
||||||
--- Creates a new group
|
|
||||||
-- @usage Ranking._group:create{name='root'} -- returns group with name root
|
|
||||||
-- @tparam table obj the fields for this object
|
|
||||||
-- @treturn Ranking._group returns the object to allow chaining
|
|
||||||
function Ranking._group:create(obj)
|
|
||||||
if game then return end
|
|
||||||
if not is_type(obj.name,'string') then error('Group creationg is invalid',2) end
|
|
||||||
verbose('Created Group: '..obj.name)
|
|
||||||
setmetatable(obj,{__index=Ranking._group})
|
|
||||||
obj.ranks = {}
|
|
||||||
obj.allow = obj.allow or {}
|
|
||||||
obj.disallow = obj.disallow or {}
|
|
||||||
Ranking.groups[obj.name] = obj
|
|
||||||
return obj
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Creats a new rank with this group as its group
|
|
||||||
-- @usage group:add_rank{name='root'} -- returns self
|
|
||||||
-- @tparam table obj the fields for this object
|
|
||||||
-- @treturn Ranking._group returns the object to allow chaining
|
|
||||||
function Ranking._group:add_rank(obj)
|
|
||||||
if game then return end
|
|
||||||
if not is_type(obj.name,'string') or
|
|
||||||
not is_type(obj.short_hand,'string') or
|
|
||||||
not is_type(obj.tag,'string') or
|
|
||||||
not is_type(obj.colour,'table') then error('Rank creation is invalid',2) end
|
|
||||||
verbose('Created Rank: '..obj.name)
|
|
||||||
setmetatable(obj,{__index=Ranking._rank})
|
|
||||||
obj.group = self.name
|
|
||||||
obj.children = {}
|
|
||||||
obj.allow = obj.allow or {}
|
|
||||||
obj.disallow = obj.disallow or {}
|
|
||||||
table.insert(self.ranks,obj.name)
|
|
||||||
Ranking.ranks[obj.name] = obj
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Allows for a clean way to edit rank group objects
|
|
||||||
-- @usage group:edit('allow',{'interface'}) -- allows this rank to use 'interface'
|
|
||||||
-- @tparam string key the key to edit, often allow or disallow
|
|
||||||
-- @param value the new value to be set
|
|
||||||
function Ranking._group:edit(key,value)
|
|
||||||
if game then return end
|
|
||||||
verbose('Edited Group: '..self.name..'/'..key)
|
|
||||||
if key == 'disallow' then self.disallow = table.merge(self.disallow,value,true)
|
|
||||||
elseif key == 'allow' then self.allow = table.merge(self.allow,value)
|
|
||||||
else self[key] = value end
|
|
||||||
end
|
|
||||||
|
|
||||||
script.on_event('on_player_joined_game',function(event)
|
|
||||||
Ranking.find_preset(event.player_index)
|
|
||||||
end)
|
|
||||||
|
|
||||||
script.on_event('on_init',function(event)
|
|
||||||
for name,rank in pairs(Ranking.ranks) do
|
|
||||||
local perm = game.permissions.create_group(name)
|
|
||||||
for _,toRemove in pairs(rank.disallow) do
|
|
||||||
perm.set_allows_action(defines.input_action[toRemove],false)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
script.on_event('on_tick',function(event)
|
|
||||||
if (((event.tick+10)/(3600*game.speed))+(15/2))% 15 == 0 then
|
|
||||||
-- this is the system to auto rank players
|
|
||||||
for _,player in pairs(game.connected_players) do
|
|
||||||
Ranking.find_preset(player,tick)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
verbose('Loading rank core...')
|
|
||||||
require(module_path..'/src/core',{Ranking=Ranking})
|
|
||||||
verbose('Loading rank configs...')
|
|
||||||
require(module_path..'/src/config',{Ranking=Ranking})
|
|
||||||
|
|
||||||
function Ranking:on_init()
|
|
||||||
if loaded_modules['ExpGamingCore.Server'] then verbose('ExpGamingCore.Server is installed; Loading server src') require(module_path..'/src/server',{Ranking=Ranking}) end
|
|
||||||
if loaded_modules['ExpGamingCore.Command'] then verbose('ExpGamingCore.Server is installed; Loading commands src') require(module_path..'/src/commands',{Ranking=Ranking}) end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Ranking:on_post()
|
|
||||||
-- other modules can creat ranks during init and this will then set up the meta data
|
|
||||||
-- sets up the power system, the lower the power the closer to root, root is 0
|
|
||||||
-- there must be a rank with is_root flag set and one rank with is_default flag set, if multiple found then first found is used
|
|
||||||
local root = Ranking.get_rank(Ranking.meta.root)
|
|
||||||
root:edit('power',0)
|
|
||||||
-- asigning of children
|
|
||||||
verbose('Creating Rank Tree')
|
|
||||||
for name,rank in pairs(Ranking.ranks) do
|
|
||||||
if rank ~= root then
|
|
||||||
if not rank.parent then error('Rank has no parent: "'..name..'"') end
|
|
||||||
if not Ranking.ranks[rank.parent] then error('Invalid parent rank: "'..rank.parent..'"') end
|
|
||||||
table.insert(Ranking.ranks[rank.parent].children,name)
|
|
||||||
Ranking.ranks[rank.parent]:edit('allow',rank.allow)
|
|
||||||
rank:edit('disallow',Ranking.ranks[rank.parent].disallow)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- asigning of powers
|
|
||||||
-- @todo need a better system for non liner rank trees
|
|
||||||
verbose('Assigning Rank Powers')
|
|
||||||
local power = 1
|
|
||||||
local function set_powers(rank)
|
|
||||||
for _,name in pairs(rank.children) do
|
|
||||||
Ranking.ranks[name]:edit('power',power)
|
|
||||||
power=power+1
|
|
||||||
end
|
|
||||||
for _,name in pairs(rank.children) do set_powers(Ranking.ranks[name]) end
|
|
||||||
end
|
|
||||||
set_powers(root)
|
|
||||||
-- asigning group meta data
|
|
||||||
verbose('Creating Rank-Group Relationship')
|
|
||||||
for name,group in pairs(Ranking.groups) do
|
|
||||||
if name ~= 'Root' then
|
|
||||||
if not group.parent then error('Group has no parent: "'..name..'"') end
|
|
||||||
if not Ranking.groups[group.parent] then error('Invalid parent rank: "'..group.parent..'"') end
|
|
||||||
Ranking.groups[group.parent]:edit('allow',group.allow)
|
|
||||||
group:edit('disallow',Ranking.groups[group.parent].disallow)
|
|
||||||
end
|
|
||||||
for _,name in pairs(group.ranks) do
|
|
||||||
local rank = Ranking.ranks[name]
|
|
||||||
rank:edit('disallow',group.disallow)
|
|
||||||
rank:edit('allow',group.allow)
|
|
||||||
if not group.highest or Ranking.ranks[group.highest].power > rank.power then group.highest = rank.name end
|
|
||||||
if not group.lowest or Ranking.ranks[group.highest].power < rank.power then group.lowest = rank.name end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return Ranking
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
[ranking]
|
|
||||||
all-rank-print=[Alle]: __1__
|
|
||||||
rank-print=[__1__]: __2__
|
|
||||||
rank-up=__1__ wurde befördert zu __2__ von __3__
|
|
||||||
rank-down=__1__ wurde degradiert zu __2__ von __3__
|
|
||||||
rank-given=Dir wurde der Rang __1__ zugeteilt!
|
|
||||||
tag-reset=Dein Spitzname wurde aufgrund eines Rangwechsels zurückgesetzt.
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
[ranking]
|
|
||||||
all-rank-print=[Everyone]: __1__
|
|
||||||
rank-print=[__1__]: __2__
|
|
||||||
rank-up=__1__ was promoted to __2__ by __3__
|
|
||||||
rank-down=__1__ was demoted to __2__ by __3__
|
|
||||||
rank-given=You have been given the __1__ Rank!
|
|
||||||
tag-reset=Your Tag was reset due to a Rank change
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
[ranking]
|
|
||||||
all-rank-print=[Everyone]: __1__
|
|
||||||
rank-print=[__1__]: __2__
|
|
||||||
rank-up=__1__ was promoted to __2__ by __3__
|
|
||||||
rank-down=__1__ was demoted to __2__ by __3__
|
|
||||||
rank-given=You have been given the __1__ Rank!
|
|
||||||
tag-reset=Your Tag was reset due to a Rank change
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
[ranking]
|
|
||||||
all-rank-print=[Everyone]: __1__
|
|
||||||
rank-print=[__1__]: __2__
|
|
||||||
rank-up=__1__ is gepromoot naar __2__ door __3__
|
|
||||||
rank-down=__1__ is gedegradeerd naar __2__ door __3__
|
|
||||||
rank-given=Je rank is veranderd naar __1__
|
|
||||||
tag-reset=Je tag is gereset door een wijziging in je rank.
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
[ranking]
|
|
||||||
all-rank-print=[Everyone]: __1__
|
|
||||||
rank-print=[__1__]: __2__
|
|
||||||
rank-up=__1__ blev befordrad till __2__ av __3__
|
|
||||||
rank-down=__1__ blev degraderad till __2__ av __3__
|
|
||||||
rank-given=Du har fått __1__ Rang!
|
|
||||||
tag-reset=Din tag blev återställd på grund av rangförändrning.
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "Ranking",
|
|
||||||
"version": "4.0.0",
|
|
||||||
"type": "Submodule",
|
|
||||||
"description": "A full ranking system for factorio.",
|
|
||||||
"location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Ranking_4.0.0.zip",
|
|
||||||
"keywords": [
|
|
||||||
"Library",
|
|
||||||
"Lib",
|
|
||||||
"ExpGaming",
|
|
||||||
"Core",
|
|
||||||
"Ranking",
|
|
||||||
"Ranks",
|
|
||||||
"Permissions",
|
|
||||||
"Roles"
|
|
||||||
],
|
|
||||||
"dependencies": {
|
|
||||||
"ExpGamingLib": "^4.0.0",
|
|
||||||
"FactorioStdLib.Color": "^0.8.0",
|
|
||||||
"FactorioStdLib.Table": "^0.8.0",
|
|
||||||
"FactorioStdLib.Game": "^0.8.0",
|
|
||||||
"ExpGamingCore.Server": "?^4.0.0"
|
|
||||||
},
|
|
||||||
"collection": "ExpGamingCore_4.0.0"
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
local Ranking = Ranking
|
|
||||||
|
|
||||||
commands.add_validation('player-rank',function(value,event)
|
|
||||||
local player,err = commands.validate['player'](value)
|
|
||||||
return err and commands.error(err)
|
|
||||||
or Ranking.get_rank(player).power > Ranking.get_rank(event).power and player
|
|
||||||
or commands.error{'commands.error-player-rank'}
|
|
||||||
end)
|
|
||||||
|
|
||||||
commands.add_validation('player-rank-online',function(value,event)
|
|
||||||
local player,err = commands.validate['player-online'](value)
|
|
||||||
if err then return commands.error(err) end
|
|
||||||
local player,err = commands.validate['player-rank'](player)
|
|
||||||
if err then return commands.error(err) end
|
|
||||||
return player
|
|
||||||
end)
|
|
||||||
|
|
||||||
commands.add_validation('player-rank-alive',function(value,event)
|
|
||||||
local player,err = commands.validate['player-alive'](value)
|
|
||||||
if err then return commands.error(err) end
|
|
||||||
local player,err = commands.validate['player-rank'](player)
|
|
||||||
if err then return commands.error(err) end
|
|
||||||
return player
|
|
||||||
end)
|
|
||||||
|
|
||||||
commands.add_middleware(function(player_name,command_name,event)
|
|
||||||
return Ranking.get_rank(player_name):allowed(command_name)
|
|
||||||
end)
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
--[[
|
|
||||||
How to use groups:
|
|
||||||
name The name that you can use to reference it.
|
|
||||||
disallow If present then all ranks in this group will have this added to their disallow.
|
|
||||||
allow If present then all ranks in this group will have this added to their allow.
|
|
||||||
highest Assigned by the script to show the highest rank in this group.
|
|
||||||
lowest Assigned by the script to show the lowest rank in this group.
|
|
||||||
How to add ranks:
|
|
||||||
Name What will be used in the scripts and is often the best choice for display in text.
|
|
||||||
short_hand What can be used when short on space but the rank still need to be displayed.
|
|
||||||
tag The tag the player will gain when moved to the rank, it can be nil.
|
|
||||||
time Used for auto-rank feature where you are moved to the rank after a certain play time in minutes.
|
|
||||||
colour The RGB value that can be used to emphasise GUI elements based on rank.
|
|
||||||
power Assigned by the script based on their index in ranks, you can insert new ranks between current ones.
|
|
||||||
group Assigned by the script to show the group this rank is in.
|
|
||||||
disallow A list containing input actions that the user can not perform.
|
|
||||||
allow A list of custom commands and effects that that rank can use, all defined in the scripts.
|
|
||||||
|
|
||||||
For allow, add the allow as the key and the value as true
|
|
||||||
Example: test for 'server-interface' => allow['server-interface'] = true
|
|
||||||
|
|
||||||
For disallow, add to the list the end part of the input action
|
|
||||||
Example: defines.input_action.drop_item -> 'drop_item'
|
|
||||||
http://lua-api.factorio.com/latest/defines.html#defines.input_action
|
|
||||||
--]]
|
|
||||||
|
|
||||||
local groups = Ranking.groups
|
|
||||||
local ranks = Ranking.ranks
|
|
||||||
|
|
||||||
groups['Root']:add_rank{
|
|
||||||
name='Owner',
|
|
||||||
short_hand='Owner',
|
|
||||||
tag='[Owner]',
|
|
||||||
parent='Root',
|
|
||||||
time=nil,
|
|
||||||
colour={r=170,g=0,b=0},
|
|
||||||
is_admin = true,
|
|
||||||
is_spectator=true,
|
|
||||||
base_afk_time=false
|
|
||||||
}
|
|
||||||
groups['Root']:add_rank{
|
|
||||||
name='Community Manager',
|
|
||||||
short_hand='Com Mngr',
|
|
||||||
tag='[Com Mngr]',
|
|
||||||
parent='Root',
|
|
||||||
colour={r=150,g=68,b=161},
|
|
||||||
is_admin = true,
|
|
||||||
is_spectator=true,
|
|
||||||
base_afk_time=false
|
|
||||||
}
|
|
||||||
groups['Root']:add_rank{
|
|
||||||
name='Developer',
|
|
||||||
short_hand='Dev',
|
|
||||||
tag='[Dev]',
|
|
||||||
parent='Root',
|
|
||||||
colour={r=179,g=125,b=46},
|
|
||||||
is_admin = true,
|
|
||||||
is_spectator=true,
|
|
||||||
base_afk_time=false
|
|
||||||
}
|
|
||||||
|
|
||||||
ranks['Admin']:edit('parent','Developer')
|
|
||||||
groups['Admin']:add_rank{
|
|
||||||
name='Mod',
|
|
||||||
short_hand='Mod',
|
|
||||||
tag='[Mod]',
|
|
||||||
parent='Admin',
|
|
||||||
colour={r=0,g=170,b=0},
|
|
||||||
disallow={
|
|
||||||
'server_command'
|
|
||||||
},
|
|
||||||
is_admin = true,
|
|
||||||
is_spectator=true,
|
|
||||||
base_afk_time=false
|
|
||||||
}
|
|
||||||
|
|
||||||
groups['User']:add_rank{
|
|
||||||
name='Donator',
|
|
||||||
short_hand='P2W',
|
|
||||||
tag='[P2W]',
|
|
||||||
parent='Mod',
|
|
||||||
colour={r=233,g=63,b=233},
|
|
||||||
is_spectator=true,
|
|
||||||
base_afk_time=120
|
|
||||||
}
|
|
||||||
groups['User']:add_rank{
|
|
||||||
name='Veteran',
|
|
||||||
short_hand='Vet',
|
|
||||||
tag='[Veteran]',
|
|
||||||
parent='Donator',
|
|
||||||
time=600,
|
|
||||||
colour={r=140,g=120,b=200},
|
|
||||||
base_afk_time=60
|
|
||||||
}
|
|
||||||
ranks['Member']:edit('parent','Veteran')
|
|
||||||
groups['User']:add_rank{
|
|
||||||
name='Regular',
|
|
||||||
short_hand='Reg',
|
|
||||||
tag='[Regular]',
|
|
||||||
parent='Member',
|
|
||||||
time=180,
|
|
||||||
colour={r=24,g=172,b=188},
|
|
||||||
base_afk_time=30
|
|
||||||
}
|
|
||||||
ranks['Guest']:edit('parent','Regular')
|
|
||||||
|
|
||||||
Ranking._base_preset{
|
|
||||||
['badgamernl']='Owner',
|
|
||||||
['arty714']='Community Manager',
|
|
||||||
['cooldude2606']='Developer',
|
|
||||||
['mark9064']='Admin'
|
|
||||||
}
|
|
||||||
@@ -1,149 +0,0 @@
|
|||||||
--[[
|
|
||||||
How to use groups:
|
|
||||||
name the name that you can use to refence it.
|
|
||||||
disallow if present then all ranks in this group will have this added to their disallow.
|
|
||||||
allow if present then all ranks in this group will have this added to their allow.
|
|
||||||
highest is asigned by the script to show the highest rank in this group.
|
|
||||||
lowest is asigned by the script to show the lowest rank in this group.
|
|
||||||
How to add ranks:
|
|
||||||
Name is what will be used in the scripts and is often the best choice for display in text.
|
|
||||||
short_hand is what can be used when short on space but the rank still need to be displayed.
|
|
||||||
tag is the tag the player will gain when moved to the rank, it can be nil.
|
|
||||||
time is used for auto-rank feature where you are moved to the rank after a certain play time in minutes.
|
|
||||||
colour is the RGB value that can be used to emphasise GUI elements based on rank.
|
|
||||||
power is asigned by the script based on their index in ranks, you can insert new ranks between current ones, lower is better
|
|
||||||
group is asigned by the script to show the group this rank is in
|
|
||||||
disallow is a list containing input actions that the user can not perform.
|
|
||||||
allow is a list of custom commands and effects that that rank can use, all defined in the sctips.
|
|
||||||
|
|
||||||
For allow, add the allow as the key and the value as true
|
|
||||||
Example: test for 'server-interface' => allow['server-interface'] = true
|
|
||||||
|
|
||||||
For disallow, add to the list the end part of the input action
|
|
||||||
Example: defines.input_action.drop_item -> 'drop_item'
|
|
||||||
http://lua-api.factorio.com/latest/defines.html#defines.input_action
|
|
||||||
--]]
|
|
||||||
|
|
||||||
-- If you wish to add more groups please use src/config or add during your own module
|
|
||||||
-- If you wish to add to these rank groups use src/config or add during your own module
|
|
||||||
-- But groups do not inherite from each other
|
|
||||||
-- DO NOT REMOVE ANY OF THESE GROUPS!!!
|
|
||||||
|
|
||||||
local root = Ranking._group:create{
|
|
||||||
name='Root',
|
|
||||||
allow={
|
|
||||||
['interface'] = true
|
|
||||||
},
|
|
||||||
disallow={}
|
|
||||||
}
|
|
||||||
local admin = Ranking._group:create{
|
|
||||||
name='Admin',
|
|
||||||
parent='Root',
|
|
||||||
allow={},
|
|
||||||
disallow={
|
|
||||||
'edit_permission_group',
|
|
||||||
'delete_permission_group',
|
|
||||||
'add_permission_group'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
local user = Ranking._group:create{
|
|
||||||
name='User',
|
|
||||||
parent='Admin',
|
|
||||||
allow={},
|
|
||||||
disallow={}
|
|
||||||
}
|
|
||||||
local jail = Ranking._group:create{
|
|
||||||
name='Jail',
|
|
||||||
parent='User',
|
|
||||||
allow={},
|
|
||||||
disallow={
|
|
||||||
'open_character_gui',
|
|
||||||
'begin_mining',
|
|
||||||
'start_walking',
|
|
||||||
'player_leave_game',
|
|
||||||
'open_blueprint_library_gui',
|
|
||||||
'build_item',
|
|
||||||
'use_item',
|
|
||||||
'select_item',
|
|
||||||
'rotate_entity',
|
|
||||||
'open_train_gui',
|
|
||||||
'open_train_station_gui',
|
|
||||||
'open_gui',
|
|
||||||
'open_item',
|
|
||||||
'deconstruct',
|
|
||||||
'build_rail',
|
|
||||||
'cancel_research',
|
|
||||||
'start_research',
|
|
||||||
'set_train_stopped',
|
|
||||||
'select_gun',
|
|
||||||
'open_technology_gui',
|
|
||||||
'open_trains_gui',
|
|
||||||
'edit_custom_tag',
|
|
||||||
'craft',
|
|
||||||
'setup_assembling_machine',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-- If you wish to add more ranks please use src/config or add during your own module
|
|
||||||
-- If you wish to add to these rank use src/config or add during your own module
|
|
||||||
root:add_rank{
|
|
||||||
name='Root',
|
|
||||||
short_hand='Root',
|
|
||||||
tag='[Root]',
|
|
||||||
colour={r=255,b=255,g=255},
|
|
||||||
is_root=true,
|
|
||||||
is_admin=true,
|
|
||||||
is_spectator=true,
|
|
||||||
base_afk_time=false
|
|
||||||
}
|
|
||||||
|
|
||||||
admin:add_rank{
|
|
||||||
name='Admin',
|
|
||||||
short_hand='Admin',
|
|
||||||
tag='[Admin]',
|
|
||||||
parent='Root',
|
|
||||||
colour={r=233,g=63,b=233},
|
|
||||||
is_admin=true,
|
|
||||||
is_spectator=true,
|
|
||||||
base_afk_time=false
|
|
||||||
}
|
|
||||||
|
|
||||||
user:add_rank{
|
|
||||||
name='Member',
|
|
||||||
short_hand='Mem',
|
|
||||||
tag='[Member]',
|
|
||||||
parent='Admin',
|
|
||||||
colour={r=24,g=172,b=188},
|
|
||||||
disallow={
|
|
||||||
'set_auto_launch_rocket',
|
|
||||||
'change_programmable_speaker_alert_parameters',
|
|
||||||
'drop_item'
|
|
||||||
},
|
|
||||||
base_afk_time=60
|
|
||||||
}
|
|
||||||
user:add_rank{
|
|
||||||
name='Guest',
|
|
||||||
short_hand='',
|
|
||||||
tag='',
|
|
||||||
parent='Member',
|
|
||||||
colour={r=255,g=159,b=27},
|
|
||||||
is_default=true,
|
|
||||||
disallow={
|
|
||||||
'build_terrain',
|
|
||||||
'remove_cables',
|
|
||||||
'launch_rocket',
|
|
||||||
'reset_assembling_machine',
|
|
||||||
'cancel_research'
|
|
||||||
},
|
|
||||||
base_afk_time=10
|
|
||||||
}
|
|
||||||
|
|
||||||
jail:add_rank{
|
|
||||||
name='Jail',
|
|
||||||
short_hand='Jail',
|
|
||||||
tag='[Jail]',
|
|
||||||
parent='Guest',
|
|
||||||
colour={r=50,g=50,b=50},
|
|
||||||
disallow={},
|
|
||||||
base_afk_time=false
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
--- A full ranking system for factorio.
|
|
||||||
-- @submodule ExpGamingCore.Ranking
|
|
||||||
-- @alias Ranking
|
|
||||||
-- @author Cooldude2606
|
|
||||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
|
||||||
|
|
||||||
--- This file will be loaded when ExpGamingCore.Server is present
|
|
||||||
-- @function _comment
|
|
||||||
|
|
||||||
local Game = require('FactorioStdLib.Game')
|
|
||||||
local Color = require('FactorioStdLib.Color')
|
|
||||||
local Server = require('ExpGamingCore.Server')
|
|
||||||
local Ranking = Ranking
|
|
||||||
|
|
||||||
--- Print a message to all players of this rank
|
|
||||||
-- @usage rank:print('foo') -- prints to all members of this rank
|
|
||||||
-- @param rtn any value you want to return
|
|
||||||
-- @tparam[opt=defines.color.white] define.color colour the colour that will be used to print
|
|
||||||
-- @tparam[opt=false] boolean show_default weather to use the default rank name for the print, used as a pass though
|
|
||||||
function Ranking._rank:print(rtn,colour,show_default)
|
|
||||||
local colour = colour or defines.color.white
|
|
||||||
local default = Ranking.get_rank(Ranking.meta.default)
|
|
||||||
Server.new_thread{
|
|
||||||
data={rank=self,rtn=rtn,default=default.name,all=show_default}
|
|
||||||
}:on_event('resolve',function(thread)
|
|
||||||
return thread.data.rank:get_players(true)
|
|
||||||
end):on_event('success',function(thread,players)
|
|
||||||
for _,player in pairs(players) do
|
|
||||||
if thread.data.rank.name == thread.data.default or thread.data.all then
|
|
||||||
player_return({'ranking.all-rank-print',thread.data.rtn},colour,player)
|
|
||||||
else
|
|
||||||
player_return({'ranking.rank-print',thread.data.rank.name,thread.data.rtn},colour,player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end):queue()
|
|
||||||
end
|
|
||||||
|
|
||||||
script.on_event('on_tick',function(event)
|
|
||||||
if (((event.tick+10)/(3600*game.speed))+(15/2))% 15 == 0 then
|
|
||||||
Server.new_thread{
|
|
||||||
data={players=game.connected_players}
|
|
||||||
}:on_event('tick',function(thread)
|
|
||||||
if #thread.data.players == 0 then thread:close() return end
|
|
||||||
local player = table.remove(thread.data.players,1)
|
|
||||||
Ranking.find_preset(player,tick)
|
|
||||||
end):open()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
Server.add_to_interface('rank',function() return Ranking.get_rank(game.player) end)
|
|
||||||
Server.add_module_to_interface('Ranking','ExpGamingCore.Ranking')
|
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
Role.add_flag('is_default') -- this must be included in atleast one role
|
Role.add_flag('is_default') -- this must be included in atleast one role
|
||||||
Role.add_flag('is_root',function(player,state) player.character.destructible = not state end) -- not required but setting true will allow everythin for that role
|
Role.add_flag('is_root',function(player,state) player.character.destructible = not state end) -- not required but setting true will allow everythin for that role
|
||||||
|
Role.add_flag('is_antiroot',function(player,state) player.character.destructible = not state end) -- not required but setting true will disallow everythin for that role
|
||||||
Role.add_flag('is_admin',function(player,state) player.admin = state end) -- highly recomented but not required
|
Role.add_flag('is_admin',function(player,state) player.admin = state end) -- highly recomented but not required
|
||||||
Role.add_flag('is_spectator',function(player,state) player.spectator = state end)
|
Role.add_flag('is_spectator',function(player,state) player.spectator = state end)
|
||||||
Role.add_flag('is_jail',function(player,state) player.character.active = not state end)
|
Role.add_flag('is_jail',function(player,state) player.character.active = not state end)
|
||||||
Role.add_flag('is_donator')
|
Role.add_flag('is_donator')
|
||||||
Role.add_flag('is_timed')
|
Role.add_flag('is_timed')
|
||||||
|
Role.add_flag('is_varified')
|
||||||
|
Role.add_flag('not_reportable')
|
||||||
|
|
||||||
-- Root
|
-- Root
|
||||||
Role{
|
Role{
|
||||||
@@ -16,6 +19,7 @@ Role{
|
|||||||
is_root=true,
|
is_root=true,
|
||||||
is_admin=true,
|
is_admin=true,
|
||||||
is_spectator=true,
|
is_spectator=true,
|
||||||
|
not_reportable=true,
|
||||||
allow={}
|
allow={}
|
||||||
}
|
}
|
||||||
Role{
|
Role{
|
||||||
@@ -53,6 +57,7 @@ Role{
|
|||||||
colour={r=233,g=63,b=233},
|
colour={r=233,g=63,b=233},
|
||||||
is_admin=true,
|
is_admin=true,
|
||||||
is_spectator=true,
|
is_spectator=true,
|
||||||
|
not_reportable=true,
|
||||||
allow={
|
allow={
|
||||||
['game-settings']=true,
|
['game-settings']=true,
|
||||||
['always-warp']=true,
|
['always-warp']=true,
|
||||||
@@ -67,6 +72,7 @@ Role{
|
|||||||
colour={r=0,g=170,b=0},
|
colour={r=0,g=170,b=0},
|
||||||
is_admin=true,
|
is_admin=true,
|
||||||
is_spectator=true,
|
is_spectator=true,
|
||||||
|
not_reportable=true,
|
||||||
allow={
|
allow={
|
||||||
['set-home']=true,
|
['set-home']=true,
|
||||||
['home']=true,
|
['home']=true,
|
||||||
@@ -82,6 +88,7 @@ Role{
|
|||||||
group='Admin',
|
group='Admin',
|
||||||
colour={r=0,g=196,b=137},
|
colour={r=0,g=196,b=137},
|
||||||
is_spectator=true,
|
is_spectator=true,
|
||||||
|
not_reportable=true,
|
||||||
allow={
|
allow={
|
||||||
['go-to']=true,
|
['go-to']=true,
|
||||||
['bring']=true,
|
['bring']=true,
|
||||||
@@ -153,6 +160,7 @@ Role{
|
|||||||
group='HiMember',
|
group='HiMember',
|
||||||
colour={r=140,g=120,b=200},
|
colour={r=140,g=120,b=200},
|
||||||
is_timed=true,
|
is_timed=true,
|
||||||
|
is_varified=true,
|
||||||
time=600, -- 10 hours
|
time=600, -- 10 hours
|
||||||
allow={
|
allow={
|
||||||
['global-chat']=true,
|
['global-chat']=true,
|
||||||
@@ -169,6 +177,7 @@ Role{
|
|||||||
tag='[Member]',
|
tag='[Member]',
|
||||||
group='Member',
|
group='Member',
|
||||||
colour={r=24,g=172,b=188},
|
colour={r=24,g=172,b=188},
|
||||||
|
is_varified=true,
|
||||||
allow={
|
allow={
|
||||||
['edit-tasklist']=true,
|
['edit-tasklist']=true,
|
||||||
['make-warp']=true,
|
['make-warp']=true,
|
||||||
@@ -223,6 +232,7 @@ Role{
|
|||||||
group='Jail',
|
group='Jail',
|
||||||
colour={r=50,g=50,b=50},
|
colour={r=50,g=50,b=50},
|
||||||
is_jail=true,
|
is_jail=true,
|
||||||
|
is_antiroot=true,
|
||||||
allow={}
|
allow={}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
--- Adds roles where a player can have more than one role
|
--- Adds roles where a player can have more than one role
|
||||||
-- @module ExpGamingCore.Role@4.0.0
|
-- @module ExpGamingCore.Role@4.0.0
|
||||||
-- @author Cooldude2606
|
-- @author Cooldude2606
|
||||||
-- @license https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Ranking_4.0.0.zip
|
-- @license https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Role_4.0.0.zip
|
||||||
-- @alais Role
|
-- @alais Role
|
||||||
|
|
||||||
-- Module Require
|
-- Module Require
|
||||||
@@ -18,7 +18,7 @@ local Role = {
|
|||||||
order={},
|
order={},
|
||||||
flags={},
|
flags={},
|
||||||
actions={},
|
actions={},
|
||||||
meta={times={}},
|
meta={times={},groups={}},
|
||||||
roles=setmetatable({},{
|
roles=setmetatable({},{
|
||||||
__index=table.autokey,
|
__index=table.autokey,
|
||||||
__newindex=function(tbl,key,value)
|
__newindex=function(tbl,key,value)
|
||||||
@@ -39,6 +39,9 @@ local Role = {
|
|||||||
if not role then error('Invalid role name in order listing: '..role_name) return end
|
if not role then error('Invalid role name in order listing: '..role_name) return end
|
||||||
if role.is_default then self.meta.default = role end
|
if role.is_default then self.meta.default = role end
|
||||||
if role.is_timed then self.meta.times[role.name] = {index,role.time} end
|
if role.is_timed then self.meta.times[role.name] = {index,role.time} end
|
||||||
|
if not self.meta.groups[role.group.name] then self.meta.groups[role.group.name] = {lowest=index,highest=index} end
|
||||||
|
if self.meta.groups[role.group.name].highest > index then self.meta.groups[role.group.name].highest = index end
|
||||||
|
if self.meta.groups[role.group.name].lowest < index then self.meta.groups[role.group.name].lowest = index end
|
||||||
if previous then setmetatable(previous.allow,{__index=role.allow}) end
|
if previous then setmetatable(previous.allow,{__index=role.allow}) end
|
||||||
role.index = index
|
role.index = index
|
||||||
previous = role
|
previous = role
|
||||||
@@ -52,6 +55,7 @@ local Role = {
|
|||||||
local global = global{
|
local global = global{
|
||||||
change_chache_length=15,
|
change_chache_length=15,
|
||||||
changes={},
|
changes={},
|
||||||
|
latest_change={},
|
||||||
preassign={},
|
preassign={},
|
||||||
players={},
|
players={},
|
||||||
roles={}
|
roles={}
|
||||||
@@ -118,14 +122,14 @@ function Role.assign(player,role,by_player,no_log)
|
|||||||
if is_type(role,'table') and not role.name then
|
if is_type(role,'table') and not role.name then
|
||||||
local ctn = 0
|
local ctn = 0
|
||||||
for _,_role in ipairs(role) do ctn=ctn+1 Role.assign(player,_role,by_player,true) end
|
for _,_role in ipairs(role) do ctn=ctn+1 Role.assign(player,_role,by_player,true) end
|
||||||
if ctn > 0 then if not no_log then table.insert(global.changes[player.index],{'assign',role}) end return end
|
if ctn > 0 then if not no_log then table.insert(global.changes[player.index],{'assign',role}) global.latest_change = {player.index,'assign',role} end return end
|
||||||
end
|
end
|
||||||
local role = Role.get(role)
|
local role = Role.get(role)
|
||||||
if not role then error('Invalid role #2 given to Role.assign.',2) return end
|
if not role then error('Invalid role #2 given to Role.assign.',2) return end
|
||||||
-- this acts as a way to provent the global table getting too full
|
-- this acts as a way to provent the global table getting too full
|
||||||
if not global.changes[player.index] then global.changes[player.index]={} end
|
if not global.changes[player.index] then global.changes[player.index]={} end
|
||||||
if #global.changes[player.index] > global.change_chache_length then table.remove(global.changes[player.index],1) end
|
if #global.changes[player.index] > global.change_chache_length then table.remove(global.changes[player.index],1) end
|
||||||
if not no_log then table.insert(global.changes[player.index],{'assign',role.name}) end
|
if not no_log then table.insert(global.changes[player.index],{'assign',role.name}) global.latest_change = {player.index,'assign',role.name} end
|
||||||
return role:add_player(player,by_player)
|
return role:add_player(player,by_player)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -143,14 +147,14 @@ function Role.unassign(player,role,by_player,no_log)
|
|||||||
if is_type(role,'table') and not role.name then
|
if is_type(role,'table') and not role.name then
|
||||||
local ctn = 0
|
local ctn = 0
|
||||||
for _,_role in ipairs(role) do ctn=ctn+1 Role.unassign(player,_role,by_player,true) end
|
for _,_role in ipairs(role) do ctn=ctn+1 Role.unassign(player,_role,by_player,true) end
|
||||||
if ctn > 0 then if not no_log then table.insert(global.changes[player.index],{'unassign',role}) end return end
|
if ctn > 0 then if not no_log then table.insert(global.changes[player.index],{'unassign',role}) global.latest_change = {player.index,'unassign',role} end return end
|
||||||
end
|
end
|
||||||
local role = Role.get(role)
|
local role = Role.get(role)
|
||||||
if not role then error('Invalid role #2 given to Role.unassign.',2) return end
|
if not role then error('Invalid role #2 given to Role.unassign.',2) return end
|
||||||
if not global.changes[player.index] then global.changes[player.index]={} end
|
if not global.changes[player.index] then global.changes[player.index]={} end
|
||||||
-- this acts as a way to provent the global table getting too full
|
-- this acts as a way to provent the global table getting too full
|
||||||
if #global.changes[player.index] > global.change_chache_length then table.remove(global.changes[player.index],1) end
|
if #global.changes[player.index] > global.change_chache_length then table.remove(global.changes[player.index],1) end
|
||||||
if not no_log then table.insert(global.changes[player.index],{'unassign',role.name}) end
|
if not no_log then table.insert(global.changes[player.index],{'unassign',role.name}) global.latest_change = {player.index,'unassign',role.name} end
|
||||||
return role:remove_player(player,by_player)
|
return role:remove_player(player,by_player)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -306,6 +310,7 @@ end
|
|||||||
function Role._prototype:allowed(action)
|
function Role._prototype:allowed(action)
|
||||||
if not self_test(self,'role','allowed') then return end
|
if not self_test(self,'role','allowed') then return end
|
||||||
if not type_error(action,'string','Invalid argument #1 to role:allowed, action is not a string.') then return end
|
if not type_error(action,'string','Invalid argument #1 to role:allowed, action is not a string.') then return end
|
||||||
|
if self.is_antiroot then return false end
|
||||||
return self.allow[action] or self.is_root or false -- still include is_root exception flag
|
return self.allow[action] or self.is_root or false -- still include is_root exception flag
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -379,8 +384,7 @@ function Role._prototype:add_player(player,by_player)
|
|||||||
if not self_test(self,'role','add_player') then return end
|
if not self_test(self,'role','add_player') then return end
|
||||||
local player = Game.get_player(player)
|
local player = Game.get_player(player)
|
||||||
if not player then error('Invalid player #1 given to role:add_player.',2) return end
|
if not player then error('Invalid player #1 given to role:add_player.',2) return end
|
||||||
local by_player = Game.get_player(by_player)
|
local by_player = Game.get_player(by_player) or SERVER
|
||||||
if not by_player then by_player = {name='<server>',index=0} end
|
|
||||||
if not global.roles[self.name] then global.roles[self.name] = {} end
|
if not global.roles[self.name] then global.roles[self.name] = {} end
|
||||||
if not global.players[player.index] then global.players[player.index] = {} end
|
if not global.players[player.index] then global.players[player.index] = {} end
|
||||||
local highest = Role.get_highest(player) or Role.meta.default
|
local highest = Role.get_highest(player) or Role.meta.default
|
||||||
@@ -405,7 +409,7 @@ function Role._prototype:remove_player(player,by_player)
|
|||||||
if not self_test(self,'role','add_player') then return end
|
if not self_test(self,'role','add_player') then return end
|
||||||
local player = Game.get_player(player)
|
local player = Game.get_player(player)
|
||||||
if not player then error('Invalid player #1 given to role:remove_player.',2) return end
|
if not player then error('Invalid player #1 given to role:remove_player.',2) return end
|
||||||
local by_player = Game.get_player(by_player) or {name='<server>',index=0}
|
local by_player = Game.get_player(by_player) or SERVER
|
||||||
if not global.roles[self.name] then global.roles[self.name] = {} end
|
if not global.roles[self.name] then global.roles[self.name] = {} end
|
||||||
if not global.players[player.index] then global.players[player.index] = {} end
|
if not global.players[player.index] then global.players[player.index] = {} end
|
||||||
local highest = Role.get_highest(player) or Role.meta.default
|
local highest = Role.get_highest(player) or Role.meta.default
|
||||||
@@ -429,7 +433,7 @@ end
|
|||||||
script.on_event(role_change_event_id,function(event)
|
script.on_event(role_change_event_id,function(event)
|
||||||
-- varible init
|
-- varible init
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
local by_player = Game.get_player(event.by_player_index) or {name='<server>',index=0}
|
local by_player = Game.get_player(event.by_player_index) or SERVER
|
||||||
local role = Role.get(event.role_name)
|
local role = Role.get(event.role_name)
|
||||||
local highest = Role.get_highest(player) or {__faild=true,tag='',name='None'}
|
local highest = Role.get_highest(player) or {__faild=true,tag='',name='None'}
|
||||||
-- gets the falgs the player currently has
|
-- gets the falgs the player currently has
|
||||||
@@ -437,7 +441,10 @@ script.on_event(role_change_event_id,function(event)
|
|||||||
-- assign new tag and group of highest role
|
-- assign new tag and group of highest role
|
||||||
if highest.__faild then Group.get(player):remove_player(player)
|
if highest.__faild then Group.get(player):remove_player(player)
|
||||||
else Group.assign(player,highest.group) end
|
else Group.assign(player,highest.group) end
|
||||||
if player.tag ~= highest.tag then player.tag = highest.tag player.print{'ExpGamingCore-Role.tag-reset'} end
|
local old_highest_tag = Role.get(event.old_highest).tag or ''
|
||||||
|
local start, _end = string.find(player.tag,old_highest_tag,1,true)
|
||||||
|
if start and old_highest_tag ~= highest.tag then player.tag = string.sub(player.tag,0,start-1)..highest.tag..string.sub(player.tag,_end+1) end
|
||||||
|
if not start then player.tag = highest.tag player_return({'ExpGamingCore-Role.tag-reset'},nil,player) end
|
||||||
-- play a sound to the player
|
-- play a sound to the player
|
||||||
if event.effect == 'assign' and not role.is_jail then player.play_sound{path='utility/achievement_unlocked'}
|
if event.effect == 'assign' and not role.is_jail then player.play_sound{path='utility/achievement_unlocked'}
|
||||||
else player.play_sound{path='utility/game_lost'} end
|
else player.play_sound{path='utility/game_lost'} end
|
||||||
@@ -454,6 +461,7 @@ script.on_event(role_change_event_id,function(event)
|
|||||||
by_player_name=by_player.name,
|
by_player_name=by_player.name,
|
||||||
role_name=role.name,
|
role_name=role.name,
|
||||||
highest_role_name=highest.name,
|
highest_role_name=highest.name,
|
||||||
|
old_highest=event.highest,
|
||||||
effect=event.effect
|
effect=event.effect
|
||||||
})..'\n'
|
})..'\n'
|
||||||
, true, 0)
|
, true, 0)
|
||||||
|
|||||||
@@ -177,24 +177,24 @@ function Sync.count_afk_times(time)
|
|||||||
return rtn
|
return rtn
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Used to get the number of players in each rank and currently online; if ExpGamingCore/Ranking is present then it will give more than admin and user
|
--- Used to get the number of players in each rank and currently online; if ExpGamingCore/Role is present then it will give more than admin and user
|
||||||
-- @usage Sync.count_ranks()
|
-- @usage Sync.count_roles()
|
||||||
-- @treturn table contains the ranks and the players in that rank
|
-- @treturn table contains the ranks and the players in that rank
|
||||||
function Sync.count_ranks()
|
function Sync.count_roles()
|
||||||
if not game then return {'Offline'} end
|
if not game then return {'Offline'} end
|
||||||
local _ranks = {admin={online={},players={}},user={online={},players={}}}
|
local _roles = {admin={online={},players={}},user={online={},players={}}}
|
||||||
for index,player in pairs(game.players) do
|
for index,player in pairs(game.players) do
|
||||||
if player.admin then
|
if player.admin then
|
||||||
table.insert(_ranks.admin.players,player.name)
|
table.insert(_roles.admin.players,player.name)
|
||||||
if player.connected then table.insert(_ranks.admin.online,player.name) end
|
if player.connected then table.insert(_roles.admin.online,player.name) end
|
||||||
else
|
else
|
||||||
table.insert(_ranks.user.players,player.name)
|
table.insert(_roles.user.players,player.name)
|
||||||
if player.connected then table.insert(_ranks.user.online,player.name) end
|
if player.connected then table.insert(_roles.user.online,player.name) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
_ranks.admin.n_players,_ranks.admin.n_online=#_ranks.admin.players,#_ranks.admin.online
|
_roles.admin.n_players,_roles.admin.n_online=#_roles.admin.players,#_roles.admin.online
|
||||||
_ranks.user.n_players,_ranks.user.n_online=#_ranks.user.players,#_ranks.user.online
|
_roles.user.n_players,_roles.user.n_online=#_roles.user.players,#_roles.user.online
|
||||||
return _ranks
|
return _roles
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Used to get a list of every player name with the option to limit to only online players
|
--- Used to get a list of every player name with the option to limit to only online players
|
||||||
@@ -255,7 +255,7 @@ function Sync.update()
|
|||||||
afk_players=Sync.count_afk_times(),
|
afk_players=Sync.count_afk_times(),
|
||||||
times=Sync.count_player_times()
|
times=Sync.count_player_times()
|
||||||
}
|
}
|
||||||
info.ranks = Sync.count_ranks()
|
info.ranks = Sync.count_roles()
|
||||||
info.rockets = game.forces['player'].get_item_launched('satellite')
|
info.rockets = game.forces['player'].get_item_launched('satellite')
|
||||||
for key,callback in pairs(Sync_updates) do info[key] = callback() end
|
for key,callback in pairs(Sync_updates) do info[key] = callback() end
|
||||||
return info
|
return info
|
||||||
@@ -310,7 +310,7 @@ script.on_event('on_rocket_launched',Sync.emit_update)
|
|||||||
|
|
||||||
function Sync:on_init()
|
function Sync:on_init()
|
||||||
if loaded_modules['ExpGamingCore.Gui'] then verbose('ExpGamingCore.Gui is installed; Loading gui src') require(module_path..'/src/gui',{Sync=Sync}) end
|
if loaded_modules['ExpGamingCore.Gui'] then verbose('ExpGamingCore.Gui is installed; Loading gui src') require(module_path..'/src/gui',{Sync=Sync}) end
|
||||||
if loaded_modules['ExpGamingCore.Ranking'] then verbose('ExpGamingCore.Ranking is installed; Loading ranking src') require(module_path..'/src/ranking',{Sync=Sync}) end
|
if loaded_modules['ExpGamingCore.Role'] then verbose('ExpGamingCore.Role is installed; Loading role src') require(module_path..'/src/ranking',{Sync=Sync}) end
|
||||||
if loaded_modules['ExpGamingCore.Server'] then require('ExpGamingCore.Server').add_module_to_interface('Sync','ExpGamingCore.Sync') end
|
if loaded_modules['ExpGamingCore.Server'] then require('ExpGamingCore.Server').add_module_to_interface('Sync','ExpGamingCore.Sync') end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,55 +4,55 @@
|
|||||||
-- @author Cooldude2606
|
-- @author Cooldude2606
|
||||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||||
|
|
||||||
--- This file will be loaded when ExpGamingCore.Ranking is present
|
--- This file will be loaded when ExpGamingCore.Role is present
|
||||||
-- @function _comment
|
-- @function _comment
|
||||||
|
|
||||||
local Game = require('FactorioStdLib.Game')
|
local Game = require('FactorioStdLib.Game')
|
||||||
local Color = require('FactorioStdLib.Color')
|
local Color = require('FactorioStdLib.Color')
|
||||||
local Ranking = require('ExpGamingCore.Ranking')
|
local Role = require('ExpGamingCore.Role')
|
||||||
|
|
||||||
--- Used as a redirect to Ranking._base_preset that will set the rank given to a player apon joining
|
--- Used as a redirect to Role._base_preset that will set the rank given to a player apon joining
|
||||||
-- @usage Sync.set_ranks{player_name=rank_name,...}
|
-- @usage Sync.set_roles{player_name=rank_name,...}
|
||||||
function Sync.set_ranks(...)
|
function Sync.set_roles(...)
|
||||||
Ranking._base_preset(...)
|
Role._base_preset(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Used to get the number of players in each rank and currently online
|
--- Used to get the number of players in each rank and currently online
|
||||||
-- @usage Sync.count_ranks()
|
-- @usage Sync.count_roles()
|
||||||
-- @treturn table contains the ranks and the players in that rank
|
-- @treturn table contains the ranks and the players in that rank
|
||||||
function Sync.count_ranks()
|
function Sync.count_roles()
|
||||||
if not game then return {'Offline'} end
|
if not game then return {'Offline'} end
|
||||||
local _ranks = {}
|
local _roles = {}
|
||||||
for name,rank in pairs(Ranking.ranks) do
|
for name,role in pairs(Role.roles) do
|
||||||
local players = rank:get_players()
|
local players = role:get_players()
|
||||||
for k,player in pairs(players) do players[k] = player.name end
|
for k,player in pairs(players) do players[k] = player.name end
|
||||||
local online = rank:get_players(true)
|
local online = role:get_players(true)
|
||||||
for k,player in pairs(online) do online[k] = player.name end
|
for k,player in pairs(online) do online[k] = player.name end
|
||||||
_ranks[rank.name] = {players=players,online=online,n_players=#players,n_online=#online}
|
_roles[role.name] = {players=players,online=online,n_players=#players,n_online=#online}
|
||||||
end
|
end
|
||||||
return _ranks
|
return _roles
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Adds a caption to the info gui that shows the rank given to the player
|
-- Adds a caption to the info gui that shows the rank given to the player
|
||||||
if Sync.add_to_gui then
|
if Sync.add_to_gui then
|
||||||
Sync.add_to_gui(function(player,frame)
|
Sync.add_to_gui(function(player,frame)
|
||||||
return 'You have been assigned the rank \''..Ranking.get_rank(player).name..'\''
|
return 'You have been assigned the rank \''..Role.get_highest(player).name..'\''
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- adds a discord emit for rank chaning
|
-- adds a discord emit for rank chaning
|
||||||
script.on_event('on_rank_change',function(event)
|
script.on_event('on_role_change',function(event)
|
||||||
local rank = Ranking.get_rank(event.new_rank)
|
local role = Role.get(event.role_name)
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
local by_player_name = Game.get_player(event.by_player_index) or '<server>'
|
local by_player = Game.get_player(event.by_player_index) or SERVER
|
||||||
local global = global.Ranking
|
local global = global['ExpGamingCore.Role^4.0.0']
|
||||||
if rank.group.name == 'Jail' and global.last_change ~= player.name then
|
if role.is_jail == 'Jail' and global.last_change[1] ~= player.index then
|
||||||
Sync.emit_embeded{
|
Sync.emit_embeded{
|
||||||
title='Player Jail',
|
title='Player Jail',
|
||||||
color=Color.to_hex(defines.textcolor.med),
|
color=Color.to_hex(defines.textcolor.med),
|
||||||
description='There was a player jailed.',
|
description='There was a player jailed.',
|
||||||
['Player:']='<<inline>>'..player.name,
|
['Player:']='<<inline>>'..player.name,
|
||||||
['By:']='<<inline>>'..by_player_name,
|
['By:']='<<inline>>'..by_player.name,
|
||||||
['Reason:']='No Reason'
|
['Reason:']='No Reason'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -132,8 +132,8 @@ Gui.left.add{
|
|||||||
}
|
}
|
||||||
local data = _global()
|
local data = _global()
|
||||||
local player = Game.get_player(frame.player_index)
|
local player = Game.get_player(frame.player_index)
|
||||||
local rank = Ranking.get_rank(player)
|
local allowed = Role.allowed(player,'edit-tasklist')
|
||||||
if rank:allowed('edit-tasklist') then
|
if allowed then
|
||||||
if not data._edit[player.index] then data._edit[player.index] = table.deepcopy(data._base) end
|
if not data._edit[player.index] then data._edit[player.index] = table.deepcopy(data._base) end
|
||||||
end
|
end
|
||||||
for i,task in pairs(_tasks(player)) do
|
for i,task in pairs(_tasks(player)) do
|
||||||
@@ -156,7 +156,7 @@ Gui.left.add{
|
|||||||
type='flow',
|
type='flow',
|
||||||
direction='horizontal'
|
direction='horizontal'
|
||||||
}
|
}
|
||||||
if rank:allowed('edit-tasklist') then
|
if allowed then
|
||||||
_edit(button_flow)
|
_edit(button_flow)
|
||||||
if data._edit[player.index]._editing[i] then
|
if data._edit[player.index]._editing[i] then
|
||||||
local element = remove:draw(button_flow)
|
local element = remove:draw(button_flow)
|
||||||
@@ -168,7 +168,7 @@ Gui.left.add{
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if rank:allowed('edit-tasklist') then
|
if allowed then
|
||||||
local flow = title.add{
|
local flow = title.add{
|
||||||
name=#_tasks(player),
|
name=#_tasks(player),
|
||||||
type='flow',
|
type='flow',
|
||||||
@@ -182,11 +182,10 @@ Gui.left.add{
|
|||||||
element.style.height = 20
|
element.style.height = 20
|
||||||
element.style.width = 20
|
element.style.width = 20
|
||||||
end
|
end
|
||||||
if #_tasks(player) == 0 and not rank:allowed('edit-tasklist') then frame.style.visible = false end
|
if #_tasks(player) == 0 and not role:allowed('edit-tasklist') then frame.style.visible = false end
|
||||||
end,
|
end,
|
||||||
can_open=function(player)
|
can_open=function(player)
|
||||||
local rank = Ranking.get_rank(player)
|
if Role.allowed(player,'edit-tasklist') or #_global().tasks > 0 then return true
|
||||||
if rank:allowed('edit-tasklist') or #_global().tasks > 0 then return true
|
|
||||||
else return {'tasklist.none'} end
|
else return {'tasklist.none'} end
|
||||||
end,
|
end,
|
||||||
open_on_join=true
|
open_on_join=true
|
||||||
|
|||||||
@@ -5,17 +5,17 @@
|
|||||||
|
|
||||||
local Game = require('FactorioStdLib.Game')
|
local Game = require('FactorioStdLib.Game')
|
||||||
local Gui = require('ExpGamingCore.Gui')
|
local Gui = require('ExpGamingCore.Gui')
|
||||||
local Ranking -- hanndled on load
|
local Role -- hanndled on load
|
||||||
local Sync -- hanndled on load
|
local Sync -- hanndled on load
|
||||||
|
|
||||||
function get_allowed_afk_time(player)
|
function get_allowed_afk_time(player)
|
||||||
local rank
|
local role
|
||||||
if Ranking then rank = Ranking.get_rank(player)
|
if Role then role = Role.get_highest(player)
|
||||||
else if player.admin then return else rank = {base_afk_time=15} end end
|
else if player.admin then return else rank = Role.meta.default end end
|
||||||
local count = #game.connected_players
|
local count = #game.connected_players
|
||||||
local base = rank.base_afk_time or false
|
local base = role.index or false
|
||||||
if not base then return false end
|
if not base then return false end
|
||||||
return (base/5)*count
|
return (10/base)*count
|
||||||
end
|
end
|
||||||
|
|
||||||
script.on_event(defines.events.on_tick,function(event)
|
script.on_event(defines.events.on_tick,function(event)
|
||||||
@@ -31,7 +31,7 @@ end)
|
|||||||
return {
|
return {
|
||||||
get_allowed_afk_time=get_allowed_afk_time,
|
get_allowed_afk_time=get_allowed_afk_time,
|
||||||
on_init=function(self)
|
on_init=function(self)
|
||||||
if loaded_modules['ExpGamingCore.Ranking'] then Ranking = require('ExpGamingCore.Ranking') end
|
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
|
||||||
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
|
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
|
||||||
if loaded_modules['ExpGamingCore.Server'] then require(module_path..'/src/server',Sync) end
|
if loaded_modules['ExpGamingCore.Server'] then require(module_path..'/src/server',Sync) end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
-- Module Require
|
-- Module Require
|
||||||
local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0')
|
local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0')
|
||||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
local Ranking -- ExpGamingCore.Ranking@^4.0.0
|
local Role -- ExpGamingCore.Role@^4.0.0
|
||||||
|
|
||||||
-- Local Varibles
|
-- Local Varibles
|
||||||
-- removed from none admin ranks, no further action
|
-- removed from none admin ranks, no further action
|
||||||
@@ -48,7 +48,7 @@ local _root_tree = {low_items=low_items,med_items=med_items,high_items=high_item
|
|||||||
local module_verbose = false
|
local module_verbose = false
|
||||||
local ThisModule = {
|
local ThisModule = {
|
||||||
on_init=function()
|
on_init=function()
|
||||||
if loaded_modules['ExpGamingCore.Ranking@^4.0.0'] then Ranking = require('ExpGamingCore.Ranking@^4.0.0') end
|
if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ end
|
|||||||
|
|
||||||
function ThisModule.search_player(player)
|
function ThisModule.search_player(player)
|
||||||
for category,items in pairs(_root_tree) do
|
for category,items in pairs(_root_tree) do
|
||||||
if not Ranking or category ~= 'low_items' and not Ranking.get_rank(player):allowed('admin-items') then
|
if not Role or category ~= 'low_items' and not Role.allowed(player,'admin-items') then
|
||||||
for _,_inventory in pairs(inventorys) do
|
for _,_inventory in pairs(inventorys) do
|
||||||
local inventory = player.get_inventory(_inventory)
|
local inventory = player.get_inventory(_inventory)
|
||||||
if inventory then
|
if inventory then
|
||||||
@@ -82,7 +82,7 @@ script.on_event(defines.events.on_tick,function(event)
|
|||||||
local players = game.connected_players
|
local players = game.connected_players
|
||||||
if #players == 0 then return end
|
if #players == 0 then return end
|
||||||
local player = players[math.random(#players)]
|
local player = players[math.random(#players)]
|
||||||
if Ranking and Ranking.get_rank(player):allowed('all-items') then return end
|
if Role and Role.allowed(player,'all-items') then return end
|
||||||
ThisModule.search_player(player)
|
ThisModule.search_player(player)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
local Game = require('FactorioStdLib.Game')
|
local Game = require('FactorioStdLib.Game')
|
||||||
local Gui = require('ExpGamingCore.Gui')
|
local Gui = require('ExpGamingCore.Gui')
|
||||||
local Ranking -- hanndled on load
|
local Role -- hanndled on load
|
||||||
|
local Group -- hanndled on load
|
||||||
|
|
||||||
local function get_player_info(player,frame,add_cam)
|
local function get_player_info(player,frame,add_cam)
|
||||||
local player = Game.get_player(player)
|
local player = Game.get_player(player)
|
||||||
@@ -18,23 +19,26 @@ local function get_player_info(player,frame,add_cam)
|
|||||||
_player.color = player.color
|
_player.color = player.color
|
||||||
_player.admin = player.admin
|
_player.admin = player.admin
|
||||||
_player.online_time = player.online_time
|
_player.online_time = player.online_time
|
||||||
if Ranking then
|
_player.group = player.permission_group.name
|
||||||
_player.rank = Ranking.get_rank(player).name
|
if Role then
|
||||||
_player.group = Ranking.get_group(player).name
|
_player.highest_role = Role.get_highest(player).name
|
||||||
|
local roles = {}; for _,role in pairs(Role.get(player)) do table.insert(roles,role.name) end
|
||||||
|
_player.roles = roles
|
||||||
end
|
end
|
||||||
if frame then
|
if frame then
|
||||||
local frame = frame.add{type='frame',direction='vertical',style='image_frame'}
|
local frame = frame.add{type='frame',direction='vertical',style='image_frame'}
|
||||||
frame.style.width = 200
|
frame.style.width = 200
|
||||||
if Ranking then frame.style.height = 275
|
if Role then frame.style.height = 275
|
||||||
else frame.style.height = 260 end
|
else frame.style.height = 260 end
|
||||||
frame.add{type='label',caption={'player-info.name',_player.index,_player.name},style='caption_label'}
|
frame.add{type='label',caption={'player-info.name',_player.index,_player.name},style='caption_label'}
|
||||||
local _online = {'player-info.no'}; if _player.online then _online = {'player-info.yes'} end
|
local _online = {'player-info.no'}; if _player.online then _online = {'player-info.yes'} end
|
||||||
frame.add{type='label',caption={'player-info.online',_online,tick_to_display_format(_player.online_time)}}
|
frame.add{type='label',caption={'player-info.online',_online,tick_to_display_format(_player.online_time)}}
|
||||||
local _admin = {'player-info.no'}; if _player.admin then _admin = {'player-info.yes'} end
|
local _admin = {'player-info.no'}; if _player.admin then _admin = {'player-info.yes'} end
|
||||||
frame.add{type='label',caption={'player-info.admin',_admin}}
|
frame.add{type='label',caption={'player-info.admin',_admin}}
|
||||||
if Ranking then
|
if Role then
|
||||||
frame.add{type='label',caption={'player-info.group',_player.group}}
|
frame.add{type='label',caption={'player-info.group',_player.group}}
|
||||||
frame.add{type='label',caption={'player-info.rank',_player.rank}}
|
frame.add{type='label',caption={'player-info.role',_player.highest_role}}
|
||||||
|
frame.add{type='label',caption={'player-info.roles',table.concat(_player.roles,', ')}}
|
||||||
end
|
end
|
||||||
if add_cam then
|
if add_cam then
|
||||||
Gui.cam_link{entity=player.character,frame=frame,width=200,height=150,zoom=0.5,respawn_open=true}
|
Gui.cam_link{entity=player.character,frame=frame,width=200,height=150,zoom=0.5,respawn_open=true}
|
||||||
@@ -46,7 +50,8 @@ end
|
|||||||
return setmetatable({
|
return setmetatable({
|
||||||
get_player_info=get_player_info,
|
get_player_info=get_player_info,
|
||||||
on_init=function(self)
|
on_init=function(self)
|
||||||
if loaded_modules['ExpGamingCore.Ranking'] then Ranking = require('ExpGamingCore.Ranking') end
|
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
|
||||||
|
if loaded_modules['ExpGamingCore.Group'] then Group = require('ExpGamingCore.Group') end
|
||||||
end
|
end
|
||||||
},{
|
},{
|
||||||
__call=function(self,...) self.get_player_info(...) end
|
__call=function(self,...) self.get_player_info(...) end
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ local module_verbose = false
|
|||||||
local ThisModule = {
|
local ThisModule = {
|
||||||
on_init=function(self)
|
on_init=function(self)
|
||||||
if loaded_modules['ExpGamingPlayer.playerInfo'] then playerInfo = require('ExpGamingPlayer.playerInfo') end
|
if loaded_modules['ExpGamingPlayer.playerInfo'] then playerInfo = require('ExpGamingPlayer.playerInfo') end
|
||||||
if loaded_modules['ExpGamingCore.Ranking@^4.0.0'] then getPlayers = require(module_path..'/src/ranking') end
|
if loaded_modules['ExpGamingCore.Role@^4.0.0'] then getPlayers = require(module_path..'/src/ranking') end
|
||||||
if loaded_modules['ExpGamingAdmin.AdminLib@^4.0.0'] then Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') end
|
if loaded_modules['ExpGamingAdmin.AdminLib@^4.0.0'] then Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@@ -72,9 +72,12 @@ Gui.left.add{
|
|||||||
}
|
}
|
||||||
player_list.vertical_scroll_policy = 'auto'
|
player_list.vertical_scroll_policy = 'auto'
|
||||||
player_list.style.maximal_height=195
|
player_list.style.maximal_height=195
|
||||||
|
local done = {}
|
||||||
local players = getPlayers() -- list of [colour,shortHand,[playerOne,playerTwo]]
|
local players = getPlayers() -- list of [colour,shortHand,[playerOne,playerTwo]]
|
||||||
for _,rank in pairs(players) do
|
for _,rank in pairs(players) do
|
||||||
for _,player in pairs(rank[3]) do
|
for _,player in pairs(rank[3]) do
|
||||||
|
if not done[player.index] then
|
||||||
|
done[player.index] = true
|
||||||
local flow = player_list.add{type='flow'}
|
local flow = player_list.add{type='flow'}
|
||||||
if rank[2] == '' then
|
if rank[2] == '' then
|
||||||
flow.add{
|
flow.add{
|
||||||
@@ -100,6 +103,7 @@ Gui.left.add{
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
open_on_join=true
|
open_on_join=true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
local Ranking = require('ExpGamingCore.Ranking@^4.0.0')
|
local Role = require('ExpGamingCore.Role@^4.0.0')
|
||||||
|
|
||||||
return function()
|
return function()
|
||||||
local rtn = {}
|
local rtn = {}
|
||||||
for _,rank in pairs(Ranking.ranks) do
|
for _,role_name in pairs(Role.order) do
|
||||||
table.insert(rtn,{rank.colour,rank.short_hand,rank:get_players(true),rank:allowed('no-report')})
|
local role = Role.get(role_name)
|
||||||
|
table.insert(rtn,{role.colour,role.short_hand,role:get_players(true),role.not_reportable})
|
||||||
end
|
end
|
||||||
return rtn
|
return rtn
|
||||||
end
|
end
|
||||||
@@ -240,7 +240,7 @@ Gui.popup.add{
|
|||||||
local btn = next:draw(title)
|
local btn = next:draw(title)
|
||||||
btn.style.width = 20
|
btn.style.width = 20
|
||||||
btn.style.height = 20
|
btn.style.height = 20
|
||||||
if Ranking.get_rank(frame.player_index):allowed('create-poll') then
|
if Role.get_highest(frame.player_index):allowed('create-poll') then
|
||||||
local btn = create_poll:draw(title)
|
local btn = create_poll:draw(title)
|
||||||
btn.style.width = 20
|
btn.style.width = 20
|
||||||
btn.style.height = 20
|
btn.style.height = 20
|
||||||
@@ -254,7 +254,7 @@ Gui.popup.add{
|
|||||||
end,
|
end,
|
||||||
can_open=function(player)
|
can_open=function(player)
|
||||||
if #_polls().old > 0 then return true
|
if #_polls().old > 0 then return true
|
||||||
elseif Ranking.get_rank(player):allowed('create-poll') then return true
|
elseif Role.allowed(player,'create-poll') then return true
|
||||||
else return {'polls.no-poll'} end
|
else return {'polls.no-poll'} end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,19 +8,19 @@ Discord: https://discord.gg/r6dC2uK
|
|||||||
]]
|
]]
|
||||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||||
|
|
||||||
local function _ranks(player)
|
local function _roles(player)
|
||||||
local ranks = {'Select Rank'}
|
local roles = {'Select Rank'}
|
||||||
local _rank = Ranking.get_rank(player)
|
local _role = Role.get_highest(player)
|
||||||
for _,rank in pairs(Ranking._ranks()) do
|
for index,role_name in pairs(Role.order) do
|
||||||
if rank.power >= _rank.power then
|
if index >= _role.index then
|
||||||
table.insert(ranks,rank.name)
|
table.insert(ranks,role_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return ranks
|
return ranks
|
||||||
end
|
end
|
||||||
|
|
||||||
local rank_drop_down = Gui.inputs.add_drop_down('rank-drop-down-annoncements',_ranks,1,function(player,selected,items,element)
|
local role_drop_down = Gui.inputs.add_drop_down('rank-drop-down-annoncements',_roles,1,function(player,selected,items,element)
|
||||||
element.parent.rank.caption = selected
|
element.parent.role.caption = selected
|
||||||
if selected == 'Select Rank' then element.parent['send-annoncement'].style.visible = false
|
if selected == 'Select Rank' then element.parent['send-annoncement'].style.visible = false
|
||||||
else element.parent['send-annoncement'].style.visible = true end
|
else element.parent['send-annoncement'].style.visible = true end
|
||||||
end)
|
end)
|
||||||
@@ -30,18 +30,16 @@ local send_popup = Gui.inputs.add{
|
|||||||
name='send-annoncement',
|
name='send-annoncement',
|
||||||
caption='utility/export_slot'
|
caption='utility/export_slot'
|
||||||
}:on_event('click',function(event)
|
}:on_event('click',function(event)
|
||||||
local meta_data = Ranking.meta
|
|
||||||
local default = Ranking.get_rank(meta_data.default)
|
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
local rank = Ranking.get_rank(player)
|
local role = Role.get_highest(player)
|
||||||
local _rank = Ranking.get_rank(event.element.parent.rank.caption); if not _rank then return end
|
local _role = Role.get(event.element.parent.role.caption); if not _role then return end
|
||||||
local sent_by = {'announcements.sent-by',player.name,rank.name}
|
local sent_by = {'announcements.sent-by',player.name,role.name}
|
||||||
local rank_name = _rank.name..'s'; if rank_name == default.name..'s' then rank_name = 'Everyone' end
|
local role_name = _role.name..'s'; if rank_name == Role.meta.default.name..'s' then rank_name = 'Everyone' end
|
||||||
local sent_to = {'announcements.sent-to',rank_name}
|
local sent_to = {'announcements.sent-to',rank_name}
|
||||||
local message = event.element.parent.parent.message.text
|
local message = event.element.parent.parent.message.text
|
||||||
for power,__rank in pairs(Ranking._ranks()) do
|
for index,_role_name in pairs(Role.order) do
|
||||||
if power <= _rank.power then
|
if index <= _role.index then
|
||||||
Gui.popup.open('announcements',{sent_by=sent_by,sent_to=sent_to,message=message},__rank:get_players(true))
|
Gui.popup.open('announcements',{sent_by=sent_by,sent_to=sent_to,message=message},Role.get(_role_name):get_players(true))
|
||||||
event.element.parent.parent.message.text = ''
|
event.element.parent.parent.message.text = ''
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -42,40 +42,40 @@ local player_drop_down = Gui.inputs.add_drop_down('player-drop-down-rank-change'
|
|||||||
player_info_flow.clear()
|
player_info_flow.clear()
|
||||||
if selected == 'Select Player' then return
|
if selected == 'Select Player' then return
|
||||||
else get_player_info(selected,player_info_flow,true) end
|
else get_player_info(selected,player_info_flow,true) end
|
||||||
local rank = Ranking.get_rank(player)
|
local role = Role.get_highest(player)
|
||||||
local _rank = Ranking.get_rank(selected)
|
local _role = Role.get(selected)
|
||||||
if rank.power >= _rank.power then element.parent.warning.caption = {'rank-changer.warning'}
|
if role.index >= _role.index then element.parent.warning.caption = {'rank-changer.warning'}
|
||||||
else element.parent.warning.caption = '' end
|
else element.parent.warning.caption = '' end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function _ranks(player)
|
local function _roles(player)
|
||||||
local ranks = {'Select Rank'}
|
local roles = {'Select Rank'}
|
||||||
local _rank = Ranking.get_rank(player)
|
local _role = Role.get_highest(player)
|
||||||
for _,rank in pairs(Ranking._ranks()) do
|
for index,role_name in pairs(Role.order) do
|
||||||
if rank.power > _rank.power then
|
if index > _role.index then
|
||||||
table.insert(ranks,rank.name)
|
table.insert(ranks,role_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return ranks
|
return ranks
|
||||||
end
|
end
|
||||||
|
|
||||||
local rank_drop_down = Gui.inputs.add_drop_down('rank-drop-down-rank-change',_ranks,1,function(player,selected,items,element)
|
local role_drop_down = Gui.inputs.add_drop_down('rank-drop-down-rank-change',_roles,1,function(player,selected,items,element)
|
||||||
element.parent.parent.rank.caption = selected
|
element.parent.parent.role.caption = selected
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local set_rank = Gui.inputs.add{
|
local set_role = Gui.inputs.add{
|
||||||
type='button',
|
type='button',
|
||||||
name='rank-change-set',
|
name='rank-change-set',
|
||||||
caption={'rank-changer.set-rank'}
|
caption={'rank-changer.set-rank'}
|
||||||
}:on_event('click',function(event)
|
}:on_event('click',function(event)
|
||||||
local dropdowns = event.element.parent
|
local dropdowns = event.element.parent
|
||||||
local rank = Ranking.get_rank(event.player_index)
|
local role = Role.get_highest(event.player_index)
|
||||||
local _rank = Ranking.get_rank(dropdowns.parent.rank.caption)
|
local _role = Role.get(dropdowns.parent.role.caption)
|
||||||
local _player = Game.get_player(dropdowns.parent.player.caption)
|
local _player = Game.get_player(dropdowns.parent.player.caption)
|
||||||
if not _player or not _rank then dropdowns.warning.caption = {'rank-changer.invalid'} return end
|
if not _player or not _role then dropdowns.warning.caption = {'rank-changer.invalid'} return end
|
||||||
local __rank = Ranking.get_rank(_player)
|
local __role = Role.get_highest(_player)
|
||||||
if rank.power >= __rank.power then dropdowns.warning.caption = {'rank-changer.rank-high'} return end
|
if role.index >= __role.index then dropdowns.warning.caption = {'rank-changer.rank-high'} return end
|
||||||
Ranking.give_rank(_player,_rank,event)
|
Role.assign(_player,_role,event)
|
||||||
Gui.center.clear(event)
|
Gui.center.clear(event)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ Gui.center.add{
|
|||||||
}
|
}
|
||||||
label.style.single_line = false
|
label.style.single_line = false
|
||||||
label.style.width = 200
|
label.style.width = 200
|
||||||
set_rank:draw(dropdowns)
|
set_role:draw(dropdowns)
|
||||||
frame.add{
|
frame.add{
|
||||||
name='player',
|
name='player',
|
||||||
type='label',
|
type='label',
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ local go_to_warp = Gui.inputs.add{
|
|||||||
if player.vehicle then player.vehicle.set_passenger(nil) end
|
if player.vehicle then player.vehicle.set_passenger(nil) end
|
||||||
if player.vehicle then return end
|
if player.vehicle then return end
|
||||||
player.teleport(warp.surface.find_non_colliding_position('player',warp.position,32,1),warp.surface)
|
player.teleport(warp.surface.find_non_colliding_position('player',warp.position,32,1),warp.surface)
|
||||||
if not Ranking.get_rank(player):allowed('always-warp') then
|
if not Role.allowed(player,'always-warp') then
|
||||||
event.element.parent.parent.parent.parent.style.visible = false
|
event.element.parent.parent.parent.parent.style.visible = false
|
||||||
_warps().cooldowns[event.player_index] = warp_limit
|
_warps().cooldowns[event.player_index] = warp_limit
|
||||||
end
|
end
|
||||||
@@ -172,7 +172,7 @@ Gui.left.add{
|
|||||||
local btn = go_to_warp:draw(_flow)
|
local btn = go_to_warp:draw(_flow)
|
||||||
btn.style.height = 20
|
btn.style.height = 20
|
||||||
btn.style.width = 20
|
btn.style.width = 20
|
||||||
if Ranking.get_rank(player):allowed('make-warp') and name ~= 'Spawn' then
|
if Role.allowed(player,'make-warp') and name ~= 'Spawn' then
|
||||||
local btn = remove_warp:draw(_flow)
|
local btn = remove_warp:draw(_flow)
|
||||||
btn.style.height = 20
|
btn.style.height = 20
|
||||||
btn.style.width = 20
|
btn.style.width = 20
|
||||||
@@ -180,7 +180,7 @@ Gui.left.add{
|
|||||||
end
|
end
|
||||||
local cooldown = _warps().cooldowns[player.index] or 0
|
local cooldown = _warps().cooldowns[player.index] or 0
|
||||||
if cooldown > 0 then frame.style.visible = false return
|
if cooldown > 0 then frame.style.visible = false return
|
||||||
elseif Ranking.get_rank(player):allowed('always-warp') then return
|
elseif Role.allowed(player,'always-warp') then return
|
||||||
elseif player.surface.get_tile(player.position).name == warp_tile
|
elseif player.surface.get_tile(player.position).name == warp_tile
|
||||||
and player.surface.name == 'nauvis'
|
and player.surface.name == 'nauvis'
|
||||||
then return
|
then return
|
||||||
@@ -189,7 +189,7 @@ Gui.left.add{
|
|||||||
end,
|
end,
|
||||||
can_open=function(player)
|
can_open=function(player)
|
||||||
local cooldown = _warps().cooldowns[player.index] or 0
|
local cooldown = _warps().cooldowns[player.index] or 0
|
||||||
if Ranking.get_rank(player):allowed('always-warp') then return true
|
if Role.allowed(player,'always-warp') then return true
|
||||||
elseif player.surface.get_tile(player.position).name == warp_tile
|
elseif player.surface.get_tile(player.position).name == warp_tile
|
||||||
and player.surface.name == 'nauvis'
|
and player.surface.name == 'nauvis'
|
||||||
then return true
|
then return true
|
||||||
@@ -214,7 +214,7 @@ Event.register(defines.events.on_player_changed_position, function(event)
|
|||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
local cooldown = _warps().cooldowns[player.index] or 0
|
local cooldown = _warps().cooldowns[player.index] or 0
|
||||||
local tile = player.surface.get_tile(player.position).name
|
local tile = player.surface.get_tile(player.position).name
|
||||||
if not Ranking.get_rank(player):allowed('always-warp') and cooldown == 0 then
|
if not Role.allowed(player,'always-warp') and cooldown == 0 then
|
||||||
if tile == warp_tile and player.surface.name == 'nauvis' then
|
if tile == warp_tile and player.surface.name == 'nauvis' then
|
||||||
mod_gui.get_frame_flow(player)['warp-list'].style.visible = true
|
mod_gui.get_frame_flow(player)['warp-list'].style.visible = true
|
||||||
elseif player.position.x^2+player.position.y^2 < (warp_radius*spawn_warp_scale)^2 then
|
elseif player.position.x^2+player.position.y^2 < (warp_radius*spawn_warp_scale)^2 then
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ return {
|
|||||||
['ExpGamingLib@4.0.0']='./modules/ExpGamingLib',
|
['ExpGamingLib@4.0.0']='./modules/ExpGamingLib',
|
||||||
['ExpGamingCore.Command@4.0.0']='./modules/ExpGamingCore/Command',
|
['ExpGamingCore.Command@4.0.0']='./modules/ExpGamingCore/Command',
|
||||||
['ExpGamingCore.Server@4.0.0']='./modules/ExpGamingCore/Server',
|
['ExpGamingCore.Server@4.0.0']='./modules/ExpGamingCore/Server',
|
||||||
['ExpGamingCore.Ranking@^4.0.0']='./modules/ExpGamingCore/Ranking',
|
['ExpGamingCore.Group@4.0.0']='./modules/ExpGamingCore/Group',
|
||||||
['ExpGamingCore.Ranking@4.0.0']='./modules/ExpGamingCore/Ranking',
|
['ExpGamingCore.Role@^4.0.0']='./modules/ExpGamingCore/Role',
|
||||||
|
['ExpGamingCore.Role@4.0.0']='./modules/ExpGamingCore/Role',
|
||||||
['ExpGamingBot.autoChat@4.0.0']='./modules/ExpGamingBot/autoChat',
|
['ExpGamingBot.autoChat@4.0.0']='./modules/ExpGamingBot/autoChat',
|
||||||
['ExpGamingCore.Server@^4.0.0']='./modules/ExpGamingCore/Server',
|
['ExpGamingCore.Server@^4.0.0']='./modules/ExpGamingCore/Server',
|
||||||
['ExpGamingCommands.tags@4.0.0']='./modules/ExpGamingCommands/tags',
|
['ExpGamingCommands.tags@4.0.0']='./modules/ExpGamingCommands/tags',
|
||||||
@@ -48,7 +49,5 @@ return {
|
|||||||
['ExpGamingAdmin.Commands@4.0.0']='./modules/ExpGamingAdmin/Commands',
|
['ExpGamingAdmin.Commands@4.0.0']='./modules/ExpGamingAdmin/Commands',
|
||||||
['ExpGamingAdmin.Ban@4.0.0']='./modules/ExpGamingAdmin/Ban',
|
['ExpGamingAdmin.Ban@4.0.0']='./modules/ExpGamingAdmin/Ban',
|
||||||
['ChatPopup@4.0.0']='./modules/ChatPopup',
|
['ChatPopup@4.0.0']='./modules/ChatPopup',
|
||||||
['DamagePopup@4.0.0']='./modules/DamagePopup',
|
['DamagePopup@4.0.0']='./modules/DamagePopup'
|
||||||
['ExpGamingCore.Group@4.0.0']='./modules/ExpGamingCore/Group',
|
|
||||||
['ExpGamingCore.Role@4.0.0']='./modules/ExpGamingCore/Role',
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user