mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 19:45:22 +09:00
Merge branch 'core' into testing
This commit is contained in:
@@ -31,6 +31,16 @@ function center.get_flow(player)
|
||||
return player.gui.center.exp_center or player.gui.center.add{name='exp_center',type='flow'}
|
||||
end
|
||||
|
||||
-- used to open any center gui
|
||||
function center.open(player,center)
|
||||
local player = Game.get_player(player)
|
||||
Gui.center.clear(player)
|
||||
Gui._get_data('center')[center].open{
|
||||
element={name=center},
|
||||
player_index=player.index
|
||||
}
|
||||
end
|
||||
|
||||
-- used to clear the center frame of the player, used mainly in script
|
||||
function center.clear(player)
|
||||
local player = Game.get_player(player)
|
||||
@@ -42,7 +52,7 @@ function center._center.open(event)
|
||||
local player = Game.get_player(event)
|
||||
local _center = Gui._get_data('center')[event.element.name]
|
||||
local center_flow = center.get_flow(player)
|
||||
if center_flow[_center.name] then center.clear(player) return end
|
||||
if center_flow[_center.name] then Gui.center.clear(player) return end
|
||||
local center_frame = center_flow.add{
|
||||
name=_center.name,
|
||||
type='frame',
|
||||
|
||||
@@ -18,8 +18,8 @@ Pass a table with the names of the objects you want and it will be return in tha
|
||||
local StdExpCoreLib = {}
|
||||
|
||||
require '/commands'
|
||||
StdExpCoreLib.Server = require '/server'
|
||||
StdExpCoreLib.Ranking = require '/ranking'
|
||||
StdExpCoreLib.Server = require '/server'
|
||||
StdExpCoreLib.Sync = require '/sync'
|
||||
StdExpCoreLib.Gui = require '/gui'
|
||||
StdExpCoreLib.Gui:_load_parts{
|
||||
|
||||
@@ -9,6 +9,7 @@ Discord: https://discord.gg/r6dC2uK
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
-- this file is used to allow easy syncing with out side programes
|
||||
local Sync = {}
|
||||
local Sync_gui_functions = {}
|
||||
|
||||
-- only used as a faster way to get to the ranking function
|
||||
function Sync.set_ranks(...)
|
||||
@@ -156,6 +157,7 @@ function Sync.info(set)
|
||||
if not global.exp_core then global.exp_core = {} end
|
||||
if not global.exp_core.sync then global.exp_core.sync = {
|
||||
server_name='Factorio Server',
|
||||
server_description='A factorio server for everyone',
|
||||
reset_time='On Demand',
|
||||
time='Day Mth 00 00:00:00 UTC Year',
|
||||
time_set={0,tick_to_display_format(0)},
|
||||
@@ -235,4 +237,77 @@ Event.register(defines.events.on_tick,function(event)
|
||||
if (event.tick%time)==0 then Sync.update() Sync.emit_data() end
|
||||
end)
|
||||
|
||||
function Sync.add_to_gui(element,...)
|
||||
if game then return end
|
||||
if is_type(element,'function') then
|
||||
table.insert(Sync_gui_functions,{'function',element,...})
|
||||
elseif is_type(element,'table') then
|
||||
if element.draw then table.insert(Sync_gui_functions,{'gui',element})
|
||||
else table.insert(Sync_gui_functions,{'table',element}) end
|
||||
else table.insert(Sync_gui_functions,{'string',element}) end
|
||||
end
|
||||
|
||||
-- Examples for Sync.add_to_gui
|
||||
Sync.add_to_gui('Welcome to the Explosive Gaming comunity! This is one of many servers which we host.')
|
||||
Sync.add_to_gui(function(player,frame)
|
||||
return 'This server will reset at: '..Sync.info().reset_time
|
||||
end)
|
||||
Sync.add_to_gui(function(player,frame)
|
||||
return 'You have been given the rank '..Ranking.get_rank(player).name..' from our Discord'
|
||||
end)
|
||||
|
||||
function Sync._load()
|
||||
Gui.center.add{
|
||||
name='server-info',
|
||||
caption='Server Info',
|
||||
tooltip='Basic info about the current server',
|
||||
draw=function(self,frame)
|
||||
frame.caption = ''
|
||||
local info = Sync.info()
|
||||
local frame = frame.add{type='flow',direction='vertical'}
|
||||
local _flow = frame.add{type='flow'}
|
||||
Gui.bar(_flow,200)
|
||||
_flow.add{
|
||||
type='label',
|
||||
caption='Welcome To '..info.server_name,
|
||||
style='caption_label'
|
||||
}.style.width = 185
|
||||
Gui.bar(_flow,200)
|
||||
frame.add{
|
||||
type='label',
|
||||
caption=info.server_description,style='description_label'
|
||||
}
|
||||
Gui.bar(frame,600)
|
||||
local frame = frame.add{
|
||||
type='frame',
|
||||
direction='vertical',
|
||||
style='image_frame'
|
||||
}
|
||||
frame.style.width = 600
|
||||
local text_flow = frame.add{type='flow',direction='vertical'}
|
||||
local button_flow = frame.add{type='table',column_count=3}
|
||||
for _,element in pairs(table.deepcopy(Sync_gui_functions)) do
|
||||
local _type = table.remove(element,1)
|
||||
if _type == 'function' then
|
||||
local success, err = pcall(table.remove(element,1),frame.player_index,frame,unpack(element))
|
||||
if not success then error(err) else
|
||||
if is_type(err,'table') then
|
||||
if element.draw then element:draw(button_flow)
|
||||
else text_flow.add{type='label',caption=err} end
|
||||
else text_flow.add{type='label',caption=tostring(err)} end
|
||||
end
|
||||
elseif _type == 'gui' then element[1]:draw(button_flow)
|
||||
elseif _type == 'string' then text_flow.add{type='label',caption=tostring(element[1])}
|
||||
elseif _type == 'table' then text_flow.add{type='label',caption=element[1]} end
|
||||
end
|
||||
end}
|
||||
end
|
||||
|
||||
Event.register(defines.events.on_player_joined_game,function(event)
|
||||
local player = Game.get_player(event)
|
||||
if not player.admin and player.online_time < 60 then
|
||||
Gui.center.open(player,'server-info')
|
||||
end
|
||||
end)
|
||||
|
||||
return Sync
|
||||
@@ -48,6 +48,7 @@ Ranking, Sync, Server, Gui = require('/ExpCore/load'){'Ranking','Sync','Server',
|
||||
local success,err = pcall(require,'/ExpCore/GuiParts/test')
|
||||
if success then Gui.test = err end
|
||||
if Gui.popup then Gui.popup._load() end
|
||||
if Sync._load then Sync._load() end
|
||||
-- this loads the ranks that Ranking uses
|
||||
require('/ExpCore/ranks')
|
||||
-- this loads any edits that are not need in core pcall as file may not be preset
|
||||
|
||||
Reference in New Issue
Block a user