From 627f5a4651b2135fd9ea45fee56f0a977e668960 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sat, 29 Sep 2018 18:17:18 +0100 Subject: [PATCH] Fixed Task list and Admin Commands --- modules/ExpGamingAdmin/Gui/control.lua | 3 +- modules/ExpGamingCore/Gui/src/left.lua | 1 + modules/ExpGamingCore/Server/control.lua | 3 +- modules/ExpGamingInfo/Readme/control.lua | 2 +- modules/ExpGamingInfo/Rockets/control.lua | 2 +- modules/ExpGamingInfo/Science/control.lua | 2 +- modules/ExpGamingInfo/Tasklist/control.lua | 36 ++++++++++----------- modules/ExpGamingInfo/Tasklist/softmod.json | 1 + modules/ExpGamingInfo/softmod.json | 1 + modules/index.lua | 8 ++--- 10 files changed, 31 insertions(+), 28 deletions(-) diff --git a/modules/ExpGamingAdmin/Gui/control.lua b/modules/ExpGamingAdmin/Gui/control.lua index 435b04c8..ffaf6286 100644 --- a/modules/ExpGamingAdmin/Gui/control.lua +++ b/modules/ExpGamingAdmin/Gui/control.lua @@ -10,6 +10,7 @@ local Gui = require('ExpGamingCore.Gui@^4.0.0') local Role = require('ExpGamingCore.Role@^4.0.0') local Game = require('FactorioStdLib.Game@^0.8.0') local playerInfo -- ExpGamingPlayer@^4.0.0 +local mod_gui = require('mod-gui') -- Module Define local module_verbose = false @@ -137,7 +138,7 @@ Admin.center = Gui.center.add{ open=function(event,pre_select_player,pre_select_action) local _player = Game.get_player(pre_select_player) local player = Game.get_player(event) - local _center = Gui._get_data('center')['admin-commands'] + local _center = Gui.data.center['admin-commands'] local center_flow = Gui.center.get_flow(player) if center_flow[_center.name] then Gui.center.clear(player) return end local center_frame = center_flow.add{ diff --git a/modules/ExpGamingCore/Gui/src/left.lua b/modules/ExpGamingCore/Gui/src/left.lua index a7ae4499..0075437a 100644 --- a/modules/ExpGamingCore/Gui/src/left.lua +++ b/modules/ExpGamingCore/Gui/src/left.lua @@ -8,6 +8,7 @@ -- @function _comment local Game = require('FactorioStdLib.Game') +local Server = require('ExpGamingCore.Server') local Color = require('FactorioStdLib.Color') local Role -- this is optional and is hanndled by it being present, it is loaded on init local mod_gui = require("mod-gui") diff --git a/modules/ExpGamingCore/Server/control.lua b/modules/ExpGamingCore/Server/control.lua index 24171890..925340da 100644 --- a/modules/ExpGamingCore/Server/control.lua +++ b/modules/ExpGamingCore/Server/control.lua @@ -178,7 +178,7 @@ end --[[ cant be used V --- Adds a event handler to tell threads about events -- @usage Server.add_thread_handler(defines.event) --- @tparam number event the event to run the thread handler on +-- @tparam number event the event to run the thread handler on` -- @treturn bolean if the handler was added function Server.add_thread_handler(event) if not is_type(event,'number') then return false end @@ -458,7 +458,6 @@ script.on_event(defines.events.on_tick,function(event) if #global.timeout > 0 then Server.check_timeouts() end -- timeout checks if #global.queue > 0 then -- resolve one thread local current_thread = global.all[global.queue[1]] - game.print(current_thread.uuid) if current_thread and current_thread:valid() then current_thread:resolve() end end end) diff --git a/modules/ExpGamingInfo/Readme/control.lua b/modules/ExpGamingInfo/Readme/control.lua index 219b26d1..fd078883 100644 --- a/modules/ExpGamingInfo/Readme/control.lua +++ b/modules/ExpGamingInfo/Readme/control.lua @@ -6,7 +6,7 @@ -- Module Require local Gui = require('ExpGamingCore.Gui@^4.0.0') -local Game = require('FactoiorStdLib.Game@^0.8.0') +local Game = require('FactorioStdLib.Game@^0.8.0') -- Module Define local module_verbose = false diff --git a/modules/ExpGamingInfo/Rockets/control.lua b/modules/ExpGamingInfo/Rockets/control.lua index 6dfe0394..9403a0c9 100644 --- a/modules/ExpGamingInfo/Rockets/control.lua +++ b/modules/ExpGamingInfo/Rockets/control.lua @@ -6,7 +6,7 @@ -- Module Require local Gui = require('ExpGamingCore.Gui@^4.0.0') -local Game = require('FactoiorStdLib.Game@^0.8.0') +local Game = require('FactorioStdLib.Game@^0.8.0') -- Module Define local module_verbose = false diff --git a/modules/ExpGamingInfo/Science/control.lua b/modules/ExpGamingInfo/Science/control.lua index 86018e2d..9fb22ad3 100644 --- a/modules/ExpGamingInfo/Science/control.lua +++ b/modules/ExpGamingInfo/Science/control.lua @@ -6,7 +6,7 @@ -- Module Require local Gui = require('ExpGamingCore.Gui@^4.0.0') -local Game = require('FactoiorStdLib.Game@^0.8.0') +local Game = require('FactorioStdLib.Game@^0.8.0') -- Local Varibles local science_packs = { diff --git a/modules/ExpGamingInfo/Tasklist/control.lua b/modules/ExpGamingInfo/Tasklist/control.lua index 042df4f1..1d3c2b8b 100644 --- a/modules/ExpGamingInfo/Tasklist/control.lua +++ b/modules/ExpGamingInfo/Tasklist/control.lua @@ -5,8 +5,9 @@ -- @alais ThisModule -- Module Require -local Gui = require('ExpGamingCore.Role@^4.0.0') -local Game = require('FactoiorStdLib.Game@^0.8.0') +local Gui = require('ExpGamingCore.Gui@^4.0.0') +local Role = require('ExpGamingCore.Role@^4.0.0') +local Game = require('FactorioStdLib.Game@^0.8.0') -- Module Define local module_verbose = false @@ -31,7 +32,7 @@ local edit = Gui.inputs.add{ }:on_event('click',function(event) local text_flow = event.element.parent.parent.text_flow local data = global._edit[event.player_index] - if not data._edit then data._tasks = table.deepcopy(_global().tasks) end + if not data._edit then data._tasks = table.deepcopy(global.tasks) end if text_flow.input.type == 'label' then data._editing[tonumber(text_flow.parent.name)]=true Gui.left.update('tasklist',event.player_index) @@ -71,12 +72,12 @@ local remove = Gui.inputs.add{ caption='utility/remove' }:on_event('click',function(event) local frame = event.element.parent.parent - local data = _global()._edit[event.player_index] + local data = global._edit[event.player_index] if data._edit then table.remove(data._tasks,tonumber(frame.name)) table.remove(data._editing,tonumber(frame.name)) else - table.remove(_global().tasks,tonumber(frame.name)) + table.remove(global.tasks,tonumber(frame.name)) Gui.left.update('tasklist') end Gui.left.update('tasklist',event.player_index) @@ -88,12 +89,12 @@ local add = Gui.inputs.add{ caption='utility/add' }:on_event('click',function(event) local frame = event.element.parent.parent - local data = _global()._edit[event.player_index] + local data = global._edit[event.player_index] if data._edit then table.insert(data._tasks,tonumber(frame.name)+1,'New Value') table.insert(data._editing,tonumber(frame.name)+1,true) else - data._tasks = table.deepcopy(_global().tasks) + data._tasks = table.deepcopy(global.tasks) table.insert(data._tasks,tonumber(frame.name)+1,'New Value') table.insert(data._editing,tonumber(frame.name)+1,true) end @@ -102,8 +103,8 @@ end) local function _tasks(player) local player = Game.get_player(player) - local data = _global()._edit[player.index] - if not data then return _global().tasks end + local data = global._edit[player.index] + if not data then return global.tasks end local _edit = false for _,v in pairs(data._editing) do if v == true then @@ -112,16 +113,16 @@ local function _tasks(player) end end if data._edit and not _edit then - _global().tasks = table.deepcopy(data._tasks) - _global()._edit[player.index] = table.deepcopy(_global()._base) + global.tasks = table.deepcopy(data._tasks) + global._edit[player.index] = table.deepcopy(global._base) Gui.left.update('tasklist') - return _global().tasks + return global.tasks elseif not data._edit and _edit then data._edit = true for key,_ in pairs(data._tasks) do if not data._editing[key] then data._editing[key] = false end end return data._tasks elseif _edit then return data._tasks - else return _global().tasks + else return global.tasks end end @@ -140,11 +141,10 @@ Gui.left.add{ caption={'tasklist.name'}, style='caption_label' } - local data = _global() local player = Game.get_player(frame.player_index) local allowed = Role.allowed(player,'edit-tasklist') if allowed then - if not data._edit[player.index] then data._edit[player.index] = table.deepcopy(data._base) end + if not global._edit[player.index] then global._edit[player.index] = table.deepcopy(global._base) end end for i,task in pairs(_tasks(player)) do local flow = frame.add{ @@ -168,7 +168,7 @@ Gui.left.add{ } if allowed then _edit(button_flow) - if data._edit[player.index]._editing[i] then + if global._edit[player.index]._editing[i] then local element = remove:draw(button_flow) element.style.height = 30 element.style.width = 30 @@ -192,10 +192,10 @@ Gui.left.add{ element.style.height = 20 element.style.width = 20 end - if #_tasks(player) == 0 and not role:allowed('edit-tasklist') then frame.style.visible = false end + if #_tasks(player) == 0 and not allowed then frame.style.visible = false end end, can_open=function(player) - if Role.allowed(player,'edit-tasklist') or #_global().tasks > 0 then return true + if Role.allowed(player,'edit-tasklist') or #global.tasks > 0 then return true else return {'tasklist.none'} end end, open_on_join=true diff --git a/modules/ExpGamingInfo/Tasklist/softmod.json b/modules/ExpGamingInfo/Tasklist/softmod.json index ba743a75..4a749217 100644 --- a/modules/ExpGamingInfo/Tasklist/softmod.json +++ b/modules/ExpGamingInfo/Tasklist/softmod.json @@ -15,6 +15,7 @@ "license": "", "dependencies": { "ExpGamingCore.Gui": "^4.0.0", + "ExpGamingCore.Role": "^4.0.0", "FactoiorStdLib.Game": "^0.8.0" } } \ No newline at end of file diff --git a/modules/ExpGamingInfo/softmod.json b/modules/ExpGamingInfo/softmod.json index a614d7a1..fcdf4b5e 100644 --- a/modules/ExpGamingInfo/softmod.json +++ b/modules/ExpGamingInfo/softmod.json @@ -84,6 +84,7 @@ ], "dependencies": { "ExpGamingCore.Gui": "^4.0.0", + "ExpGamingCore.Role": "^4.0.0", "FactoiorStdLib.Game": "^0.8.0" } } diff --git a/modules/index.lua b/modules/index.lua index 2bc08154..22af24cc 100644 --- a/modules/index.lua +++ b/modules/index.lua @@ -50,8 +50,8 @@ return { ['ExpGamingAdmin.Ban@4.0.0']='./modules/ExpGamingAdmin/Ban', ['ChatPopup@4.0.0']='./modules/ChatPopup', ['DamagePopup@4.0.0']='./modules/DamagePopup', - ['ExpGamingInfo.Readme@4.0.0']='./modules/DamagePopup', - ['ExpGamingInfo.Rockets@4.0.0']='./modules/DamagePopup', - ['ExpGamingInfo.Science@4.0.0']='./modules/DamagePopup', - ['ExpGamingInfo.Tasklist@4.0.0']='./modules/DamagePopup', + ['ExpGamingInfo.Readme@4.0.0']='./modules/ExpGamingInfo/Readme', + ['ExpGamingInfo.Rockets@4.0.0']='./modules/ExpGamingInfo/Rockets', + ['ExpGamingInfo.Science@4.0.0']='./modules/ExpGamingInfo/Science', + ['ExpGamingInfo.Tasklist@4.0.0']='./modules/ExpGamingInfo/Tasklist', } \ No newline at end of file