Converted Modules To Use Roles

This commit is contained in:
Cooldude2606
2018-09-29 17:28:07 +01:00
parent 96784009b6
commit e50bd509f8
48 changed files with 277 additions and 1146 deletions

View File

@@ -209,5 +209,5 @@ center._events = {[defines.events.on_gui_closed]=function(event)
if event.element and event.element.valid then event.element.destroy() end
end}
center.on_rank_change = center.clear
center.on_role_change = center.clear
return center

View File

@@ -9,7 +9,7 @@
local Game = require('FactorioStdLib.Game')
local Color = require('FactorioStdLib.Color')
local Ranking -- 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 Gui = Gui -- this is to force gui to remain in the ENV
@@ -150,14 +150,14 @@ function left._left.toggle(event)
if not success then error(err)
elseif err == true then open = true
elseif global.over_ride_left_can_open 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 is_type(Role,'table') then
if Role.allowed(player,_left.name) then open = true
else open = {gui.unauthorized} end
else open = true end
else open = err end
else
if is_type(Ranking,'table') and Ranking.meta.rank_count > 0 then
if Ranking.get_rank(player):allowed(_left.name) then open = true
if is_type(Role,'table') then
if Role.allowed(player,_left.name) then open = true
else open = {gui.unauthorized} end
else open = true end
end
@@ -181,7 +181,7 @@ left.on_player_joined_game = function(event)
end
function left:on_init()
if loaded_modules['ExpGamingCore.Ranking'] then Ranking = require('ExpGamingCore.Ranking') end
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
end
return left

View File

@@ -8,7 +8,7 @@
-- @function _comment
local Game = require('FactorioStdLib.Game')
local Ranking -- 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 Gui = Gui -- this is to force gui to remain in the ENV
@@ -39,9 +39,8 @@ function toolbar.draw(player)
toolbar_frame.clear()
if not Gui.data.toolbar then return end
for name,button in pairs(Gui.data.toolbar) do
if is_type(Ranking,'table') and Ranking.meta.rank_count > 0 then
local rank = Ranking.get_rank(player)
if rank:allowed(name) then
if is_type(Role,'table') then
if Role.allowed(player,name) then
button:draw(toolbar_frame)
end
else button:draw(toolbar_frame) end
@@ -49,9 +48,9 @@ function toolbar.draw(player)
end
function toolbar:on_init()
if loaded_modules['ExpGamingCore.Ranking'] then Ranking = require('ExpGamingCore.Ranking') end
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
end
toolbar.on_rank_change = toolbar.draw
toolbar.on_role_change = toolbar.draw
toolbar.on_player_joined_game = toolbar.draw
return toolbar