mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-28 12:05:21 +09:00
Added module: ExpGamingCore.Ranking
This commit is contained in:
118
modules/ExpGamingCore/Ranking/src/config.lua
Normal file
118
modules/ExpGamingCore/Ranking/src/config.lua
Normal file
@@ -0,0 +1,118 @@
|
||||
--- Description - A small description that will be displayed on the doc
|
||||
-- @submodule ExpGamingCore.Ranking
|
||||
-- @alias Ranking
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
--[[
|
||||
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'
|
||||
}
|
||||
155
modules/ExpGamingCore/Ranking/src/core.lua
Normal file
155
modules/ExpGamingCore/Ranking/src/core.lua
Normal file
@@ -0,0 +1,155 @@
|
||||
--- Description - A small description that will be displayed on the doc
|
||||
-- @submodule ExpGamingCore.Ranking
|
||||
-- @alias Ranking
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
--[[
|
||||
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=defines.color.white,
|
||||
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
|
||||
}
|
||||
43
modules/ExpGamingCore/Ranking/src/server.lua
Normal file
43
modules/ExpGamingCore/Ranking/src/server.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
--- Description - A small description that will be displayed on the doc
|
||||
-- @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
|
||||
|
||||
--- 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)
|
||||
Reference in New Issue
Block a user