Skip to content

Commit

Permalink
Merge branch 'patch/6.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Cooldude2606 committed May 25, 2020
2 parents 3069185 + d5db186 commit 9135608
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 19 deletions.
9 changes: 9 additions & 0 deletions config/inventory_clear.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--- Config to control when players items are removed, this is a list of event names that will trigger inventory clear
-- @config inventory_clear

local events = defines.events
return {
events.on_player_banned,
events.on_player_kicked,
--events.on_player_left_game
}
15 changes: 15 additions & 0 deletions modules/addons/inventory-clear.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--- Will move players items to spawn when they are banned or kicked, option to clear on leave
-- @addon Inventory-Clear

local Event = require 'utils.event' --- @dep utils.event
local events = require 'config.inventory_clear' --- @dep config.inventory_clear
local move_items = _C.move_items --- @dep expcore.common

local function clear_items(event)
local player = game.players[event.player_index]
local inv = player.get_main_inventory()
move_items(inv.get_contents())
inv.clear()
end

for _, event_name in ipairs(events) do Event.add(event_name, clear_items) end
38 changes: 19 additions & 19 deletions modules/gui/rocket-info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ end
local function update_build_progress(parent,progress_data)
local show_message = true
for _, silo_data in ipairs(progress_data) do
parent.no_silos.visible = false
parent.parent.no_silos.visible = false
parent.visible = true
local silo_name = silo_data.silo_name
local progress_label = parent[silo_name]
if silo_data.remove then
Expand Down Expand Up @@ -310,7 +311,7 @@ local function update_build_progress(parent,progress_data)
end
end
end
if show_message then parent.no_silos.visible = true end
if show_message then parent.parent.no_silos.visible = true parent.visible = false end
end

--- Gets the label data for all the different stats
Expand Down Expand Up @@ -494,13 +495,13 @@ Gui.element(function(event_trigger,parent)
if check_player_permissions(player,'toggle_active') then col_count = col_count+1 end
local progress = section(container,'progress',col_count)
-- Label used when there are no active silos
local no_silos = progress.add{
local no_silos = progress.parent.add{
type = 'label',
name = 'no_silos',
caption = {'rocket-info.progress-no-silos'}
}
no_silos.style.padding = {1,2}
update_build_progress(progress,get_progress_data(force_name))
update_build_progress(progress, get_progress_data(force_name))
end

-- Return the exteral container
Expand Down Expand Up @@ -580,23 +581,22 @@ Event.add(defines.events.on_robot_built_entity,on_built)

--- Redraw the progress section on role change
local function role_update_event(event)
if not config.progress.show_progress then return end
local player = game.players[event.player_index]
local container = Gui.get_left_element(player,rocket_list_container).container
local progress = container.progress
if config.progress.show_progress then
progress.destroy()
local col_count = 3
if check_player_permissions(player,'remote_launch') then col_count = col_count+1 end
if check_player_permissions(player,'toggle_active') then col_count = col_count+1 end
progress = section(container,'progress',col_count)
-- Label used when there are no active silos
progress.add{
type = 'label',
name = 'no_silos',
caption = {'rocket-info.progress-no-silos'}
}
update_build_progress(progress,get_progress_data(player.force.name))
end
local progress_scroll = container.progress
Gui.destroy_if_valid(progress_scroll.table)

local col_count = 3
if check_player_permissions(player,'remote_launch') then col_count = col_count+1 end
if check_player_permissions(player,'toggle_active') then col_count = col_count+1 end
local progress = progress_scroll.add{
type = 'table',
name = 'table',
column_count = col_count
}

update_build_progress(progress, get_progress_data(player.force.name))
end

Event.add(Roles.events.on_role_assigned,role_update_event)
Expand Down

0 comments on commit 9135608

Please sign in to comment.