mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-28 20:05:22 +09:00
Converted Modules To Use Roles
This commit is contained in:
@@ -5,17 +5,17 @@
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Gui = require('ExpGamingCore.Gui')
|
||||
local Ranking -- hanndled on load
|
||||
local Role -- hanndled on load
|
||||
local Sync -- hanndled on load
|
||||
|
||||
function get_allowed_afk_time(player)
|
||||
local rank
|
||||
if Ranking then rank = Ranking.get_rank(player)
|
||||
else if player.admin then return else rank = {base_afk_time=15} end end
|
||||
local role
|
||||
if Role then role = Role.get_highest(player)
|
||||
else if player.admin then return else rank = Role.meta.default end end
|
||||
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
|
||||
return (base/5)*count
|
||||
return (10/base)*count
|
||||
end
|
||||
|
||||
script.on_event(defines.events.on_tick,function(event)
|
||||
@@ -31,7 +31,7 @@ end)
|
||||
return {
|
||||
get_allowed_afk_time=get_allowed_afk_time,
|
||||
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.Server'] then require(module_path..'/src/server',Sync) end
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
-- Module Require
|
||||
local Admin = require('ExpGamingAdmin.AdminLib@^4.0.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
|
||||
-- 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 ThisModule = {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ end
|
||||
|
||||
function ThisModule.search_player(player)
|
||||
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
|
||||
local inventory = player.get_inventory(_inventory)
|
||||
if inventory then
|
||||
@@ -82,7 +82,7 @@ script.on_event(defines.events.on_tick,function(event)
|
||||
local players = game.connected_players
|
||||
if #players == 0 then return end
|
||||
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)
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
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 player = Game.get_player(player)
|
||||
@@ -18,23 +19,26 @@ local function get_player_info(player,frame,add_cam)
|
||||
_player.color = player.color
|
||||
_player.admin = player.admin
|
||||
_player.online_time = player.online_time
|
||||
if Ranking then
|
||||
_player.rank = Ranking.get_rank(player).name
|
||||
_player.group = Ranking.get_group(player).name
|
||||
_player.group = player.permission_group.name
|
||||
if Role then
|
||||
_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
|
||||
if frame then
|
||||
local frame = frame.add{type='frame',direction='vertical',style='image_frame'}
|
||||
frame.style.width = 200
|
||||
if Ranking then frame.style.height = 275
|
||||
if Role then frame.style.height = 275
|
||||
else frame.style.height = 260 end
|
||||
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
|
||||
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
|
||||
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.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
|
||||
if add_cam then
|
||||
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({
|
||||
get_player_info=get_player_info,
|
||||
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
|
||||
},{
|
||||
__call=function(self,...) self.get_player_info(...) end
|
||||
|
||||
@@ -29,7 +29,7 @@ local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function(self)
|
||||
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
|
||||
end
|
||||
}
|
||||
@@ -72,30 +72,34 @@ Gui.left.add{
|
||||
}
|
||||
player_list.vertical_scroll_policy = 'auto'
|
||||
player_list.style.maximal_height=195
|
||||
local done = {}
|
||||
local players = getPlayers() -- list of [colour,shortHand,[playerOne,playerTwo]]
|
||||
for _,rank in pairs(players) do
|
||||
for _,player in pairs(rank[3]) do
|
||||
local flow = player_list.add{type='flow'}
|
||||
if rank[2] == '' then
|
||||
flow.add{
|
||||
type='label',
|
||||
name=player.name,
|
||||
style='caption_label',
|
||||
caption={'ExpGamingPlayer-playerList.format-nil',tick_to_display_format(player.online_time),player.name}
|
||||
}.style.font_color = rank[1]
|
||||
else
|
||||
flow.add{
|
||||
type='label',
|
||||
name=player.name,
|
||||
style='caption_label',
|
||||
caption={'ExpGamingPlayer-playerList.format',tick_to_display_format(player.online_time),player.name,rank[2]}
|
||||
}.style.font_color = rank[1]
|
||||
end
|
||||
if Admin and Admin.report_btn then
|
||||
if not rank[4] and player.index ~= frame.player_index then
|
||||
local btn = Admin.report_btn:draw(flow)
|
||||
btn.style.height = 20
|
||||
btn.style.width = 20
|
||||
if not done[player.index] then
|
||||
done[player.index] = true
|
||||
local flow = player_list.add{type='flow'}
|
||||
if rank[2] == '' then
|
||||
flow.add{
|
||||
type='label',
|
||||
name=player.name,
|
||||
style='caption_label',
|
||||
caption={'ExpGamingPlayer-playerList.format-nil',tick_to_display_format(player.online_time),player.name}
|
||||
}.style.font_color = rank[1]
|
||||
else
|
||||
flow.add{
|
||||
type='label',
|
||||
name=player.name,
|
||||
style='caption_label',
|
||||
caption={'ExpGamingPlayer-playerList.format',tick_to_display_format(player.online_time),player.name,rank[2]}
|
||||
}.style.font_color = rank[1]
|
||||
end
|
||||
if Admin and Admin.report_btn then
|
||||
if not rank[4] and player.index ~= frame.player_index then
|
||||
local btn = Admin.report_btn:draw(flow)
|
||||
btn.style.height = 20
|
||||
btn.style.width = 20
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
local Ranking = require('ExpGamingCore.Ranking@^4.0.0')
|
||||
local Role = require('ExpGamingCore.Role@^4.0.0')
|
||||
|
||||
return function()
|
||||
local rtn = {}
|
||||
for _,rank in pairs(Ranking.ranks) do
|
||||
table.insert(rtn,{rank.colour,rank.short_hand,rank:get_players(true),rank:allowed('no-report')})
|
||||
for _,role_name in pairs(Role.order) do
|
||||
local role = Role.get(role_name)
|
||||
table.insert(rtn,{role.colour,role.short_hand,role:get_players(true),role.not_reportable})
|
||||
end
|
||||
return rtn
|
||||
end
|
||||
@@ -240,7 +240,7 @@ Gui.popup.add{
|
||||
local btn = next:draw(title)
|
||||
btn.style.width = 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)
|
||||
btn.style.width = 20
|
||||
btn.style.height = 20
|
||||
@@ -254,7 +254,7 @@ Gui.popup.add{
|
||||
end,
|
||||
can_open=function(player)
|
||||
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
|
||||
end
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user