mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 12:31:41 +09:00
Refactor of commands
This commit is contained in:
37
old/modules/ExpGamingPlayer/afkKick/control.lua
Normal file
37
old/modules/ExpGamingPlayer/afkKick/control.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
--- A full ranking system for factorio.
|
||||
-- @module ExpGamingPlayer.afkKick@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Role -- ExpGamingCore.Role@^4.0.0
|
||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||
|
||||
local function get_allowed_afk_time(player)
|
||||
player = Game.get_player(player)
|
||||
local role = Role and Role.get_highest(player) or {index=1,allow_afk_kick=not player.admin}
|
||||
local player_count = #game.connected_players
|
||||
local role_count = Role and Role.meta.count or 1
|
||||
local role_index = role.allow_afk_kick and role.index or false
|
||||
if not role_index then return false end
|
||||
return (role_count/role_index)*player_count
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_tick,function(event)
|
||||
if (game.tick%3600) ~= 0 then return end
|
||||
for _,player in pairs(game.connected_players) do
|
||||
local afk = #game.connected_players < 3 and 10 or get_allowed_afk_time(player)
|
||||
if afk then
|
||||
if player.afk_time > afk*3600 then game.kick_player(player,'AFK For Too Long ('..math.floor(afk)..' Minutes)') end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
return setmetatable({
|
||||
get_allowed_afk_time=get_allowed_afk_time,
|
||||
on_init=function(self)
|
||||
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=Sync,self=self}) end
|
||||
end
|
||||
},{__call=function(self,...) return self.get_allowed_afk_time(...) end})
|
||||
22
old/modules/ExpGamingPlayer/afkKick/softmod.json
Normal file
22
old/modules/ExpGamingPlayer/afkKick/softmod.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "ExpGamingPlayer.afkKick",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a varible amount of time before a user is kicked based on the current player count.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Kick",
|
||||
"AFK",
|
||||
"Players",
|
||||
"Smart",
|
||||
"Varible"
|
||||
],
|
||||
"dependencies": {
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingCore.Gui": "^4.0.0",
|
||||
"ExpGamingCore.Role": "?^4.0.0",
|
||||
"ExpGamingCore.Sync": "?^4.0.0",
|
||||
"ExpGamingCore.Server": "?^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingPlayer@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
29
old/modules/ExpGamingPlayer/afkKick/src/server.lua
Normal file
29
old/modules/ExpGamingPlayer/afkKick/src/server.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
local Sync = Sync
|
||||
local get_allowed_afk_time = self
|
||||
local Server = require('ExpGamingCore.Server')
|
||||
local Color = require('FactorioStdLib.Color')
|
||||
Event[defines.events.on_tick] = nil
|
||||
|
||||
script.on_init(function(event)
|
||||
Server.new_thread{
|
||||
name='afk-kick',
|
||||
}:on_event('tick',function(self)
|
||||
if (game.tick%3600) ~= 0 then return end
|
||||
for _,player in pairs(game.connected_players) do
|
||||
local afk = #game.connected_players < 3 and 10 or get_allowed_afk_time(player)
|
||||
if afk then
|
||||
if player.afk_time > afk*3600 then game.kick_player(player,'AFK For Too Long ('..math.floor(afk)..' Minutes)') end
|
||||
end
|
||||
end
|
||||
end):on_event('error',function(self,err)
|
||||
if Sync then
|
||||
Sync.emit_embedded{
|
||||
title='Auto Kick Error',
|
||||
color=Color.to_hex(defines.textcolor.bg),
|
||||
description='Auto Kick Error - Closed Thread',
|
||||
Error=err
|
||||
}
|
||||
end
|
||||
self:close()
|
||||
end):open()
|
||||
end)
|
||||
92
old/modules/ExpGamingPlayer/inventorySearch/control.lua
Normal file
92
old/modules/ExpGamingPlayer/inventorySearch/control.lua
Normal file
@@ -0,0 +1,92 @@
|
||||
--- Adds an inventory search that is preformed on a random player every 15 seconds
|
||||
-- @module ExpGamingPlayer.inventorySearch@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Module Require
|
||||
local Admin = require('ExpGamingAdmin')
|
||||
local Role -- ExpGamingCore.Role@^4.0.0
|
||||
|
||||
-- Local Variables
|
||||
-- removed from none admin ranks, no further action
|
||||
local low_items = {
|
||||
'loader',
|
||||
'fast-loader',
|
||||
'express-loader',
|
||||
'small-plane',
|
||||
'player-port',
|
||||
'coin',
|
||||
'programmable-speaker',
|
||||
'logistic-chest-active-provider'
|
||||
}
|
||||
|
||||
-- removed for admin and non-admin ranks, gives warnings to non-admins
|
||||
local med_items = {
|
||||
'railgun',
|
||||
'railgun-dart',
|
||||
'belt-immunity-equipment'
|
||||
}
|
||||
|
||||
-- temp-ban for any rank, this is a very hard enforcement, admin ranks lose rank
|
||||
local high_items = {
|
||||
'electric-energy-interface',
|
||||
'infinity-chest'
|
||||
}
|
||||
|
||||
-- inventories which are searched
|
||||
local inventories = {
|
||||
defines.inventory.player_main,
|
||||
defines.inventory.player_quickbar,
|
||||
defines.inventory.player_trash
|
||||
}
|
||||
|
||||
local _root_tree = {low_items=low_items,med_items=med_items,high_items=high_items}
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
|
||||
end
|
||||
}
|
||||
|
||||
-- Function Define
|
||||
local function take_action(player,item_name,category)
|
||||
if category == 'low_items' then player_return({'ExpGamingPlayer-inventorySearch.low',item_name},defines.textcolor.med,player)
|
||||
elseif category == 'med_items' then player_return({'ExpGamingPlayer-inventorySearch.med',item_name},defines.textcolor.high,player) Admin.give_warning(player,'<server>','Found A Banned Item',5)
|
||||
elseif category == 'high_items' then player_return({'ExpGamingPlayer-inventorySearch.high',item_name},defines.textcolor.crit,player) Admin.temp_ban(player,'<server>','Found A Banned Item')
|
||||
else return end
|
||||
end
|
||||
|
||||
function ThisModule.search_player(player)
|
||||
for category,items in pairs(_root_tree) do
|
||||
if not Role or category ~= 'low_items' and not Role.allowed(player,'admin-items') then
|
||||
for _,_inventory in pairs(inventories) do
|
||||
local inventory = player.get_inventory(_inventory)
|
||||
if inventory then
|
||||
for _,item in pairs(items) do
|
||||
local found = inventory.remove(item)
|
||||
if found > 0 then take_action(player,item,category) end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Event Handlers Define
|
||||
Event.add(defines.events.on_tick,function(event)
|
||||
if (game.tick%900) == 0 then
|
||||
local players = game.connected_players
|
||||
if #players == 0 then return end
|
||||
local player = players[math.random(#players)]
|
||||
if Role and Role.allowed(player,'all-items') then return end
|
||||
ThisModule.search_player(player)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Module Return
|
||||
return setmetatable(ThisModule,{
|
||||
__call=function(self,...) self.search_player(...) end
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
[ExpGamingPlayer-inventorySearch]
|
||||
low=Dein Inventar wurde durchsucht und __1__ wurde entfernt.
|
||||
med=Dein Inventar wurde durchsucht und __1__ wurde entfernt. Dir wird hiermit eine Warnung erteilt! Versuche es nicht erneut!
|
||||
high=Dein inventar wurde durchsucht und __1__ wurde gefunden, dies ist auf GAR KEINEN Fall erlaubt, dein Inventar wurde zum Spawnpunkt transferiert.
|
||||
@@ -0,0 +1,4 @@
|
||||
[ExpGamingPlayer-inventorySearch]
|
||||
low=Your inventory was searched and __1__ was removed.
|
||||
med=Your inventory was searched and __1__ was removed, you have been given a warning as a result.
|
||||
high=Your inventory was searched and __1__ was removed: this is NOT allowed. You have been temp-banned as a result.
|
||||
@@ -0,0 +1,4 @@
|
||||
[ExpGamingPlayer-inventorySearch]
|
||||
low=Your Inventory Was Search And __1__ was removed.
|
||||
med=Your Inventory Was Search And __1__ was removed, you have been given a warning.
|
||||
high=Your Inventory Was Search And __1__ was found, this is not allowed AT ALL, your inventory has been moved to spawn.
|
||||
@@ -0,0 +1,4 @@
|
||||
[ExpGamingPlayer-inventorySearch]
|
||||
low=Je inventaris is doorzocht en __1__ is verwijderd.
|
||||
med=Je inventaris is doorzocht en __1__ is verwijderd, je bent gewaarschuwd.
|
||||
high=Je inventaris is doorzocht en __1__ is gevonden, dit is ten strengste verboden! Je inventaris is verwijderd.
|
||||
@@ -0,0 +1,4 @@
|
||||
[ExpGamingPlayer-inventorySearch]
|
||||
low=Ditt inventarie blev genomsökt och __1__ togs bort.
|
||||
med=Ditt inventarie blev genomsökt och __1__ togs bort, du har fått en varning på grund av detta.
|
||||
high=Ditt inventarie blev genomsökt och __1__ togs bort: Det här är inte tillåtet. Som ett resultat av det har du blivit tillfälligt bannlyst.
|
||||
22
old/modules/ExpGamingPlayer/inventorySearch/softmod.json
Normal file
22
old/modules/ExpGamingPlayer/inventorySearch/softmod.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "ExpGamingPlayer.inventorySearch",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds an inventory search that is proformed on a random player every 15 seconds.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Search",
|
||||
"ExpGaming",
|
||||
"Player",
|
||||
"Inventory"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingLib": "^4.0.0",
|
||||
"ExpGamingAdmin.TempBan": "^4.0.0",
|
||||
"ExpGamingAdmin.Warnings": "^4.0.0",
|
||||
"ExpGamingCore.Role": "?^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingAdmin": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingPlayer@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
58
old/modules/ExpGamingPlayer/playerInfo/control.lua
Normal file
58
old/modules/ExpGamingPlayer/playerInfo/control.lua
Normal file
@@ -0,0 +1,58 @@
|
||||
--- Used to give so common info on a player as a lua table or a frame.
|
||||
-- @module ExpGamingPlayer.playerInfo@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Gui = require('ExpGamingCore.Gui')
|
||||
local Role -- ExpGamingCore.Role@^4.0.0
|
||||
local Group -- ExpGamingCore.Group@^4.0.0
|
||||
|
||||
local function get_player_info(player,frame,add_cam)
|
||||
player = Game.get_player(player)
|
||||
if not player then return {} end
|
||||
local _player = {}
|
||||
_player.index = player.index
|
||||
_player.name = player.name
|
||||
_player.online = player.connected
|
||||
_player.tag = player.tag
|
||||
_player.color = player.color
|
||||
_player.admin = player.admin
|
||||
_player.online_time = player.online_time
|
||||
_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
|
||||
frame = frame.add{type='frame',direction='vertical',style='image_frame'}
|
||||
frame.style.width = 200
|
||||
if Role then frame.style.height = 300
|
||||
else frame.style.height = 260 end
|
||||
frame.add{type='label',caption={'ExpGamingPlayer-playerInfo.name',_player.index,_player.name},style='caption_label'}
|
||||
local _online = {'ExpGamingPlayer-playerInfo.no'}; if _player.online then _online = {'ExpGamingPlayer-playerInfo.yes'} end
|
||||
frame.add{type='label',caption={'ExpGamingPlayer-playerInfo.online',_online,tick_to_display_format(_player.online_time)}}
|
||||
local _admin = {'ExpGamingPlayer-playerInfo.no'}; if _player.admin then _admin = {'ExpGamingPlayer-playerInfo.yes'} end
|
||||
frame.add{type='label',caption={'ExpGamingPlayer-playerInfo.admin',_admin}}
|
||||
if Role then
|
||||
frame.add{type='label',caption={'ExpGamingPlayer-playerInfo.group',_player.group}}
|
||||
frame.add{type='label',caption={'ExpGamingPlayer-playerInfo.role',_player.highest_role}}
|
||||
frame.add{type='label',caption={'ExpGamingPlayer-playerInfo.roles',table.concat(_player.roles,', ')}}.style.single_line = false
|
||||
end
|
||||
if add_cam then
|
||||
Gui.cam_link{entity=player.character,frame=frame,width=200,height=150,zoom=0.5,respawn_open=true}
|
||||
end
|
||||
end
|
||||
return _player
|
||||
end
|
||||
|
||||
return setmetatable({
|
||||
get_player_info=get_player_info,
|
||||
on_init=function(self)
|
||||
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,...) return self.get_player_info(...) end
|
||||
})
|
||||
8
old/modules/ExpGamingPlayer/playerInfo/locale/de.cfg
Normal file
8
old/modules/ExpGamingPlayer/playerInfo/locale/de.cfg
Normal file
@@ -0,0 +1,8 @@
|
||||
[ExpGamingPlayer-playerInfo]
|
||||
yes=Ja
|
||||
no=Nein
|
||||
name=[__1__] __2__
|
||||
online=Ist online: __1__ (__2__)
|
||||
admin=Hat Admin Rang: __1__
|
||||
group=In Benutzer Gruppe: __1__
|
||||
role=Hat Rang: __1__
|
||||
9
old/modules/ExpGamingPlayer/playerInfo/locale/en.cfg
Normal file
9
old/modules/ExpGamingPlayer/playerInfo/locale/en.cfg
Normal file
@@ -0,0 +1,9 @@
|
||||
[ExpGamingPlayer-playerInfo]
|
||||
yes=Yes
|
||||
no=No
|
||||
name=[__1__] __2__
|
||||
online=Is Online: __1__ (__2__)
|
||||
admin=Has Admin: __1__
|
||||
group=In User Group: __1__
|
||||
role=Highest Role: __1__
|
||||
roles=Other Roles: __1__
|
||||
8
old/modules/ExpGamingPlayer/playerInfo/locale/fr.cfg
Normal file
8
old/modules/ExpGamingPlayer/playerInfo/locale/fr.cfg
Normal file
@@ -0,0 +1,8 @@
|
||||
[ExpGamingPlayer-playerInfo]
|
||||
yes=Yes
|
||||
no=No
|
||||
name=[__1__] __2__
|
||||
online=Is Online: __1__ (__2__)
|
||||
admin=Has Admin: __1__
|
||||
group=In User Group: __1__
|
||||
role=Has Rank: __1__
|
||||
8
old/modules/ExpGamingPlayer/playerInfo/locale/nl.cfg
Normal file
8
old/modules/ExpGamingPlayer/playerInfo/locale/nl.cfg
Normal file
@@ -0,0 +1,8 @@
|
||||
[ExpGamingPlayer-playerInfo]
|
||||
yes=Ja
|
||||
no=Nee
|
||||
name=[__1__] __2__
|
||||
online=Is Online: __1__ (__2__)
|
||||
admin=Heeft Admin: __1__
|
||||
group=In Groep: __1__
|
||||
role=Heeft Rank: __1__
|
||||
8
old/modules/ExpGamingPlayer/playerInfo/locale/sv-SE.cfg
Normal file
8
old/modules/ExpGamingPlayer/playerInfo/locale/sv-SE.cfg
Normal file
@@ -0,0 +1,8 @@
|
||||
[ExpGamingPlayer-playerInfo]
|
||||
yes=Ja
|
||||
no=Nej
|
||||
name=[__1__] __2__
|
||||
online=Är Online: __1__ (__2__)
|
||||
admin=Har Admin: __1__
|
||||
group=I användargrupp: __1__
|
||||
role=Har rang: __1__
|
||||
21
old/modules/ExpGamingPlayer/playerInfo/softmod.json
Normal file
21
old/modules/ExpGamingPlayer/playerInfo/softmod.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "ExpGamingPlayer.playerInfo",
|
||||
"version": "4.0.0",
|
||||
"description": "Used to give so common info on a player as a lua table or a frame.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Cam",
|
||||
"Follow",
|
||||
"Player",
|
||||
"Info",
|
||||
"Useful"
|
||||
],
|
||||
"dependencies": {
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingCore.Gui": "^4.0.0",
|
||||
"ExpGamingCore.Role": "?^4.0.0",
|
||||
"ExpGamingCore.Group": "?^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingPlayer@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
145
old/modules/ExpGamingPlayer/playerList/control.lua
Normal file
145
old/modules/ExpGamingPlayer/playerList/control.lua
Normal file
@@ -0,0 +1,145 @@
|
||||
--- A full ranking system for factorio.
|
||||
-- @module ExpGamingPlayer.playerList@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Gui = require('ExpGamingCore.Gui')
|
||||
local Admin -- ExpGamingAdmin@^4.0.0
|
||||
local AdminGui -- ExpGamingAdmin.Gui@^4.0.0
|
||||
|
||||
-- Local Variables
|
||||
local playerInfo = function(player,frame)
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'ExpGamingPlayer-playerList.no-info-file'}
|
||||
}
|
||||
end
|
||||
|
||||
local getPlayers = function()
|
||||
local rtn = {{{r=233,g=63,b=233},'Admin',{},true},{{r=255,g=159,b=27},'',{},false}}
|
||||
for _,player in pairs(game.connected_players) do
|
||||
if player.admin then table.insert(rtn[2][3],player)
|
||||
else table.insert(rtn[1][3],player) end
|
||||
end
|
||||
return rtn
|
||||
end
|
||||
|
||||
-- Module Define
|
||||
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.Role'] then getPlayers = require(module_path..'/src/ranking',{self=self}) end
|
||||
if loaded_modules['ExpGamingAdmin'] then Admin = require('ExpGamingAdmin') end
|
||||
if loaded_modules['ExpGamingAdmin.Gui'] then AdminGui = require('ExpGamingAdmin.Gui') end
|
||||
end
|
||||
}
|
||||
|
||||
-- Global Define
|
||||
local global = {
|
||||
update=0,
|
||||
delay=10,
|
||||
interval=54000
|
||||
}
|
||||
Global.register(global,function(tbl) global = tbl end)
|
||||
|
||||
function ThisModule.update(tick)
|
||||
local tick = is_type(tick,'table') and tick.tick or is_type(tick,'number') and tick or game.tick
|
||||
if tick + global.delay > global.update - global.interval then
|
||||
global.update = tick + global.delay
|
||||
end
|
||||
end
|
||||
|
||||
local back_btn = Gui.inputs{
|
||||
type='button',
|
||||
caption='utility/enter',
|
||||
name='player-list-back'
|
||||
}:on_event('click',function(event)
|
||||
event.element.parent.parent.scroll.style.visible = true
|
||||
event.element.parent.destroy()
|
||||
end)
|
||||
|
||||
ThisModule.Gui = Gui.left{
|
||||
name='player-list',
|
||||
caption='entity/player',
|
||||
tooltip={'ExpGamingPlayer-playerList.tooltip'},
|
||||
draw=function(self,frame)
|
||||
frame.caption = ''
|
||||
local player_list = frame.add{
|
||||
name='scroll',
|
||||
type = 'scroll-pane',
|
||||
direction = 'vertical',
|
||||
vertical_scroll_policy='auto',
|
||||
horizontal_scroll_policy='never'
|
||||
}
|
||||
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
|
||||
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(flow)
|
||||
btn.style.height = 20
|
||||
btn.style.width = 20
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
open_on_join=true
|
||||
}
|
||||
|
||||
Event.add(defines.events.on_tick,function(event)
|
||||
if event.tick > global.update then
|
||||
ThisModule.Gui()
|
||||
global.update = event.tick + global.interval
|
||||
end
|
||||
end)
|
||||
|
||||
Event.add(defines.events.on_gui_click,function(event)
|
||||
-- lots of checks for it being valid
|
||||
if event.element and event.element.valid
|
||||
and event.element.parent and event.element.parent.parent and event.element.parent.parent.parent
|
||||
and event.element.parent.parent.parent.name == 'player-list' then else return end
|
||||
-- must be a right click
|
||||
if event.button == defines.mouse_button_type.right then else return end
|
||||
local player_list = event.element.parent.parent.parent
|
||||
-- must be a valid player which is clicked
|
||||
if not Game.get_player(event.element.name) then return end
|
||||
-- hides the player list to show the info
|
||||
player_list.scroll.style.visible = false
|
||||
local flow = player_list.add{type='flow',direction='vertical'}
|
||||
back_btn:draw(flow)
|
||||
playerInfo(event.element.name,flow,true)
|
||||
if Game.get_player(event.element.name) and event.player_index == Game.get_player(event.element.name).index then return end
|
||||
if Admin and AdminGui and Admin.allowed(event.player_index) then AdminGui(flow).caption = event.element.name end
|
||||
end)
|
||||
|
||||
Event.add(defines.events.on_player_joined_game,function() ThisModule.update() end)
|
||||
Event.add(defines.events.on_player_left_game,function() ThisModule.update() end)
|
||||
|
||||
ThisModule.force_update = function() return ThisModule.Gui() end
|
||||
-- when called it will queue an update to the player list
|
||||
return setmetatable(ThisModule,{__call=function(self,...) self.update(...) end})
|
||||
5
old/modules/ExpGamingPlayer/playerList/locale/de.cfg
Normal file
5
old/modules/ExpGamingPlayer/playerList/locale/de.cfg
Normal file
@@ -0,0 +1,5 @@
|
||||
[ExpGamingPlayer-playerList]
|
||||
tooltip=Verkleinere die Spielerliste. Rechtsklicke einen Spieler für Informationen über ihn.
|
||||
format-nil=__1__ - __2__
|
||||
format=__1__ - __2__ - __3__
|
||||
no-info-file=Es wurden keine Informationen gefunden.
|
||||
5
old/modules/ExpGamingPlayer/playerList/locale/en.cfg
Normal file
5
old/modules/ExpGamingPlayer/playerList/locale/en.cfg
Normal file
@@ -0,0 +1,5 @@
|
||||
[ExpGamingPlayer-playerList]
|
||||
tooltip=Toggle player list, right click player for more info
|
||||
format-nil=__1__ - __2__
|
||||
format=__1__ - __2__ - __3__
|
||||
no-info-file=No info file was found
|
||||
5
old/modules/ExpGamingPlayer/playerList/locale/fr.cfg
Normal file
5
old/modules/ExpGamingPlayer/playerList/locale/fr.cfg
Normal file
@@ -0,0 +1,5 @@
|
||||
[ExpGamingPlayer-playerList]
|
||||
tooltip=Toogle player list, right click player for info
|
||||
format-nil=__1__ - __2__
|
||||
format=__1__ - __2__ - __3__
|
||||
no-info-file=No info file was found
|
||||
5
old/modules/ExpGamingPlayer/playerList/locale/nl.cfg
Normal file
5
old/modules/ExpGamingPlayer/playerList/locale/nl.cfg
Normal file
@@ -0,0 +1,5 @@
|
||||
[ExpGamingPlayer-playerList]
|
||||
tooltip=Toggle speler lijst. Rechtermuisklik op een speler voor meer info
|
||||
format-nil=__1__ - __2__
|
||||
format=__1__ - __2__ - __3__
|
||||
no-info-file=Geen infobestand gevonden.
|
||||
5
old/modules/ExpGamingPlayer/playerList/locale/sv-SE.cfg
Normal file
5
old/modules/ExpGamingPlayer/playerList/locale/sv-SE.cfg
Normal file
@@ -0,0 +1,5 @@
|
||||
[ExpGamingPlayer-playerList]
|
||||
tooltip=Växla spelarlista, högerklicka på spelare för mer information.
|
||||
format-nil=__1__ - __2__
|
||||
format=__1__ - __2__ - __3__
|
||||
no-info-file=Ingen informationsfil kunde hittas
|
||||
24
old/modules/ExpGamingPlayer/playerList/softmod.json
Normal file
24
old/modules/ExpGamingPlayer/playerList/softmod.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "ExpGamingPlayer.playerList",
|
||||
"version": "4.0.0",
|
||||
"description": "Used to display player names and online time on the top left.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Player List",
|
||||
"List",
|
||||
"Gui",
|
||||
"Names"
|
||||
],
|
||||
"dependencies": {
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingCore.Gui": "^4.0.0",
|
||||
"ExpGamingCore.Role": "?^4.0.0",
|
||||
"ExpGamingAdmin": "?^4.0.0",
|
||||
"ExpGamingAdmin.buttonFlow": "?^4.0.0",
|
||||
"ExpGamingAdmin.reports": "?^4.0.0",
|
||||
"ExpGamingPlayer.playerInfo": "?^4.0.0",
|
||||
"ExpGamingAdmin.Gui": "?^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingPlayer@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
15
old/modules/ExpGamingPlayer/playerList/src/ranking.lua
Normal file
15
old/modules/ExpGamingPlayer/playerList/src/ranking.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
local Role = require('ExpGamingCore.Role')
|
||||
|
||||
Event.add(defines.events.on_role_change,self.update)
|
||||
|
||||
return function()
|
||||
local rtn = {}
|
||||
local default = {}
|
||||
for _,role_name in pairs(Role.order) do
|
||||
local role = Role.get(role_name,true)
|
||||
if role.is_default then default = {role.colour,role.short_hand,role:get_players(true),role.not_reportable}
|
||||
else table.insert(rtn,{role.colour,role.short_hand,role:get_players(true),role.not_reportable}) end
|
||||
end
|
||||
table.insert(rtn,default)
|
||||
return rtn
|
||||
end
|
||||
274
old/modules/ExpGamingPlayer/polls/control.lua
Normal file
274
old/modules/ExpGamingPlayer/polls/control.lua
Normal file
@@ -0,0 +1,274 @@
|
||||
--- Adds a poll gui into the game for quick polls (default 90 seconds)
|
||||
-- @module ExpGamingPlayer.polls@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
-- Module Require
|
||||
local Server = require('ExpGamingCore.Server')
|
||||
local Gui = require('ExpGamingCore.Gui')
|
||||
local Role -- ExpGamingCore.Server@^4.0.0
|
||||
|
||||
-- Local Variables
|
||||
local poll_time_out = 90 -- In seconds
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
|
||||
end
|
||||
}
|
||||
|
||||
-- Global Define
|
||||
local global = {
|
||||
active={},
|
||||
old={}
|
||||
}
|
||||
Global.register(global,function(tbl) global = tbl end)
|
||||
|
||||
-- Function Define
|
||||
local function _poll_data(question,answers)
|
||||
local rtn_poll = {
|
||||
uuid=Server.uuid(),
|
||||
question=question,
|
||||
answers=answers or {'None'},
|
||||
votes={},
|
||||
voted={}
|
||||
}
|
||||
Server.new_thread{
|
||||
data={poll_uuid=rtn_poll.uuid},
|
||||
timeout=poll_time_out*60
|
||||
}:on_event('timeout',function(self)
|
||||
local uuid = tostring(self.data.poll_uuid)
|
||||
local poll = global.active[uuid]
|
||||
if not poll then return end
|
||||
local highest = {nil,-1}
|
||||
local _votes = {}
|
||||
for index,answer in pairs(poll.answers) do
|
||||
local _result = poll.votes[index] or 0
|
||||
if _result > highest[2] then highest = {answer,_result} end
|
||||
_votes[answer] = _result
|
||||
end
|
||||
poll.uuid = nil
|
||||
poll.votes = _votes
|
||||
poll.answers = nil
|
||||
poll.voted = nil
|
||||
table.insert(global.old,poll)
|
||||
global.active[uuid] = nil
|
||||
game.print({'ExpGamingPlayer-polls.end',poll.question},defines.textcolor.info)
|
||||
game.print({'ExpGamingPlayer-polls.winner',highest[1]},defines.textcolor.info)
|
||||
verbose('Ended Poll: '..poll.question..' ('..uuid..') Highest: '..highest[1])
|
||||
end):open()
|
||||
global.active[tostring(rtn_poll.uuid)]=rtn_poll
|
||||
verbose('Created Poll: '..question..' ('..rtn_poll.uuid..')')
|
||||
return rtn_poll.uuid
|
||||
end
|
||||
|
||||
local function draw_poll(frame)
|
||||
frame.clear()
|
||||
local index = tonumber(frame.parent.current_index.caption)
|
||||
local poll = global.old[index]
|
||||
if not poll then
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'ExpGamingPlayer-polls.no-poll'}
|
||||
}
|
||||
return
|
||||
end
|
||||
frame.add{
|
||||
type='label',
|
||||
caption='Question: '..poll.question
|
||||
}
|
||||
for answer,votes in pairs(poll.votes) do
|
||||
frame.add{
|
||||
type='label',
|
||||
caption=answer..') '..votes
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
local function _options(player,root_frame)
|
||||
local options = {'Please Select An option'}
|
||||
local uuid = root_frame.name
|
||||
local poll = global.active[uuid]
|
||||
if not poll then return {'Invalid Poll'} end
|
||||
for _,answer in pairs(poll.answers) do
|
||||
table.insert(options,answer)
|
||||
end
|
||||
return options
|
||||
end
|
||||
|
||||
local option_drop_down = Gui.inputs.add_drop_down('option-drop-down-polls',_options,1,function(player,selected,items,element)
|
||||
local uuid = element.parent.name
|
||||
local poll = global.active[uuid]
|
||||
if not poll then return end
|
||||
if poll.voted[player.index] and poll.voted[player.index] > 1 then
|
||||
local old_vote = poll.voted[player.index]
|
||||
poll.votes[old_vote-1] = poll.votes[old_vote-1] and poll.votes[old_vote-1]-1 or 0
|
||||
end
|
||||
if element.selected_index > 1 then
|
||||
poll.votes[element.selected_index-1] = poll.votes[element.selected_index-1] and poll.votes[element.selected_index-1]+1 or 1
|
||||
end
|
||||
poll.voted[player.index]=element.selected_index
|
||||
element.parent.answer.caption = 'Your Answer: '..selected
|
||||
end)
|
||||
|
||||
local prev = Gui.inputs{
|
||||
type='button',
|
||||
name='prev-poll',
|
||||
caption='utility/hint_arrow_left'
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
local index = parent.parent.current_index.caption
|
||||
local _index = tonumber(index)-1
|
||||
if _index < 1 then _index = #global.old end
|
||||
parent.parent.current_index.caption = _index
|
||||
parent.parent.title.title.caption = 'Viewing Poll: '.._index
|
||||
draw_poll(parent.parent.poll_area)
|
||||
end)
|
||||
|
||||
local next = Gui.inputs{
|
||||
type='button',
|
||||
name='next-poll',
|
||||
caption='utility/hint_arrow_right'
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
local index = parent.parent.current_index.caption
|
||||
local _index = tonumber(index)+1
|
||||
if _index > #global.old then _index = 1 end
|
||||
parent.parent.current_index.caption = _index
|
||||
parent.parent.title.title.caption = 'Viewing Poll: '.._index
|
||||
draw_poll(parent.parent.poll_area)
|
||||
end)
|
||||
|
||||
local poll_question_input = Gui.inputs.add_text('poll-question-input',true,'Question',function(player,text,element)
|
||||
local options = element.parent.options
|
||||
if not options.question then options.add{type='label',name='question',caption=''}
|
||||
else options.question.caption = text end
|
||||
end)
|
||||
|
||||
local _self_reference_poll_option_input = nil
|
||||
local poll_option_input = Gui.inputs.add_text('poll-option-input',true,'Enter Option',function(player,text,element)
|
||||
local options = element.parent.parent.parent.options
|
||||
if not options[element.parent.name] then options.add{type='label',name=element.parent.name,caption=text}
|
||||
else options[element.parent.name].caption = text end
|
||||
if options.last.caption == element.parent.name then
|
||||
options.last.caption = tonumber(options.last.caption)+1
|
||||
_self_reference_poll_option_input(element.parent.parent.add{type='flow',name=options.last.caption}).style.minimal_width = 200
|
||||
end
|
||||
end)
|
||||
_self_reference_poll_option_input = poll_option_input
|
||||
|
||||
local function poll_assembler(frame)
|
||||
frame.clear()
|
||||
local options = frame.add{type='flow',name='options'}
|
||||
options.style.visible = false
|
||||
options.add{type='label',name='last',caption='2'}
|
||||
poll_question_input(frame).style.minimal_width = 200
|
||||
local flow = frame.add{type='flow',direction='vertical'}
|
||||
poll_option_input(flow.add{type='flow',name='1'}).style.minimal_width = 200
|
||||
poll_option_input(flow.add{type='flow',name='2'}).style.minimal_width = 200
|
||||
end
|
||||
|
||||
local create_poll = Gui.inputs{
|
||||
type='button',
|
||||
name='create-poll',
|
||||
caption='utility/add'
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
if event.element.sprite == 'utility/enter' then
|
||||
local inputs = parent.parent.poll_area.options
|
||||
if not inputs then
|
||||
event.element.sprite = 'utility/add'
|
||||
draw_poll(parent.parent.poll_area)
|
||||
return
|
||||
end
|
||||
local options = {}
|
||||
for _,option in pairs(inputs.children) do
|
||||
if option.name ~= 'question' and option.name ~= 'last' then
|
||||
if option.caption ~= 'Enter Option' and option.caption ~= '' then table.insert(options,option.caption) end
|
||||
end
|
||||
end
|
||||
if not inputs.question or #options == 0 then
|
||||
event.element.sprite = 'utility/add'
|
||||
draw_poll(parent.parent.poll_area)
|
||||
return
|
||||
end
|
||||
local uuid = _poll_data(inputs.question.caption,options)
|
||||
Gui.popup.open('polls',{uuid=uuid})
|
||||
event.element.sprite = 'utility/add'
|
||||
draw_poll(parent.parent.poll_area)
|
||||
else
|
||||
event.element.sprite = 'utility/enter'
|
||||
poll_assembler(parent.parent.poll_area)
|
||||
end
|
||||
end)
|
||||
|
||||
ThisModule.Gui = Gui.popup{
|
||||
name='polls',
|
||||
caption={'ExpGamingPlayer-polls.name'},
|
||||
draw=function(self,frame,data)
|
||||
frame.style.right_padding = 5
|
||||
frame.style.bottom_padding = 5
|
||||
local uuid = data.uuid
|
||||
local poll = global.active[tostring(uuid)]
|
||||
if not poll then return end
|
||||
local flow = frame.add{
|
||||
type='flow',
|
||||
name=tostring(uuid),
|
||||
direction='vertical'
|
||||
}
|
||||
flow.add{type='label',caption={'ExpGamingPlayer-polls.time-left',poll_time_out}}
|
||||
flow.add{type='label',caption='Question: '..poll.question}
|
||||
flow.add{type='label',name='answer',caption='Your Answer: None'}
|
||||
option_drop_down(flow)
|
||||
end
|
||||
}:add_left{
|
||||
caption='utility/item_editor_icon',
|
||||
tooltip={'ExpGamingPlayer-polls.tooltip'},
|
||||
draw=function(self,frame)
|
||||
frame.caption={'ExpGamingPlayer-polls.name'}
|
||||
frame.add{
|
||||
type='label',
|
||||
name='current_index',
|
||||
caption=1
|
||||
}.style.visible = false
|
||||
local title = frame.add{
|
||||
type='flow',
|
||||
name='title'
|
||||
}
|
||||
local btn = prev:draw(title)
|
||||
btn.style.width = 20
|
||||
btn.style.height = 20
|
||||
title.add{
|
||||
type='label',
|
||||
name='title',
|
||||
caption='Viewing Poll: 1',
|
||||
style='caption_label'
|
||||
}
|
||||
btn = next:draw(title)
|
||||
btn.style.width = 20
|
||||
btn.style.height = 20
|
||||
if Role and Role.allowed(frame.player_index,'create-poll') or game.players[frame.player_index].admin then
|
||||
btn = create_poll:draw(title)
|
||||
btn.style.width = 20
|
||||
btn.style.height = 20
|
||||
end
|
||||
local flow = frame.add{
|
||||
type='flow',
|
||||
name='poll_area',
|
||||
direction='vertical'
|
||||
}
|
||||
draw_poll(flow)
|
||||
end,
|
||||
can_open=function(player)
|
||||
if #global.old > 0 then return true
|
||||
elseif Role and Role.allowed(player,'create-poll') or player.admin then return true
|
||||
else return {'ExpGamingPlayer-polls.no-poll'} end
|
||||
end
|
||||
}
|
||||
-- Event Handlers Define
|
||||
|
||||
-- Module Return
|
||||
-- when called it will toggle the left gui for this player
|
||||
return setmetatable(ThisModule,{__call=function(self,...) self.Gui(...) end})
|
||||
7
old/modules/ExpGamingPlayer/polls/locale/de.cfg
Normal file
7
old/modules/ExpGamingPlayer/polls/locale/de.cfg
Normal file
@@ -0,0 +1,7 @@
|
||||
[ExpGamingPlayer-polls]
|
||||
name=Umfragen
|
||||
tooltip=Alte Umfragen ansehen
|
||||
no-poll=Keine alten Umfragen
|
||||
end=Die Umfrage hat gerade geendet: __1__
|
||||
winner=__1__ hatte die meisten Stimmen.
|
||||
time-left=Du hast noch __1__s um deine Wahl zu erfassen.
|
||||
7
old/modules/ExpGamingPlayer/polls/locale/en.cfg
Normal file
7
old/modules/ExpGamingPlayer/polls/locale/en.cfg
Normal file
@@ -0,0 +1,7 @@
|
||||
[ExpGamingPlayer-polls]
|
||||
name=Polls
|
||||
tooltip=View Old Polls
|
||||
no-poll=No Old Polls
|
||||
end=Poll Just Ended: __1__
|
||||
winner=__1__ had the most votes.
|
||||
time-left=You will have __1__s to pick.
|
||||
7
old/modules/ExpGamingPlayer/polls/locale/fr.cfg
Normal file
7
old/modules/ExpGamingPlayer/polls/locale/fr.cfg
Normal file
@@ -0,0 +1,7 @@
|
||||
[ExpGamingPlayer-polls]
|
||||
name=Polls
|
||||
tooltip=View Old Polls
|
||||
no-poll=No Old Polls
|
||||
end=Poll Just Ended: __1__
|
||||
winner=__1__ had the most votes.
|
||||
time-left=You will have __1__s to pick.
|
||||
7
old/modules/ExpGamingPlayer/polls/locale/nl.cfg
Normal file
7
old/modules/ExpGamingPlayer/polls/locale/nl.cfg
Normal file
@@ -0,0 +1,7 @@
|
||||
[ExpGamingPlayer-polls]
|
||||
name=Polls
|
||||
tooltip=Laat oude polls zien
|
||||
no-poll=Geen oude polls
|
||||
end=Poll is zojuist beëindigd: __1__
|
||||
winner=__1__ had de meeste stemmen.
|
||||
time-left=Je hebt __1__s om te kiezen.
|
||||
7
old/modules/ExpGamingPlayer/polls/locale/sv-SE.cfg
Normal file
7
old/modules/ExpGamingPlayer/polls/locale/sv-SE.cfg
Normal file
@@ -0,0 +1,7 @@
|
||||
[ExpGamingPlayer-polls]
|
||||
name=Undersökningar
|
||||
tooltip=Se gamla undersökningar
|
||||
no-poll=Inga gamla undersökningar
|
||||
end=Röstning slutade nyss: __1__
|
||||
winner=__1__ hade flest röster.
|
||||
time-left=Du kommer att få __1__s på dig att välja.
|
||||
19
old/modules/ExpGamingPlayer/polls/softmod.json
Normal file
19
old/modules/ExpGamingPlayer/polls/softmod.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "ExpGamingPlayer.polls",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a poll gui into the game for quick polls (default 90 seconds)",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Polls",
|
||||
"Poll",
|
||||
"Question",
|
||||
"Gui"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Gui": "^4.0.0",
|
||||
"ExpGamingCore.Server": "^4.0.0",
|
||||
"ExpGamingCore.Role": "?^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingPlayer@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
23
old/modules/ExpGamingPlayer/softmod.json
Normal file
23
old/modules/ExpGamingPlayer/softmod.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "ExpGamingPlayer",
|
||||
"version": "4.0.0",
|
||||
"description": "Useful collection of modules for displaying player infomation.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"ExpGaming",
|
||||
"Player",
|
||||
"Information",
|
||||
"AFK"
|
||||
],
|
||||
"author": "Cooldude2606",
|
||||
"contact": "Discord: Cooldude2606#5241",
|
||||
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
|
||||
"submodules": {
|
||||
"ExpGamingPlayer.afkKick": "4.0.0",
|
||||
"ExpGamingPlayer.playerInfo": "4.0.0",
|
||||
"ExpGamingPlayer.playerList": "4.0.0",
|
||||
"ExpGamingPlayer.inventorySearch": "4.0.0",
|
||||
"ExpGamingPlayer.polls": "4.0.0"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
Reference in New Issue
Block a user