mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Most bugs caught
This commit is contained in:
@@ -467,7 +467,7 @@ Manager.error = setmetatable({
|
|||||||
rawget(tbl,'__error_call')(err,2)
|
rawget(tbl,'__error_call')(err,2)
|
||||||
end
|
end
|
||||||
local args = {...}
|
local args = {...}
|
||||||
local trace = args[1] and type(args[1]) == 'number' and args[1] or 2
|
local trace = args[1] and type(args[1]) == 'number' and args[1]+1 or 2
|
||||||
rawget(tbl,'__error_call')(err,trace)
|
rawget(tbl,'__error_call')(err,trace)
|
||||||
end,
|
end,
|
||||||
__index=function(tbl,key)
|
__index=function(tbl,key)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ script.on_init(function(event)
|
|||||||
local data = self.data
|
local data = self.data
|
||||||
if not data.high_role or not data.low_role
|
if not data.high_role or not data.low_role
|
||||||
or not data.low then self.reopen = false return end
|
or not data.low then self.reopen = false return end
|
||||||
-- idk but this stoped working for no appent reason so i added more checks for nil values
|
-- idk but this stoped working for no appent reason so i added more checks for nil values
|
||||||
if Role and Role.get_highest(player).index <= Role.get(data.low_role).index or player.admin then return end
|
if Role and Role.get_highest(player).index <= Role.get(data.low_role).index or player.admin then return end
|
||||||
for _,message in pairs(data.low) do
|
for _,message in pairs(data.low) do
|
||||||
player_return({'ExpGamingBot-autoMessage.message',message},nil,player)
|
player_return({'ExpGamingBot-autoMessage.message',message},nil,player)
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ function commands.get_commands(player)
|
|||||||
if not player then return error('Invalid player',2) end
|
if not player then return error('Invalid player',2) end
|
||||||
for name,data in pairs(data) do
|
for name,data in pairs(data) do
|
||||||
if #middleware > 0 then for _,callback in pairs(middleware) do
|
if #middleware > 0 then for _,callback in pairs(middleware) do
|
||||||
local success, err = pcall(callback,player_name,command.name,command)
|
local success, err = pcall(callback,player,name,data)
|
||||||
if not success then error(err)
|
if not success then error(err)
|
||||||
elseif err then table.insert(commands,data) end
|
elseif err then table.insert(commands,data) end
|
||||||
end elseif data.default_admin_only == true and player.admin then table.insert(commands,data) end
|
end elseif data.default_admin_only == true and player.admin then table.insert(commands,data) end
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ Gui.data = setmetatable({},{
|
|||||||
})
|
})
|
||||||
|
|
||||||
local events = {}
|
local events = {}
|
||||||
|
local order_config = require(module_path..'/order_config')
|
||||||
|
|
||||||
Gui.center = require(module_path..'/src/center',{Gui=Gui})
|
Gui.center = require(module_path..'/src/center',{Gui=Gui})
|
||||||
table.merge(events,Gui.center._events)
|
table.merge(events,Gui.center._events)
|
||||||
@@ -36,9 +37,9 @@ Gui.inputs = require(module_path..'/src/inputs',{Gui=Gui})
|
|||||||
table.merge(events,Gui.inputs._events)
|
table.merge(events,Gui.inputs._events)
|
||||||
Gui.inputs._events = nil
|
Gui.inputs._events = nil
|
||||||
|
|
||||||
Gui.left = require(module_path..'/src/left',{Gui=Gui})
|
Gui.left = require(module_path..'/src/left',{Gui=Gui,order_config=order_config})
|
||||||
Gui.popup = require(module_path..'/src/popup',{Gui=Gui})
|
Gui.popup = require(module_path..'/src/popup',{Gui=Gui})
|
||||||
Gui.toolbar = require(module_path..'/src/toolbar',{Gui=Gui})
|
Gui.toolbar = require(module_path..'/src/toolbar',{Gui=Gui,order_config=order_config})
|
||||||
|
|
||||||
for event,callback in pairs(events) do script.on_event(event,callback) end
|
for event,callback in pairs(events) do script.on_event(event,callback) end
|
||||||
|
|
||||||
|
|||||||
12
modules/ExpGamingCore/Gui/order_config.lua
Normal file
12
modules/ExpGamingCore/Gui/order_config.lua
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
return {
|
||||||
|
'readme',
|
||||||
|
'science',
|
||||||
|
'rockets',
|
||||||
|
'player-list',
|
||||||
|
'tasklist',
|
||||||
|
'warp-list',
|
||||||
|
'polls',
|
||||||
|
'announcements',
|
||||||
|
'admin-commands',
|
||||||
|
'game-settings'
|
||||||
|
}
|
||||||
@@ -13,10 +13,21 @@ local Color = require('FactorioStdLib.Color')
|
|||||||
local Role -- this is optional and is hanndled by it being present, it is loaded on init
|
local Role -- this is optional and is hanndled by it being present, it is loaded on init
|
||||||
local mod_gui = require("mod-gui")
|
local mod_gui = require("mod-gui")
|
||||||
local Gui = Gui -- this is to force gui to remain in the ENV
|
local Gui = Gui -- this is to force gui to remain in the ENV
|
||||||
|
local order_config = order_config
|
||||||
|
|
||||||
local left = {}
|
local left = {}
|
||||||
left._prototype = {}
|
left._prototype = {}
|
||||||
|
|
||||||
|
left.hide = Gui.inputs{
|
||||||
|
name='gui-left-hide',
|
||||||
|
type='button',
|
||||||
|
caption='<'
|
||||||
|
}:on_event('click',function(event)
|
||||||
|
for _,child in pairs(event.element.parent.children) do
|
||||||
|
if child.name ~= 'popups' then child.style.visible = false end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
-- used for debugging
|
-- used for debugging
|
||||||
function left.override_open(state)
|
function left.override_open(state)
|
||||||
global.over_ride_left_can_open = state
|
global.over_ride_left_can_open = state
|
||||||
@@ -63,9 +74,7 @@ function left.update(frame,players)
|
|||||||
data={player=player,frames=thread.data.frames}
|
data={player=player,frames=thread.data.frames}
|
||||||
}:on_event('resolve',function(thread)
|
}:on_event('resolve',function(thread)
|
||||||
for name,left in pairs(thread.data.frames) do
|
for name,left in pairs(thread.data.frames) do
|
||||||
if left then
|
if left then left:first_open(thread.data.player) end
|
||||||
left:first_open(thread.data.player)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end):queue()
|
end):queue()
|
||||||
end):open()
|
end):open()
|
||||||
@@ -119,20 +128,26 @@ end
|
|||||||
-- @usage left:open(player)
|
-- @usage left:open(player)
|
||||||
-- @tparam luaPlayer player the player to open the gui for
|
-- @tparam luaPlayer player the player to open the gui for
|
||||||
function left._prototype:open(player)
|
function left._prototype:open(player)
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(player)
|
||||||
|
if not player then error('Invalid Player') end
|
||||||
local left_flow = mod_gui.get_frame_flow(player)
|
local left_flow = mod_gui.get_frame_flow(player)
|
||||||
if not left_flow[_left.name] then self:first_open(player) end
|
if not left_flow[self.name] then self:first_open(player) end
|
||||||
left_flow[_left.name].style.visible = true
|
left_flow[self.name].style.visible = true
|
||||||
|
left_flow['gui-left-hide'].style.visible = true
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Used to force the gui closed for the player
|
--- Used to force the gui closed for the player
|
||||||
-- @usage left:open(player)
|
-- @usage left:open(player)
|
||||||
-- @tparam luaPlayer player the player to close the gui for
|
-- @tparam luaPlayer player the player to close the gui for
|
||||||
function left._prototype:close(player)
|
function left._prototype:close(player)
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(player)
|
||||||
|
if not player then error('Invalid Player') end
|
||||||
local left_flow = mod_gui.get_frame_flow(player)
|
local left_flow = mod_gui.get_frame_flow(player)
|
||||||
if not left_flow[_left.name] then self:first_open(player) end
|
if not left_flow[self.name] then self:first_open(player) end
|
||||||
left_flow[_left.name].style.visible = false
|
left_flow[self.name].style.visible = false
|
||||||
|
local count = 0
|
||||||
|
for _,child in pairs(left_flow.children) do if child.style.visible then count = count+1 end if count > 1 then break end end
|
||||||
|
if count == 1 then left_flow['gui-left-hide'].style.visible = false end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- When the gui is first made or is updated this function is called, used by the script
|
--- When the gui is first made or is updated this function is called, used by the script
|
||||||
@@ -149,9 +164,9 @@ function left._prototype:first_open(player)
|
|||||||
else
|
else
|
||||||
frame = left_flow.add{type='frame',name=self.name,style=mod_gui.frame_style,caption=self.caption,direction='vertical'}
|
frame = left_flow.add{type='frame',name=self.name,style=mod_gui.frame_style,caption=self.caption,direction='vertical'}
|
||||||
frame.style.visible = false
|
frame.style.visible = false
|
||||||
if is_type(self.open_on_join,'boolean') then frame.style.visible = self.open_on_join end
|
if is_type(self.open_on_join,'boolean') then frame.style.visible = self.open_on_join left_flow['gui-left-hide'].style.visible = true end
|
||||||
end
|
end
|
||||||
if is_type(self.draw,'function') then self.draw(frame) else frame.style.visible = false error('No Callback On '.._left.name) end
|
if is_type(self.draw,'function') then self.draw(frame) else frame.style.visible = false error('No Callback On '..self.name) end
|
||||||
return frame
|
return frame
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -162,29 +177,33 @@ end
|
|||||||
function left._prototype:toggle(player)
|
function left._prototype:toggle(player)
|
||||||
local player = Game.get_player(player)
|
local player = Game.get_player(player)
|
||||||
local left_flow = mod_gui.get_frame_flow(player)
|
local left_flow = mod_gui.get_frame_flow(player)
|
||||||
if not left_flow[_left.name] then _left:first_open(player) end
|
if not left_flow[self.name] then self:first_open(player) end
|
||||||
local left = left_flow[_left.name]
|
local left = left_flow[self.name]
|
||||||
local open = false
|
local open = false
|
||||||
if is_type(_left.can_open,'function') then
|
if is_type(self.can_open,'function') then
|
||||||
local success, err = pcall(_left.can_open,player)
|
local success, err = pcall(self.can_open,player)
|
||||||
if not success then error(err)
|
if not success then error(err)
|
||||||
elseif err == true then open = true
|
elseif err == true then open = true
|
||||||
elseif global.over_ride_left_can_open then
|
elseif global.over_ride_left_can_open then
|
||||||
if is_type(Role,'table') then
|
if is_type(Role,'table') then
|
||||||
if Role.allowed(player,_left.name) then open = true
|
if Role.allowed(player,self.name) then open = true
|
||||||
else open = {'ExpGamingCore_Gui.unauthorized'} end
|
else open = {'ExpGamingCore_Gui.unauthorized'} end
|
||||||
else open = true end
|
else open = true end
|
||||||
else open = err end
|
else open = err end
|
||||||
else
|
else
|
||||||
if is_type(Role,'table') then
|
if is_type(Role,'table') then
|
||||||
if Role.allowed(player,_left.name) then open = true
|
if Role.allowed(player,self.name) then open = true
|
||||||
else open = {'ExpGamingCore_Gui.unauthorized'} end
|
else open = {'ExpGamingCore_Gui.unauthorized'} end
|
||||||
else open = true end
|
else open = true end
|
||||||
end
|
end
|
||||||
if open == true and left.style.visible ~= true then
|
if open == true and left.style.visible ~= true then
|
||||||
left.style.visible = true
|
left.style.visible = true
|
||||||
|
left_flow['gui-left-hide'].style.visible = true
|
||||||
else
|
else
|
||||||
left.style.visible = false
|
left.style.visible = false
|
||||||
|
local count = 0
|
||||||
|
for _,child in pairs(left_flow.children) do if child.style.visible then count = count+1 end if count > 1 then break end end
|
||||||
|
if count == 1 then left_flow['gui-left-hide'].style.visible = false end
|
||||||
end
|
end
|
||||||
if open == false then player_return({'ExpGamingCore_Gui.cant-open-no-reason'},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'}
|
if open == false then player_return({'ExpGamingCore_Gui.cant-open-no-reason'},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'}
|
||||||
elseif open ~= true then player_return({'ExpGamingCore_Gui.cant-open',open},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'} end
|
elseif open ~= true then player_return({'ExpGamingCore_Gui.cant-open',open},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'} end
|
||||||
@@ -195,8 +214,17 @@ left.on_player_joined_game = function(event)
|
|||||||
-- draws the left guis when a player first joins, fake_event is just because i am lazy
|
-- draws the left guis when a player first joins, fake_event is just because i am lazy
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
local frames = Gui.data.left or {}
|
local frames = Gui.data.left or {}
|
||||||
|
left.hide(mod_gui.get_frame_flow(player)).style.maximal_width=15
|
||||||
|
local done = {}
|
||||||
|
for _,name in pairs(order_config) do
|
||||||
|
local left = Gui.data.left[name]
|
||||||
|
if left then
|
||||||
|
done[name] = true
|
||||||
|
left:first_open(player)
|
||||||
|
end
|
||||||
|
end
|
||||||
for name,left in pairs(frames) do
|
for name,left in pairs(frames) do
|
||||||
left:first_open(player)
|
if not done[name] then left:first_open(player) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ function popup.load()
|
|||||||
tooltip='Close This Popup'
|
tooltip='Close This Popup'
|
||||||
}:on_event('click',function(event)
|
}:on_event('click',function(event)
|
||||||
local frame = event.element.parent
|
local frame = event.element.parent
|
||||||
if frame and frame.valid then frame.destroy() end
|
local parent = frame.parent
|
||||||
|
if frame and frame.valid then frame.destroy() if #parent.children == 0 then parent.style.visible = false end end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -45,7 +46,9 @@ end
|
|||||||
-- this is used by the script to find the popup flow
|
-- this is used by the script to find the popup flow
|
||||||
function popup.flow(player)
|
function popup.flow(player)
|
||||||
local player = Game.get_player(player)
|
local player = Game.get_player(player)
|
||||||
local flow = mod_gui.get_frame_flow(player).popups or mod_gui.get_frame_flow(player).add{name='popups',type='flow',direction='vertical'}
|
if not player then error('Invalid Player',2) end
|
||||||
|
local flow = mod_gui.get_frame_flow(player).popups
|
||||||
|
if not flow then flow = mod_gui.get_frame_flow(player).add{name='popups',type='flow',direction='vertical'} flow.style.visible=false end
|
||||||
return flow
|
return flow
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -59,10 +62,11 @@ function popup.open(style,data,players)
|
|||||||
local players = players or game.connected_players
|
local players = players or game.connected_players
|
||||||
local data = data or {}
|
local data = data or {}
|
||||||
if not _popup then return end
|
if not _popup then return end
|
||||||
if _popup.left then Gui.left.close(_popup.left.name) end
|
|
||||||
if not Server or not Server._thread then
|
if not Server or not Server._thread then
|
||||||
for _,player in pairs(players) do
|
for _,player in pairs(players) do
|
||||||
|
if _popup.left then _popup.left:close(player) end
|
||||||
local flow = popup.flow(player)
|
local flow = popup.flow(player)
|
||||||
|
flow.style.visible=true
|
||||||
local _frame = flow.add{
|
local _frame = flow.add{
|
||||||
type='frame',
|
type='frame',
|
||||||
direction='horizontal',
|
direction='horizontal',
|
||||||
@@ -86,7 +90,9 @@ function popup.open(style,data,players)
|
|||||||
}:on_event('tick',function(thread)
|
}:on_event('tick',function(thread)
|
||||||
if #thread.data.players == 0 then thread:close() return end
|
if #thread.data.players == 0 then thread:close() return end
|
||||||
local player = table.remove(thread.data.players,1)
|
local player = table.remove(thread.data.players,1)
|
||||||
|
if _popup.left then _popup.left:close(player) end
|
||||||
local flow = popup.flow(player)
|
local flow = popup.flow(player)
|
||||||
|
flow.style.visible=true
|
||||||
local _frame = flow.add{
|
local _frame = flow.add{
|
||||||
type='frame',
|
type='frame',
|
||||||
direction='horizontal',
|
direction='horizontal',
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ local send_popup = Gui.inputs{
|
|||||||
}:on_event('click',function(event)
|
}:on_event('click',function(event)
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
local message = event.element.parent['test-popup-text'].text
|
local message = event.element.parent['test-popup-text'].text
|
||||||
Gui.popup.open('test-popup',{player=player.name,message=message})
|
Gui.popup.open('test-popup',{message=message,player=player.name})
|
||||||
end)
|
end)
|
||||||
Gui.popup{
|
Gui.popup{
|
||||||
name='test-popup',
|
name='test-popup',
|
||||||
|
|||||||
@@ -11,9 +11,28 @@ local Game = require('FactorioStdLib.Game')
|
|||||||
local Role -- this is optional and is hanndled by it being present, it is loaded on init
|
local Role -- this is optional and is hanndled by it being present, it is loaded on init
|
||||||
local mod_gui = require("mod-gui")
|
local mod_gui = require("mod-gui")
|
||||||
local Gui = Gui -- this is to force gui to remain in the ENV
|
local Gui = Gui -- this is to force gui to remain in the ENV
|
||||||
|
local order_config = order_config
|
||||||
|
|
||||||
local toolbar = {}
|
local toolbar = {}
|
||||||
|
|
||||||
|
toolbar.hide = Gui.inputs{
|
||||||
|
name='gui-toolbar-hide',
|
||||||
|
type='button',
|
||||||
|
caption='<'
|
||||||
|
}:on_event('click',function(event)
|
||||||
|
if event.element.caption == '<' then
|
||||||
|
event.element.caption = '>'
|
||||||
|
for _,child in pairs(event.element.parent.children) do
|
||||||
|
if child.name ~= event.element.name then child.style.visible = false end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
event.element.caption = '<'
|
||||||
|
for _,child in pairs(event.element.parent.children) do
|
||||||
|
if child.name ~= event.element.name then child.style.visible = true end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
--- Add a button to the toolbar, ranks need to be allowed to use these buttons if ranks is preset
|
--- Add a button to the toolbar, ranks need to be allowed to use these buttons if ranks is preset
|
||||||
-- @usage toolbar.add('foo','Foo','Test',function() game.print('test') end)
|
-- @usage toolbar.add('foo','Foo','Test',function() game.print('test') end)
|
||||||
-- @tparam string name the name of the button
|
-- @tparam string name the name of the button
|
||||||
@@ -38,12 +57,27 @@ function toolbar.draw(player)
|
|||||||
local toolbar_frame = mod_gui.get_button_flow(player)
|
local toolbar_frame = mod_gui.get_button_flow(player)
|
||||||
toolbar_frame.clear()
|
toolbar_frame.clear()
|
||||||
if not Gui.data.toolbar then return end
|
if not Gui.data.toolbar then return end
|
||||||
|
toolbar.hide(toolbar_frame).style.maximal_width = 15
|
||||||
|
local done = {}
|
||||||
|
for _,name in pairs(order_config) do
|
||||||
|
local button = Gui.data.toolbar[name]
|
||||||
|
if button then
|
||||||
|
done[name] = true
|
||||||
|
if is_type(Role,'table') then
|
||||||
|
if Role.allowed(player,name) then
|
||||||
|
button(toolbar_frame)
|
||||||
|
end
|
||||||
|
else button(toolbar_frame) end
|
||||||
|
end
|
||||||
|
end
|
||||||
for name,button in pairs(Gui.data.toolbar) do
|
for name,button in pairs(Gui.data.toolbar) do
|
||||||
if is_type(Role,'table') then
|
if not done[name] then
|
||||||
if Role.allowed(player,name) then
|
if is_type(Role,'table') then
|
||||||
button(toolbar_frame)
|
if Role.allowed(player,name) then
|
||||||
end
|
button(toolbar_frame)
|
||||||
else button(toolbar_frame) end
|
end
|
||||||
|
else button(toolbar_frame) end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ local Role = {
|
|||||||
rawset(tbl,key,Role.define(value))
|
rawset(tbl,key,Role.define(value))
|
||||||
end
|
end
|
||||||
}),
|
}),
|
||||||
on_init=function()
|
on_init=function(self)
|
||||||
if loaded_modules['ExpGamingCore.Server@^4.0.0'] then require('ExpGamingCore.Server@^4.0.0').add_module_to_interface('Role','ExpGamingCore.Role') end
|
if loaded_modules['ExpGamingCore.Server@^4.0.0'] then require('ExpGamingCore.Server@^4.0.0').add_module_to_interface('Role','ExpGamingCore.Role') end
|
||||||
if loaded_modules['ExpGamingCore.Command@^4.0.0'] then require(module_path..'/src/commands',{Role=Role}) end
|
if loaded_modules['ExpGamingCore.Command@^4.0.0'] then require(module_path..'/src/commands',{self=self}) end
|
||||||
end,
|
end,
|
||||||
on_post=function(self)
|
on_post=function(self)
|
||||||
-- loads the roles in config
|
-- loads the roles in config
|
||||||
@@ -399,8 +399,8 @@ function Role._prototype:add_player(player,by_player,batch)
|
|||||||
by_player_index=by_player.index,
|
by_player_index=by_player.index,
|
||||||
old_highest=highest.name,
|
old_highest=highest.name,
|
||||||
role_name=self.name,
|
role_name=self.name,
|
||||||
batch=batch[2] or {self.name},
|
batch=batch and batch[2] or {self.name},
|
||||||
batch_index=batch[1] or 1,
|
batch_index=batch and batch[1] or 1,
|
||||||
effect='assign'
|
effect='assign'
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@@ -430,8 +430,8 @@ function Role._prototype:remove_player(player,by_player,batch)
|
|||||||
by_player_index=by_player.index,
|
by_player_index=by_player.index,
|
||||||
old_highest=highest.name,
|
old_highest=highest.name,
|
||||||
role_name=self.name,
|
role_name=self.name,
|
||||||
batch=batch[2] or {self.name},
|
batch=batch and batch[2] or {self.name},
|
||||||
batch_index=batch[1] or 1,
|
batch_index=batch and batch[1] or 1,
|
||||||
effect='unassign'
|
effect='unassign'
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@@ -441,7 +441,7 @@ script.on_event(role_change_event_id,function(event)
|
|||||||
-- varible init
|
-- varible init
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
local by_player = Game.get_player(event.by_player_index) or SERVER
|
local by_player = Game.get_player(event.by_player_index) or SERVER
|
||||||
local role = Role.get(event.role_name)
|
local role = Role.get(event.role_name)
|
||||||
local highest = Role.get_highest(player) or {__faild=true,tag='',name='None'}
|
local highest = Role.get_highest(player) or {__faild=true,tag='',name='None'}
|
||||||
-- gets the falgs the player currently has
|
-- gets the falgs the player currently has
|
||||||
for flag,callback in pairs(Role.flags) do if is_type(callback,'function') then callback(player,Role.has_flag(player,flag)) end end
|
for flag,callback in pairs(Role.flags) do if is_type(callback,'function') then callback(player,Role.has_flag(player,flag)) end end
|
||||||
@@ -458,8 +458,9 @@ script.on_event(role_change_event_id,function(event)
|
|||||||
if player.online_time > 60 then
|
if player.online_time > 60 then
|
||||||
-- send a message to other players
|
-- send a message to other players
|
||||||
if event.batch_index == 1 then
|
if event.batch_index == 1 then
|
||||||
local name = table.concat(event.batch,', ')
|
local names = {}
|
||||||
if event.effect == 'assign' then game.print{'ExpGamingCore-Role.default-print',{'ExpGamingCore-Role.assign',player.name,name,by_player.name}}
|
for _,name in pairs(event.batch) do local role = Role.get(name) if role then table.insert(names,role.name) end end
|
||||||
|
if event.effect == 'assign' then game.print{'ExpGamingCore-Role.default-print',{'ExpGamingCore-Role.assign',player.name,table.concat(names,', '),by_player.name}}
|
||||||
else game.print{'ExpGamingCore-Role.default-print',{'ExpGamingCore-Role.unassign',player.name,name,by_player.name}} end
|
else game.print{'ExpGamingCore-Role.default-print',{'ExpGamingCore-Role.unassign',player.name,name,by_player.name}} end
|
||||||
end
|
end
|
||||||
-- log change to file
|
-- log change to file
|
||||||
@@ -482,6 +483,7 @@ end)
|
|||||||
|
|
||||||
script.on_event(defines.events.on_player_joined_game,function(event)
|
script.on_event(defines.events.on_player_joined_game,function(event)
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
|
log(serpent.line(event))
|
||||||
local highest = Role.get_highest(player) or Role.meta.default
|
local highest = Role.get_highest(player) or Role.meta.default
|
||||||
Group.assign(player,highest.group)
|
Group.assign(player,highest.group)
|
||||||
player.tag=highest.tag
|
player.tag=highest.tag
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local Role = Role
|
local Role = self
|
||||||
|
|
||||||
commands.add_validation('player-rank',function(value,event)
|
commands.add_validation('player-rank',function(value,event)
|
||||||
local player,err = commands.validate['player'](value)
|
local player,err = commands.validate['player'](value)
|
||||||
|
|||||||
@@ -407,7 +407,7 @@ function Server._thread:check_timeout()
|
|||||||
if is_type(self.timeout,'number') and game.tick >= (self.opened+self.timeout) then
|
if is_type(self.timeout,'number') and game.tick >= (self.opened+self.timeout) then
|
||||||
if is_type(self._timeout,'function') then
|
if is_type(self._timeout,'function') then
|
||||||
-- we do not care if the time out has caused an error as it is in most cases an error in its own right
|
-- we do not care if the time out has caused an error as it is in most cases an error in its own right
|
||||||
Manager.sandbox(self._timeout,thread._env,self)
|
Manager.sandbox(self._timeout,self._env,self)
|
||||||
end
|
end
|
||||||
_return = true
|
_return = true
|
||||||
-- closes the thread to provent any further event calls
|
-- closes the thread to provent any further event calls
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
[ExpGamingCore_Server]
|
|
||||||
interface-description=Runs the given input from the script
|
|
||||||
@@ -23,7 +23,7 @@ Server.add_module_to_interface('Server','ExpGamingCore.Server')
|
|||||||
--- Runs the given input from the script
|
--- Runs the given input from the script
|
||||||
-- @command interface
|
-- @command interface
|
||||||
-- @param code The code that will be ran
|
-- @param code The code that will be ran
|
||||||
commands.add_command('interface',{'ExpGamingCore_Server.interface-description'}, {
|
commands.add_command('interface','Runs the given input from the script', {
|
||||||
['code']={true,'string-inf'}
|
['code']={true,'string-inf'}
|
||||||
}, function(event,args)
|
}, function(event,args)
|
||||||
local callback = args.code
|
local callback = args.code
|
||||||
|
|||||||
@@ -99,4 +99,4 @@ script.on_event(defines.events.on_gui_click,function(event)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
script.on_event(defines.events.on_player_joined_game,Sync.info_gui)
|
script.on_event(defines.events.on_player_joined_game,function(event) Sync.info_gui(event) end)
|
||||||
@@ -36,7 +36,9 @@ end
|
|||||||
-- Adds a caption to the info gui that shows the rank given to the player
|
-- Adds a caption to the info gui that shows the rank given to the player
|
||||||
if Sync.add_to_gui then
|
if Sync.add_to_gui then
|
||||||
Sync.add_to_gui(function(player,frame)
|
Sync.add_to_gui(function(player,frame)
|
||||||
return 'You have been assigned the rank \''..Role.get_highest(player).name..'\''
|
local names = {}
|
||||||
|
for _,role in pairs(Role.get(player)) do table.insert(names,role.name) end
|
||||||
|
return 'You have been assigned the roles: '..table.concat(names,', ')
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ local module_verbose = false
|
|||||||
local ThisModule = {
|
local ThisModule = {
|
||||||
on_init=function(self)
|
on_init=function(self)
|
||||||
if loaded_modules['ExpGamingPlayer.playerInfo'] then playerInfo = require('ExpGamingPlayer.playerInfo') end
|
if loaded_modules['ExpGamingPlayer.playerInfo'] then playerInfo = require('ExpGamingPlayer.playerInfo') end
|
||||||
if loaded_modules['ExpGamingCore.Role@^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',{self=self}) end
|
||||||
if loaded_modules['ExpGamingAdmin.AdminLib@^4.0.0'] then Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') end
|
if loaded_modules['ExpGamingAdmin.AdminLib@^4.0.0'] then Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,6 @@ end)
|
|||||||
|
|
||||||
script.on_event(defines.events.on_player_joined_game,ThisModule.update)
|
script.on_event(defines.events.on_player_joined_game,ThisModule.update)
|
||||||
script.on_event(defines.events.on_player_left_game,ThisModule.update)
|
script.on_event(defines.events.on_player_left_game,ThisModule.update)
|
||||||
script.on_event(defines.events.rank_change,ThisModule.update)
|
|
||||||
|
|
||||||
ThisModule.force_update = function() return ThisModule.Gui() end
|
ThisModule.force_update = function() return ThisModule.Gui() end
|
||||||
-- when called it will queue an update to the player list
|
-- when called it will queue an update to the player list
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
local Role = require('ExpGamingCore.Role@^4.0.0')
|
local Role = require('ExpGamingCore.Role@^4.0.0')
|
||||||
|
|
||||||
|
script.on_event(defines.events.on_role_change,self.update)
|
||||||
|
|
||||||
return function()
|
return function()
|
||||||
local rtn = {}
|
local rtn = {}
|
||||||
for _,role_name in pairs(Role.order) do
|
for _,role_name in pairs(Role.order) do
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ local ThisModule = {}
|
|||||||
|
|
||||||
-- Function Define
|
-- Function Define
|
||||||
local function _roles(player)
|
local function _roles(player)
|
||||||
local roles = {'Select Rank'}
|
local roles = {'Select Role'}
|
||||||
local _role = Role.get_highest(player)
|
local _role = Role.get_highest(player)
|
||||||
for index,role_name in pairs(Role.order) do
|
for index,role_name in pairs(Role.order) do
|
||||||
if index >= _role.index then
|
if index >= _role.index then
|
||||||
@@ -29,7 +29,7 @@ end
|
|||||||
|
|
||||||
local role_drop_down = Gui.inputs.add_drop_down('rank-drop-down-annoncements',_roles,1,function(player,selected,items,element)
|
local role_drop_down = Gui.inputs.add_drop_down('rank-drop-down-annoncements',_roles,1,function(player,selected,items,element)
|
||||||
element.parent.role.caption = selected
|
element.parent.role.caption = selected
|
||||||
if selected == 'Select Rank' then element.parent['send-annoncement'].style.visible = false
|
if selected == 'Select Role' then element.parent['send-annoncement'].style.visible = false
|
||||||
else element.parent['send-annoncement'].style.visible = true end
|
else element.parent['send-annoncement'].style.visible = true end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -45,12 +45,8 @@ local send_popup = Gui.inputs{
|
|||||||
local role_name = _role.name..'s'; if rank_name == Role.meta.default.name..'s' then rank_name = 'Everyone' end
|
local role_name = _role.name..'s'; if rank_name == Role.meta.default.name..'s' then rank_name = 'Everyone' end
|
||||||
local sent_to = {'announcements.sent-to',rank_name}
|
local sent_to = {'announcements.sent-to',rank_name}
|
||||||
local message = event.element.parent.parent.message.text
|
local message = event.element.parent.parent.message.text
|
||||||
for index,_role_name in pairs(Role.order) do
|
Gui.popup.open('announcements',{sent_by=sent_by,sent_to=sent_to,message=message},_role:get_players(true))
|
||||||
if index <= _role.index then
|
event.element.parent.parent.message.text = ''
|
||||||
Gui.popup.open('announcements',{sent_by=sent_by,sent_to=sent_to,message=message},Role.get(_role_name):get_players(true))
|
|
||||||
event.element.parent.parent.message.text = ''
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ThisModule.Gui = Gui.popup{
|
ThisModule.Gui = Gui.popup{
|
||||||
@@ -98,7 +94,7 @@ ThisModule.Gui = Gui.popup{
|
|||||||
btn.style.width = 25
|
btn.style.width = 25
|
||||||
flow.add{
|
flow.add{
|
||||||
type='label',
|
type='label',
|
||||||
name='rank',
|
name='role',
|
||||||
caption=''
|
caption=''
|
||||||
}.style.visible = false
|
}.style.visible = false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ script.on_event(defines.events.on_player_changed_position, function(event)
|
|||||||
end end
|
end end
|
||||||
local chance = paths[tile_name][1]/(count-adjacency_boost)
|
local chance = paths[tile_name][1]/(count-adjacency_boost)
|
||||||
if math.random() < chance then
|
if math.random() < chance then
|
||||||
down_grade(surface,pos)
|
ThisModule.down_grade(surface,pos)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user