mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-29 20:16:38 +09:00
Eddit To ExpGamingCore.Gui and Added ExpGamingPlayer.Polls
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
--- A full ranking system for factorio.
|
||||
-- @module ExpGamingPlayer.playerInfo
|
||||
-- @module ExpGamingPlayer.afkKick@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 -- hanndled on load
|
||||
local Sync -- hanndled on load
|
||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||
local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
||||
local Role -- ExpGamingCore.Role@^4.0.0
|
||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||
|
||||
function get_allowed_afk_time(player)
|
||||
local function get_allowed_afk_time(player)
|
||||
local role
|
||||
if Role then role = Role.get_highest(player)
|
||||
else if player.admin then return else rank = Role.meta.default end end
|
||||
else if player.admin then return else role = Role.meta.default end end
|
||||
local count = #game.connected_players
|
||||
local base = role.index or false
|
||||
if not base then return false end
|
||||
return (10/base)*count
|
||||
return (Role.meta.count/base)*count
|
||||
end
|
||||
|
||||
script.on_event(defines.events.on_tick,function(event)
|
||||
@@ -28,11 +28,11 @@ script.on_event(defines.events.on_tick,function(event)
|
||||
end
|
||||
end)
|
||||
|
||||
return {
|
||||
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) 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.Server@^4.0.0'] then require(module_path..'/src/server',Sync,self) end
|
||||
end
|
||||
}
|
||||
},{__call=function(self,...) self.get_allowed_afk_time(...) end})
|
||||
@@ -1,4 +1,5 @@
|
||||
local Sync = Sync
|
||||
local get_allowed_afk_time = self
|
||||
local Server = require('ExpGamingCore.Server@^4.0.0')
|
||||
Event[defines.events.on_tick] = nil
|
||||
script.on_init(function(event)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- Desction <get from json>
|
||||
-- @module ThisModule@X.Y.Z
|
||||
-- @author <get from json>
|
||||
-- @license <get from json>
|
||||
--- Adds an inventory search that is proformed on a random player every 15 seconds
|
||||
-- @module ExpGamingPlayer.inventorySearch@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alais ThisModule
|
||||
|
||||
-- Module Require
|
||||
@@ -54,9 +54,9 @@ local ThisModule = {
|
||||
|
||||
-- Function Define
|
||||
local function take_action(player,item_name,category)
|
||||
if category == 'low_items' then player_return({'inventory-search.low',item_name},defines.textcolor.med,player)
|
||||
elseif category == 'med_items' then player_return({'inventory-search.med',item_name},defines.textcolor.high,player) Admin.give_warning(player,'<server>','Found A Banned Item',5)
|
||||
elseif category == 'high_items' then player_return({'inventory-search.high',item_name},defines.textcolor.crit,player) Admin.temp_ban(player,'<server>','Found A Banned Item')
|
||||
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
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
--- A full ranking system for factorio.
|
||||
-- @module ExpGamingPlayer.playerInfo
|
||||
--- 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 -- hanndled on load
|
||||
local Group -- hanndled on load
|
||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||
local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
||||
local Role -- ExpGamingCore.Role@^4.0.0
|
||||
local Group -- ExpGamingCore.Group@^4.0.0
|
||||
|
||||
local function get_player_info(player,frame,add_cam)
|
||||
local player = Game.get_player(player)
|
||||
@@ -30,15 +30,15 @@ local function get_player_info(player,frame,add_cam)
|
||||
frame.style.width = 200
|
||||
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}}
|
||||
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={'player-info.group',_player.group}}
|
||||
frame.add{type='label',caption={'player-info.role',_player.highest_role}}
|
||||
frame.add{type='label',caption={'player-info.roles',table.concat(_player.roles,', ')}}
|
||||
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,', ')}}
|
||||
end
|
||||
if add_cam then
|
||||
Gui.cam_link{entity=player.character,frame=frame,width=200,height=150,zoom=0.5,respawn_open=true}
|
||||
@@ -50,8 +50,8 @@ 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
|
||||
if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end
|
||||
if loaded_modules['ExpGamingCore.Group@^4.0.0'] then Group = require('ExpGamingCore.Group@^4.0.0') end
|
||||
end
|
||||
},{
|
||||
__call=function(self,...) self.get_player_info(...) end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
--- A full ranking system for factorio.
|
||||
-- @module ExpGamingPlayer.playerList
|
||||
-- @module ExpGamingPlayer.playerList@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
|
||||
@@ -1,24 +1,34 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
--- 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
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
-- Module Require
|
||||
local Server = require('ExpGamingCore.Server@^4.0.0')
|
||||
local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
||||
local Role -- ExpGamingCore.Server@^4.0.0
|
||||
|
||||
-- Local Varibles
|
||||
local poll_time_out = 90 -- In seconds
|
||||
|
||||
local function _polls(reset)
|
||||
global.addons = not reset and global.addons or {}
|
||||
global.addons.polls = not reset and global.addons.polls or {active={},old={}}
|
||||
return global.addons.polls
|
||||
end
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Server@^4.0.0'] then Role = require('ExpGamingCore.Server@^4.0.0') end
|
||||
end
|
||||
}
|
||||
|
||||
function _poll_end(self)
|
||||
-- Global Define
|
||||
local global = global{
|
||||
active={},
|
||||
old={}
|
||||
}
|
||||
|
||||
-- Function Define
|
||||
local function _poll_end(self)
|
||||
local uuid = self.data.poll_uuid
|
||||
local poll = _polls().active[uuid]
|
||||
local poll = global.active[uuid]
|
||||
if not poll then return end
|
||||
local highest = {nil,-1}
|
||||
local _votes = {}
|
||||
@@ -32,15 +42,15 @@ function _poll_end(self)
|
||||
poll.votes = _votes
|
||||
poll.answers = nil
|
||||
poll.voted = nil
|
||||
table.insert(_polls().old,poll)
|
||||
_polls().active[uuid] = nil
|
||||
table.insert(global.old,poll)
|
||||
global.active[uuid] = nil
|
||||
game.print({'polls.end',poll.question},defines.textcolor.info)
|
||||
game.print({'polls.winner',highest[1]},defines.textcolor.info)
|
||||
end
|
||||
|
||||
local function _poll_data(question,answers)
|
||||
local poll = {
|
||||
uuid=Server.new_uuid(),
|
||||
uuid=Server.uuid(),
|
||||
question=question,
|
||||
answers=answers or {'None'},
|
||||
votes={},
|
||||
@@ -51,37 +61,14 @@ local function _poll_data(question,answers)
|
||||
timeout=poll_time_out*60
|
||||
}:on_event('timeout',_poll_end):open()
|
||||
-- This time out is known to cause desyncs and so I have moved it to a hard coded function
|
||||
_polls().active[poll.uuid]=poll
|
||||
global.active[poll.uuid]=poll
|
||||
return poll.uuid
|
||||
end
|
||||
|
||||
local function draw_poll(frame)
|
||||
frame.clear()
|
||||
local index = tonumber(frame.parent.current_index.caption)
|
||||
local poll = _polls().old[index]
|
||||
if not poll then
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'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 _opptions(player,root_frame)
|
||||
local opptions = {'Please Select An Opption'}
|
||||
local uuid = root_frame.name
|
||||
local poll = _polls().active[uuid]
|
||||
local poll = global.active[uuid]
|
||||
if not poll then return {'Invalid Poll'} end
|
||||
for _,answer in pairs(poll.answers) do
|
||||
table.insert(opptions,answer)
|
||||
@@ -91,7 +78,7 @@ end
|
||||
|
||||
local opption_drop_down = Gui.inputs.add_drop_down('opption-drop-down-polls',_opptions,1,function(player,selected,items,element)
|
||||
local uuid = element.parent.name
|
||||
local poll = _polls().active[uuid]
|
||||
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]
|
||||
@@ -112,7 +99,7 @@ local prev = Gui.inputs.add{
|
||||
local parent = event.element.parent
|
||||
local index = parent.parent.current_index.caption
|
||||
local _index = tonumber(index)-1
|
||||
if _index < 1 then _index = #_polls().old end
|
||||
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)
|
||||
@@ -126,7 +113,7 @@ local next = Gui.inputs.add{
|
||||
local parent = event.element.parent
|
||||
local index = parent.parent.current_index.caption
|
||||
local _index = tonumber(index)+1
|
||||
if _index > #_polls().old then _index = 1 end
|
||||
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)
|
||||
@@ -202,7 +189,7 @@ Gui.popup.add{
|
||||
frame.style.right_padding = 5
|
||||
frame.style.bottom_padding = 5
|
||||
local uuid = data.uuid
|
||||
local poll = _polls().active[uuid]
|
||||
local poll = global.active[uuid]
|
||||
if not poll then return end
|
||||
local flow = frame.add{
|
||||
type='flow',
|
||||
@@ -240,7 +227,7 @@ Gui.popup.add{
|
||||
local btn = next:draw(title)
|
||||
btn.style.width = 20
|
||||
btn.style.height = 20
|
||||
if Role.get_highest(frame.player_index):allowed('create-poll') then
|
||||
if Role and Role.get_highest(frame.player_index):allowed('create-poll') or player.admin then
|
||||
local btn = create_poll:draw(title)
|
||||
btn.style.width = 20
|
||||
btn.style.height = 20
|
||||
@@ -253,8 +240,12 @@ Gui.popup.add{
|
||||
draw_poll(flow)
|
||||
end,
|
||||
can_open=function(player)
|
||||
if #_polls().old > 0 then return true
|
||||
elseif Role.allowed(player,'create-poll') then return true
|
||||
if #global.old > 0 then return true
|
||||
elseif Role and Role.allowed(player,'create-poll') or player.admin then return true
|
||||
else return {'polls.no-poll'} end
|
||||
end
|
||||
}
|
||||
-- Event Handlers Define
|
||||
|
||||
-- Module Return
|
||||
return ThisModule
|
||||
19
modules/ExpGamingPlayer/polls/softmod.json
Normal file
19
modules/ExpGamingPlayer/polls/softmod.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "polls",
|
||||
"version": "4.0.0",
|
||||
"type": "Submodule",
|
||||
"description": "Adds a poll gui into the game for quick polls (default 90 seconds)",
|
||||
"location": "<blank>",
|
||||
"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"
|
||||
}
|
||||
@@ -99,6 +99,25 @@
|
||||
"FactorioStdLib.Game": "^0.8.0"
|
||||
},
|
||||
"collection": "ExpGamingPlayer_4.0.0"
|
||||
},
|
||||
"polls": {
|
||||
"name": "polls",
|
||||
"version": "4.0.0",
|
||||
"type": "Submodule",
|
||||
"description": "Adds a poll gui into the game for quick polls (default 90 seconds)",
|
||||
"location": "<blank>",
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"dependencies": {}
|
||||
|
||||
Reference in New Issue
Block a user