From d2f4ed53abab98f936dd1f60914411e46adefc62 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Fri, 12 Oct 2018 22:44:29 +0100 Subject: [PATCH] Most bugs caught --- FactorioSoftmodManager.lua | 2 +- modules/ExpGamingBot/autoMessage/control.lua | 2 +- modules/ExpGamingCore/Command/control.lua | 2 +- modules/ExpGamingCore/Gui/control.lua | 5 +- modules/ExpGamingCore/Gui/order_config.lua | 12 ++++ modules/ExpGamingCore/Gui/src/left.lua | 64 +++++++++++++------ modules/ExpGamingCore/Gui/src/popup.lua | 12 +++- modules/ExpGamingCore/Gui/src/test.lua | 2 +- modules/ExpGamingCore/Gui/src/toolbar.lua | 44 +++++++++++-- modules/ExpGamingCore/Role/control.lua | 20 +++--- modules/ExpGamingCore/Role/src/commands.lua | 2 +- modules/ExpGamingCore/Server/control.lua | 2 +- modules/ExpGamingCore/Server/locale/en.cfg | 2 - modules/ExpGamingCore/Server/src/commands.lua | 2 +- modules/ExpGamingCore/Sync/src/gui.lua | 2 +- modules/ExpGamingCore/Sync/src/ranking.lua | 4 +- .../ExpGamingPlayer/playerList/control.lua | 3 +- .../playerList/src/ranking.lua | 2 + modules/GuiAnnouncements/control.lua | 14 ++-- modules/WornPaths/control.lua | 2 +- 20 files changed, 140 insertions(+), 60 deletions(-) create mode 100644 modules/ExpGamingCore/Gui/order_config.lua delete mode 100644 modules/ExpGamingCore/Server/locale/en.cfg diff --git a/FactorioSoftmodManager.lua b/FactorioSoftmodManager.lua index 1ff7d3ee..d374e8fa 100644 --- a/FactorioSoftmodManager.lua +++ b/FactorioSoftmodManager.lua @@ -467,7 +467,7 @@ Manager.error = setmetatable({ rawget(tbl,'__error_call')(err,2) end 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) end, __index=function(tbl,key) diff --git a/modules/ExpGamingBot/autoMessage/control.lua b/modules/ExpGamingBot/autoMessage/control.lua index 6fcdb6b7..00906d71 100644 --- a/modules/ExpGamingBot/autoMessage/control.lua +++ b/modules/ExpGamingBot/autoMessage/control.lua @@ -54,7 +54,7 @@ script.on_init(function(event) local data = self.data if not data.high_role or not data.low_role 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 for _,message in pairs(data.low) do player_return({'ExpGamingBot-autoMessage.message',message},nil,player) diff --git a/modules/ExpGamingCore/Command/control.lua b/modules/ExpGamingCore/Command/control.lua index aef750ca..5e52d4be 100644 --- a/modules/ExpGamingCore/Command/control.lua +++ b/modules/ExpGamingCore/Command/control.lua @@ -147,7 +147,7 @@ function commands.get_commands(player) if not player then return error('Invalid player',2) end for name,data in pairs(data) 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) elseif err then table.insert(commands,data) end end elseif data.default_admin_only == true and player.admin then table.insert(commands,data) end diff --git a/modules/ExpGamingCore/Gui/control.lua b/modules/ExpGamingCore/Gui/control.lua index c902388e..d30c7dad 100644 --- a/modules/ExpGamingCore/Gui/control.lua +++ b/modules/ExpGamingCore/Gui/control.lua @@ -27,6 +27,7 @@ Gui.data = setmetatable({},{ }) local events = {} +local order_config = require(module_path..'/order_config') Gui.center = require(module_path..'/src/center',{Gui=Gui}) 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) 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.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 diff --git a/modules/ExpGamingCore/Gui/order_config.lua b/modules/ExpGamingCore/Gui/order_config.lua new file mode 100644 index 00000000..3514de34 --- /dev/null +++ b/modules/ExpGamingCore/Gui/order_config.lua @@ -0,0 +1,12 @@ +return { + 'readme', + 'science', + 'rockets', + 'player-list', + 'tasklist', + 'warp-list', + 'polls', + 'announcements', + 'admin-commands', + 'game-settings' +} \ No newline at end of file diff --git a/modules/ExpGamingCore/Gui/src/left.lua b/modules/ExpGamingCore/Gui/src/left.lua index 25e494ef..f656cf7d 100644 --- a/modules/ExpGamingCore/Gui/src/left.lua +++ b/modules/ExpGamingCore/Gui/src/left.lua @@ -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 mod_gui = require("mod-gui") local Gui = Gui -- this is to force gui to remain in the ENV +local order_config = order_config local left = {} 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 function left.override_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} }:on_event('resolve',function(thread) for name,left in pairs(thread.data.frames) do - if left then - left:first_open(thread.data.player) - end + if left then left:first_open(thread.data.player) end end end):queue() end):open() @@ -119,20 +128,26 @@ end -- @usage left:open(player) -- @tparam luaPlayer player the player to open the gui for 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) - if not left_flow[_left.name] then self:first_open(player) end - left_flow[_left.name].style.visible = true + if not left_flow[self.name] then self:first_open(player) end + left_flow[self.name].style.visible = true + left_flow['gui-left-hide'].style.visible = true end --- Used to force the gui closed for the player -- @usage left:open(player) -- @tparam luaPlayer player the player to close the gui for 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) - if not left_flow[_left.name] then self:first_open(player) end - left_flow[_left.name].style.visible = false + if not left_flow[self.name] then self:first_open(player) end + 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 --- 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 frame = left_flow.add{type='frame',name=self.name,style=mod_gui.frame_style,caption=self.caption,direction='vertical'} 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 - 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 end @@ -162,29 +177,33 @@ end function left._prototype:toggle(player) local player = Game.get_player(player) local left_flow = mod_gui.get_frame_flow(player) - if not left_flow[_left.name] then _left:first_open(player) end - local left = left_flow[_left.name] + if not left_flow[self.name] then self:first_open(player) end + local left = left_flow[self.name] local open = false - if is_type(_left.can_open,'function') then - local success, err = pcall(_left.can_open,player) + if is_type(self.can_open,'function') then + local success, err = pcall(self.can_open,player) if not success then error(err) elseif err == true then open = true elseif global.over_ride_left_can_open 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 = true end else open = err end else 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 = true end end if open == true and left.style.visible ~= true then left.style.visible = true + left_flow['gui-left-hide'].style.visible = true else 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 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 @@ -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 local player = Game.get_player(event) 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 - left:first_open(player) + if not done[name] then left:first_open(player) end end end diff --git a/modules/ExpGamingCore/Gui/src/popup.lua b/modules/ExpGamingCore/Gui/src/popup.lua index da6e1738..eadd2cfb 100644 --- a/modules/ExpGamingCore/Gui/src/popup.lua +++ b/modules/ExpGamingCore/Gui/src/popup.lua @@ -22,7 +22,8 @@ function popup.load() tooltip='Close This Popup' }:on_event('click',function(event) 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 @@ -45,7 +46,9 @@ end -- this is used by the script to find the popup flow function popup.flow(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 end @@ -59,10 +62,11 @@ function popup.open(style,data,players) local players = players or game.connected_players local data = data or {} 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 for _,player in pairs(players) do + if _popup.left then _popup.left:close(player) end local flow = popup.flow(player) + flow.style.visible=true local _frame = flow.add{ type='frame', direction='horizontal', @@ -86,7 +90,9 @@ function popup.open(style,data,players) }:on_event('tick',function(thread) if #thread.data.players == 0 then thread:close() return end local player = table.remove(thread.data.players,1) + if _popup.left then _popup.left:close(player) end local flow = popup.flow(player) + flow.style.visible=true local _frame = flow.add{ type='frame', direction='horizontal', diff --git a/modules/ExpGamingCore/Gui/src/test.lua b/modules/ExpGamingCore/Gui/src/test.lua index 54c91014..bb841e24 100644 --- a/modules/ExpGamingCore/Gui/src/test.lua +++ b/modules/ExpGamingCore/Gui/src/test.lua @@ -161,7 +161,7 @@ local send_popup = Gui.inputs{ }:on_event('click',function(event) local player = Game.get_player(event) 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) Gui.popup{ name='test-popup', diff --git a/modules/ExpGamingCore/Gui/src/toolbar.lua b/modules/ExpGamingCore/Gui/src/toolbar.lua index 36532871..f2efa707 100644 --- a/modules/ExpGamingCore/Gui/src/toolbar.lua +++ b/modules/ExpGamingCore/Gui/src/toolbar.lua @@ -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 mod_gui = require("mod-gui") local Gui = Gui -- this is to force gui to remain in the ENV +local order_config = order_config 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 -- @usage toolbar.add('foo','Foo','Test',function() game.print('test') end) -- @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) toolbar_frame.clear() 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 - if is_type(Role,'table') then - if Role.allowed(player,name) then - button(toolbar_frame) - end - else button(toolbar_frame) end + if not done[name] then + if is_type(Role,'table') then + if Role.allowed(player,name) then + button(toolbar_frame) + end + else button(toolbar_frame) end + end end end diff --git a/modules/ExpGamingCore/Role/control.lua b/modules/ExpGamingCore/Role/control.lua index 8e7b40b4..d3fb9a7f 100644 --- a/modules/ExpGamingCore/Role/control.lua +++ b/modules/ExpGamingCore/Role/control.lua @@ -25,9 +25,9 @@ local Role = { rawset(tbl,key,Role.define(value)) 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.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, on_post=function(self) -- loads the roles in config @@ -399,8 +399,8 @@ function Role._prototype:add_player(player,by_player,batch) by_player_index=by_player.index, old_highest=highest.name, role_name=self.name, - batch=batch[2] or {self.name}, - batch_index=batch[1] or 1, + batch=batch and batch[2] or {self.name}, + batch_index=batch and batch[1] or 1, effect='assign' }) end @@ -430,8 +430,8 @@ function Role._prototype:remove_player(player,by_player,batch) by_player_index=by_player.index, old_highest=highest.name, role_name=self.name, - batch=batch[2] or {self.name}, - batch_index=batch[1] or 1, + batch=batch and batch[2] or {self.name}, + batch_index=batch and batch[1] or 1, effect='unassign' }) end @@ -441,7 +441,7 @@ script.on_event(role_change_event_id,function(event) -- varible init local player = Game.get_player(event) 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'} -- 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 @@ -458,8 +458,9 @@ script.on_event(role_change_event_id,function(event) if player.online_time > 60 then -- send a message to other players if event.batch_index == 1 then - local name = table.concat(event.batch,', ') - if event.effect == 'assign' then game.print{'ExpGamingCore-Role.default-print',{'ExpGamingCore-Role.assign',player.name,name,by_player.name}} + local names = {} + 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 end -- log change to file @@ -482,6 +483,7 @@ end) script.on_event(defines.events.on_player_joined_game,function(event) local player = Game.get_player(event) + log(serpent.line(event)) local highest = Role.get_highest(player) or Role.meta.default Group.assign(player,highest.group) player.tag=highest.tag diff --git a/modules/ExpGamingCore/Role/src/commands.lua b/modules/ExpGamingCore/Role/src/commands.lua index 098a7041..77ff2f7f 100644 --- a/modules/ExpGamingCore/Role/src/commands.lua +++ b/modules/ExpGamingCore/Role/src/commands.lua @@ -1,4 +1,4 @@ -local Role = Role +local Role = self commands.add_validation('player-rank',function(value,event) local player,err = commands.validate['player'](value) diff --git a/modules/ExpGamingCore/Server/control.lua b/modules/ExpGamingCore/Server/control.lua index 925340da..4d024e6b 100644 --- a/modules/ExpGamingCore/Server/control.lua +++ b/modules/ExpGamingCore/Server/control.lua @@ -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,'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 - Manager.sandbox(self._timeout,thread._env,self) + Manager.sandbox(self._timeout,self._env,self) end _return = true -- closes the thread to provent any further event calls diff --git a/modules/ExpGamingCore/Server/locale/en.cfg b/modules/ExpGamingCore/Server/locale/en.cfg deleted file mode 100644 index e70ede54..00000000 --- a/modules/ExpGamingCore/Server/locale/en.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[ExpGamingCore_Server] -interface-description=Runs the given input from the script \ No newline at end of file diff --git a/modules/ExpGamingCore/Server/src/commands.lua b/modules/ExpGamingCore/Server/src/commands.lua index 027738cc..4188454c 100644 --- a/modules/ExpGamingCore/Server/src/commands.lua +++ b/modules/ExpGamingCore/Server/src/commands.lua @@ -23,7 +23,7 @@ Server.add_module_to_interface('Server','ExpGamingCore.Server') --- Runs the given input from the script -- @command interface -- @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'} }, function(event,args) local callback = args.code diff --git a/modules/ExpGamingCore/Sync/src/gui.lua b/modules/ExpGamingCore/Sync/src/gui.lua index f37bc2c4..ff89e991 100644 --- a/modules/ExpGamingCore/Sync/src/gui.lua +++ b/modules/ExpGamingCore/Sync/src/gui.lua @@ -99,4 +99,4 @@ script.on_event(defines.events.on_gui_click,function(event) end end) -script.on_event(defines.events.on_player_joined_game,Sync.info_gui) \ No newline at end of file +script.on_event(defines.events.on_player_joined_game,function(event) Sync.info_gui(event) end) \ No newline at end of file diff --git a/modules/ExpGamingCore/Sync/src/ranking.lua b/modules/ExpGamingCore/Sync/src/ranking.lua index 626de0a1..4d1d5c71 100644 --- a/modules/ExpGamingCore/Sync/src/ranking.lua +++ b/modules/ExpGamingCore/Sync/src/ranking.lua @@ -36,7 +36,9 @@ end -- Adds a caption to the info gui that shows the rank given to the player if Sync.add_to_gui then 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 diff --git a/modules/ExpGamingPlayer/playerList/control.lua b/modules/ExpGamingPlayer/playerList/control.lua index e4f0ea23..c326b637 100644 --- a/modules/ExpGamingPlayer/playerList/control.lua +++ b/modules/ExpGamingPlayer/playerList/control.lua @@ -29,7 +29,7 @@ local module_verbose = false local ThisModule = { on_init=function(self) 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 end } @@ -134,7 +134,6 @@ end) 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.rank_change,ThisModule.update) ThisModule.force_update = function() return ThisModule.Gui() end -- when called it will queue an update to the player list diff --git a/modules/ExpGamingPlayer/playerList/src/ranking.lua b/modules/ExpGamingPlayer/playerList/src/ranking.lua index 5d957120..e7f96896 100644 --- a/modules/ExpGamingPlayer/playerList/src/ranking.lua +++ b/modules/ExpGamingPlayer/playerList/src/ranking.lua @@ -1,5 +1,7 @@ local Role = require('ExpGamingCore.Role@^4.0.0') +script.on_event(defines.events.on_role_change,self.update) + return function() local rtn = {} for _,role_name in pairs(Role.order) do diff --git a/modules/GuiAnnouncements/control.lua b/modules/GuiAnnouncements/control.lua index bad8d5ed..5fb0c22c 100644 --- a/modules/GuiAnnouncements/control.lua +++ b/modules/GuiAnnouncements/control.lua @@ -17,7 +17,7 @@ local ThisModule = {} -- Function Define local function _roles(player) - local roles = {'Select Rank'} + local roles = {'Select Role'} local _role = Role.get_highest(player) for index,role_name in pairs(Role.order) do 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) 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 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 sent_to = {'announcements.sent-to',rank_name} local message = event.element.parent.parent.message.text - for index,_role_name in pairs(Role.order) do - if index <= _role.index then - 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 + Gui.popup.open('announcements',{sent_by=sent_by,sent_to=sent_to,message=message},_role:get_players(true)) + event.element.parent.parent.message.text = '' end) ThisModule.Gui = Gui.popup{ @@ -98,7 +94,7 @@ ThisModule.Gui = Gui.popup{ btn.style.width = 25 flow.add{ type='label', - name='rank', + name='role', caption='' }.style.visible = false end diff --git a/modules/WornPaths/control.lua b/modules/WornPaths/control.lua index babae922..49a06e56 100644 --- a/modules/WornPaths/control.lua +++ b/modules/WornPaths/control.lua @@ -69,7 +69,7 @@ script.on_event(defines.events.on_player_changed_position, function(event) end end local chance = paths[tile_name][1]/(count-adjacency_boost) if math.random() < chance then - down_grade(surface,pos) + ThisModule.down_grade(surface,pos) end end)