mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Few Bugs Fixed
This commit is contained in:
@@ -14,9 +14,9 @@ Discord: https://discord.gg/r6dC2uK
|
|||||||
Manager = require("FactorioSoftmodManager")
|
Manager = require("FactorioSoftmodManager")
|
||||||
Manager.setVerbose{
|
Manager.setVerbose{
|
||||||
selfInit=true, -- called while the manager is being set up
|
selfInit=true, -- called while the manager is being set up
|
||||||
moduleLoad=true, -- when a module is required by the manager
|
moduleLoad=false, -- when a module is required by the manager
|
||||||
moduleInit=true, -- when and within the initation of a module
|
moduleInit=false, -- when and within the initation of a module
|
||||||
modulePost=true, -- when and within the post of a module
|
modulePost=false, -- when and within the post of a module
|
||||||
moduleEnv=true, -- during module runtime, this is a global option set within each module for fine control
|
moduleEnv=true, -- during module runtime, this is a global option set within each module for fine control
|
||||||
eventRegistered=false, -- when a module registers its event handlers
|
eventRegistered=false, -- when a module registers its event handlers
|
||||||
errorCaught=true, -- when an error is caught during runtime
|
errorCaught=true, -- when an error is caught during runtime
|
||||||
|
|||||||
@@ -134,7 +134,7 @@
|
|||||||
<h2><a href="#Events">Events</a></h2>
|
<h2><a href="#Events">Events</a></h2>
|
||||||
<table class="function_list">
|
<table class="function_list">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="name" nowrap><a href="#rank_change">rank_change</a></td>
|
<td class="name" nowrap><a href="#on_rank_change">on_rank_change</a></td>
|
||||||
<td class="summary">Called when there is a rank change for a user</td>
|
<td class="summary">Called when there is a rank change for a user</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -554,8 +554,8 @@
|
|||||||
|
|
||||||
<dl class="function">
|
<dl class="function">
|
||||||
<dt>
|
<dt>
|
||||||
<a name = "rank_change"></a>
|
<a name = "on_rank_change"></a>
|
||||||
<strong>rank_change</strong>
|
<strong>on_rank_change</strong>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<dd>
|
||||||
Called when there is a rank change for a user
|
Called when there is a rank change for a user
|
||||||
|
|||||||
@@ -7,10 +7,6 @@
|
|||||||
local Gui = {}
|
local Gui = {}
|
||||||
local Gui_data = {}
|
local Gui_data = {}
|
||||||
|
|
||||||
--- Stores all the on_player_joined_game event handlers for the guis
|
|
||||||
-- @table events
|
|
||||||
Gui.events = {join={},rank={}}
|
|
||||||
|
|
||||||
--- Used to set and get data about different guis
|
--- Used to set and get data about different guis
|
||||||
-- @usage Gui.data[location] -- returns the gui data for that gui location ex center
|
-- @usage Gui.data[location] -- returns the gui data for that gui location ex center
|
||||||
-- @usage Gui.data(location,gui_name,gui_data) -- adds gui data for a gui at a location
|
-- @usage Gui.data(location,gui_name,gui_data) -- adds gui data for a gui at a location
|
||||||
@@ -28,19 +24,11 @@ Gui.data = setmetatable({},{
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- loaded the different gui parts, each is its own module for ldoc reasons
|
Gui.center = require(module_path..'/src/center')
|
||||||
local join, rank
|
Gui.inputs = require(module_path..'/src/inputs')
|
||||||
Gui.center, join, rank = require(module_path..'/src/center')
|
Gui.left = require(module_path..'/src/left')
|
||||||
table.insert(Gui.events.join,event) table.insert(Gui.events.rank,rank)
|
Gui.popup = require(module_path..'/src/popup')
|
||||||
Gui.inputs, event = require(module_path..'/src/inputs')
|
Gui.toolbar = require(module_path..'/src/toolbar')
|
||||||
table.insert(Gui.events.join,event) table.insert(Gui.events.rank,rank)
|
|
||||||
Gui.left, event = require(module_path..'/src/left')
|
|
||||||
table.insert(Gui.events.join,event) table.insert(Gui.events.rank,rank)
|
|
||||||
Gui.popup, event = require(module_path..'/src/popup')
|
|
||||||
table.insert(Gui.events.join,event) table.insert(Gui.events.rank,rank)
|
|
||||||
Gui.toolbar, event = require(module_path..'/src/toolbar')
|
|
||||||
table.insert(Gui.events.join,event) table.insert(Gui.events.rank,rank)
|
|
||||||
join, rank = nil, nil
|
|
||||||
|
|
||||||
--- Add a white bar to any gui frame
|
--- Add a white bar to any gui frame
|
||||||
-- @usage Gui.bar(frame,100)
|
-- @usage Gui.bar(frame,100)
|
||||||
@@ -74,20 +62,6 @@ function Gui.set_dropdown_index(dropdown,_item)
|
|||||||
return dropdown
|
return dropdown
|
||||||
end
|
end
|
||||||
|
|
||||||
function Gui:on_init()
|
|
||||||
if loaded_modules.Server then verbose('ExpGamingCore.Server is installed; Loading server src') require(module_path..'/src/server') end
|
|
||||||
if loaded_modules.Ranking then
|
|
||||||
verbose('ExpGamingCore.Ranking is installed; Loading ranking src')
|
|
||||||
script.on_event('on_player_joined_game',function(event)
|
|
||||||
for _,callback in pairs(Gui.events.rank) do callback(event) end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Gui:on_post()
|
|
||||||
Gui.test = require(module_path..'/src/test')
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Prams for Gui.cam_link
|
--- Prams for Gui.cam_link
|
||||||
-- @table ParametersForCamLink
|
-- @table ParametersForCamLink
|
||||||
-- @field entity this is the entity that the camera will follow
|
-- @field entity this is the entity that the camera will follow
|
||||||
@@ -152,7 +126,9 @@ function Gui.cam_link(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
script.on_event('on_player_joined_game',function(event)
|
script.on_event('on_player_joined_game',function(event)
|
||||||
for _,callback in pairs(Gui.events.join) do callback(event) end
|
Gui.toolbar.on_player_joined_game(event)
|
||||||
|
Gui.popup.on_player_joined_game(event)
|
||||||
|
Gui.left.on_player_joined_game(event)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
script.on_event('on_tick', function(event)
|
script.on_event('on_tick', function(event)
|
||||||
@@ -183,4 +159,21 @@ script.on_event('on_player_respawned',function(event)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
function Gui:on_init()
|
||||||
|
if loaded_modules.Server then verbose('ExpGamingCore.Server is installed; Loading server src') require(module_path..'/src/server') end
|
||||||
|
if loaded_modules.Ranking then
|
||||||
|
verbose('ExpGamingCore.Ranking is installed; Loading ranking src')
|
||||||
|
script.on_event('on_rank_change',function(event)
|
||||||
|
Gui.toolbar.on_rank_change(event)
|
||||||
|
Gui.center.on_rank_change(event)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Gui:on_post()
|
||||||
|
Gui.test = require(module_path..'/src/test')
|
||||||
|
Gui.popup.load() Gui.popup.load = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return Gui
|
return Gui
|
||||||
@@ -201,6 +201,5 @@ script.on_event('on_gui_closed',function(event)
|
|||||||
if event.element and event.element.valid then event.element.destroy() end
|
if event.element and event.element.valid then event.element.destroy() end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- when the player rank is changed it closses the center guis
|
center.on_rank_change = center.clear
|
||||||
-- second return is join event and third is rank change event
|
return center
|
||||||
return center, nil, center.clear
|
|
||||||
@@ -371,6 +371,6 @@ function inputs.add_drop_down(name,items,index,callback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- second return is join event and third is rank change event
|
-- second return is join event and third is rank change event
|
||||||
return inputs, nil, nil
|
return inputs
|
||||||
|
|
||||||
-- to see examples look at GuiParts/test.lua
|
-- to see examples look at GuiParts/test.lua
|
||||||
|
|||||||
@@ -144,13 +144,13 @@ function left._left.toggle(event)
|
|||||||
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(Ranking,'table') and Ranking._presets and Ranking._presets().meta.rank_count > 0 then
|
if is_type(Ranking,'table') and Ranking.meta.rank_count > 0 then
|
||||||
if Ranking.get_rank(player):allowed(_left.name) then open = true
|
if Ranking.get_rank(player):allowed(_left.name) then open = true
|
||||||
else open = {gui.unauthorized} end
|
else open = {gui.unauthorized} end
|
||||||
end
|
end
|
||||||
else open = err end
|
else open = err end
|
||||||
else
|
else
|
||||||
if is_type(Ranking,'table') and Ranking._presets and Ranking._presets().meta.rank_count > 0 then
|
if is_type(Ranking,'table') and Ranking.meta.rank_count > 0 then
|
||||||
if Ranking.get_rank(player):allowed(_left.name) then open = true
|
if Ranking.get_rank(player):allowed(_left.name) then open = true
|
||||||
else open = {gui.unauthorized} end
|
else open = {gui.unauthorized} end
|
||||||
end
|
end
|
||||||
@@ -164,8 +164,7 @@ function left._left.toggle(event)
|
|||||||
elseif open ~= true then player_return({'gui.cant-open',open},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'} end
|
elseif open ~= true then player_return({'gui.cant-open',open},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'} end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- second return is join event and third is rank change event
|
left.on_player_joined_game = function(event)
|
||||||
return left, 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 {}
|
||||||
@@ -173,4 +172,6 @@ return left, function(event)
|
|||||||
local fake_event = {player_index=player.index,element={name=name}}
|
local fake_event = {player_index=player.index,element={name=name}}
|
||||||
left.open(fake_event)
|
left.open(fake_event)
|
||||||
end
|
end
|
||||||
end, nil
|
end
|
||||||
|
|
||||||
|
return left
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
local popup = {}
|
local popup = {}
|
||||||
popup._popup = {}
|
popup._popup = {}
|
||||||
|
|
||||||
function popup._load()
|
function popup.load()
|
||||||
popup._popup.close = Gui.inputs.add{
|
popup._popup.close = Gui.inputs.add{
|
||||||
type='button',
|
type='button',
|
||||||
name='popup-close',
|
name='popup-close',
|
||||||
@@ -107,5 +107,6 @@ function popup._popup:add_left(obj)
|
|||||||
self.left = Gui.left.add(obj)
|
self.left = Gui.left.add(obj)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- second return is join event and third is rank change event
|
popup.on_player_joined_game = popup.flow
|
||||||
return popup, popup.flow, nil
|
|
||||||
|
return popup
|
||||||
@@ -34,7 +34,7 @@ function toolbar.draw(player)
|
|||||||
toolbar_frame.clear()
|
toolbar_frame.clear()
|
||||||
if not Gui.data.toolbar then return end
|
if not Gui.data.toolbar then return end
|
||||||
for name,button in pairs(Gui.data.toolbar) do
|
for name,button in pairs(Gui.data.toolbar) do
|
||||||
if is_type(Ranking,'table') and Ranking._presets and Ranking._presets().meta.rank_count > 0 then
|
if is_type(Ranking,'table') and Ranking.meta.rank_count > 0 then
|
||||||
local rank = Ranking.get_rank(player)
|
local rank = Ranking.get_rank(player)
|
||||||
if rank:allowed(name) then
|
if rank:allowed(name) then
|
||||||
button:draw(toolbar_frame)
|
button:draw(toolbar_frame)
|
||||||
@@ -43,5 +43,6 @@ function toolbar.draw(player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- second return is join event and third is rank change event
|
toolbar.on_rank_change = toolbar.draw
|
||||||
return toolbar, toolbar.draw, toolbar.draw
|
toolbar.on_player_joined_game = toolbar.draw
|
||||||
|
return toolbar
|
||||||
@@ -14,14 +14,14 @@ local module_verbose = false --true|false
|
|||||||
local global = global{old={},preset={},last_change=nil}
|
local global = global{old={},preset={},last_change=nil}
|
||||||
|
|
||||||
--- Called when there is a rank change for a user
|
--- Called when there is a rank change for a user
|
||||||
-- @event rank_change
|
-- @event on_rank_change
|
||||||
-- @field name the rank id
|
-- @field name the rank id
|
||||||
-- @field tick the tick which the event was raised on
|
-- @field tick the tick which the event was raised on
|
||||||
-- @field player_index the player whos rank was changed
|
-- @field player_index the player whos rank was changed
|
||||||
-- @field by_player_index the player who changed the rank, 0 means server
|
-- @field by_player_index the player who changed the rank, 0 means server
|
||||||
-- @field new_rank the name of the rank that was given
|
-- @field new_rank the name of the rank that was given
|
||||||
-- @field old_rank the name of the rank the player had
|
-- @field old_rank the name of the rank the player had
|
||||||
script.generate_event_name('rank_change')
|
script.generate_event_name('on_rank_change')
|
||||||
|
|
||||||
--- Outputs as a string all the ranks and the loaded order
|
--- Outputs as a string all the ranks and the loaded order
|
||||||
-- @usage Ranking.output_ranks(player) -- prints to player
|
-- @usage Ranking.output_ranks(player) -- prints to player
|
||||||
@@ -208,8 +208,8 @@ function Ranking.give_rank(player,rank,by_player,tick)
|
|||||||
player.admin = rank.is_admin or false
|
player.admin = rank.is_admin or false
|
||||||
player.spectator = rank.is_spectator or false
|
player.spectator = rank.is_spectator or false
|
||||||
local by_player_index = by_player_name == 'server' and 0 or Game.get_player(by_player_name).index
|
local by_player_index = by_player_name == 'server' and 0 or Game.get_player(by_player_name).index
|
||||||
script.raise_event(defines.events.rank_change,{
|
script.raise_event(defines.events.on_rank_change,{
|
||||||
name=defines.events.rank_change,
|
name=defines.events.on_rank_change,
|
||||||
tick=tick,
|
tick=tick,
|
||||||
player_index=player.index,
|
player_index=player.index,
|
||||||
by_player_index=by_player_index,
|
by_player_index=by_player_index,
|
||||||
|
|||||||
@@ -167,7 +167,6 @@ function Server._thread_handler(event)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
script.on_event(defines.events,Server._thread_handler)
|
|
||||||
|
|
||||||
--[[ cant be used V
|
--[[ cant be used V
|
||||||
--- Adds a event handler to tell threads about events
|
--- Adds a event handler to tell threads about events
|
||||||
@@ -370,7 +369,7 @@ function Server._thread:resolve(...)
|
|||||||
local _return = false
|
local _return = false
|
||||||
-- checks if the resolve haddler is still present
|
-- checks if the resolve haddler is still present
|
||||||
if is_type(self._resolve,'function') then
|
if is_type(self._resolve,'function') then
|
||||||
local sandbox, success, err = Manager.sandbox(self._resolve,thread._env,self,...)
|
local sandbox, success, err = Manager.sandbox(self._resolve,self._env,self,...)
|
||||||
if success then
|
if success then
|
||||||
-- if it was successful then it will attemp to call the success handler
|
-- if it was successful then it will attemp to call the success handler
|
||||||
if is_type(self._success,'function') then
|
if is_type(self._success,'function') then
|
||||||
@@ -462,6 +461,7 @@ script.on_event(-2,function(event)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
function Server:on_init()
|
function Server:on_init()
|
||||||
|
for name,id in pairs(defines.events) do if not script.get_event_handler(id) then script.on_event(id,Server._thread_handler) end end
|
||||||
if loaded_modules.commands then verbose('ExpGamingCore.Commands is installed; Loading commands src') require(module_path..'/src/commands') end
|
if loaded_modules.commands then verbose('ExpGamingCore.Commands is installed; Loading commands src') require(module_path..'/src/commands') end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ if Sync.add_to_gui then
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- adds a discord emit for rank chaning
|
-- adds a discord emit for rank chaning
|
||||||
script.on_event('rank_change',function(event)
|
script.on_event('on_rank_change',function(event)
|
||||||
local rank = Ranking.get_rank(event.new_rank)
|
local rank = Ranking.get_rank(event.new_rank)
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
local by_player_name = Game.get_player(event.by_player_index) or '<server>'
|
local by_player_name = Game.get_player(event.by_player_index) or '<server>'
|
||||||
|
|||||||
Reference in New Issue
Block a user