diff --git a/config/expcore/permission_groups.lua b/config/expcore/permission_groups.lua index 812584b7..236268b4 100644 --- a/config/expcore/permission_groups.lua +++ b/config/expcore/permission_groups.lua @@ -85,7 +85,7 @@ Permission_Groups.new_group('Guest') 'set_auto_launch_rocket', 'change_programmable_speaker_parameters', -- guest 'change_train_stop_station', - 'deconstruct', + --'deconstruct', 'remove_cables', 'remove_train_station', 'reset_assembling_machine', diff --git a/config/expcore/roles.lua b/config/expcore/roles.lua index 236fa347..763fd132 100644 --- a/config/expcore/roles.lua +++ b/config/expcore/roles.lua @@ -197,6 +197,7 @@ Roles.new_role('Regular','Reg') 'command/rainbow', 'command/go-to-spawn', 'command/me', + 'standard-decon' } :set_auto_assign_condition(function(player) if player.online_time > 3*216000 then diff --git a/modules/addons/tree-decon.lua b/modules/addons/tree-decon.lua index ac065342..ea7bfb8f 100644 --- a/modules/addons/tree-decon.lua +++ b/modules/addons/tree-decon.lua @@ -16,21 +16,37 @@ end) -- Add trees to queue when marked, only allows simple entities and for players with role permission Event.add(defines.events.on_marked_for_deconstruction, function(event) - -- Check the player is allowed fast decon - local player = Game.get_player_by_index(event.player_index) - if chache[player.name] ~= true and not Roles.player_allowed(player, 'fast-tree-decon') then - chache[player.name] = false + -- Check which type of decon a player is allowed + local index = event.player_index + if chache[index] == nil then + local player = Game.get_player_by_index(index) + if Roles.player_allowed(player, 'fast-tree-decon') then chache[index] = 'fast' + elseif Roles.player_allowed(player, 'standard-decon') then chache[index] = 'standard' + else chache[index] = player.force end + end + + -- Check what should happen to this entity + local entity = event.entity + local allow = chache[index] + if not entity or not entity.valid then return end + + -- Not allowed to decon this entity + local last_user = entity.last_user + if last_user and allow ~= 'standard' and allow ~= 'fast' then + entity.cancel_deconstruction(allow) return end - chache[player.name] = true - -- Check that the entity is allowed to be isntant deconed + -- Allowed to decon this entity, but not fast + if allow ~= 'fast' then return end + + -- Allowed fast decon on this entity, just trees local head = tree_queue._head + 1 - local entity = event.entity - if entity and entity.valid and not entity.last_user and entity.type ~= 'cliff' then + if not last_user and entity.type ~= 'cliff' then tree_queue[head] = entity tree_queue._head = head end + end) -- Remove trees at random till the queue is empty diff --git a/modules/gui/player-list.lua b/modules/gui/player-list.lua index d16acd5e..fce43c57 100644 --- a/modules/gui/player-list.lua +++ b/modules/gui/player-list.lua @@ -94,7 +94,7 @@ Gui.element(function(event_trigger,parent,player_data) open_action_bar(toggle_action_bar_flow) -- Add the player name - local player_name_flow = parent.add{ type = 'flow', 'player-name-'..player_data.index } + local player_name_flow = parent.add{ type = 'flow', name = 'player-name-'..player_data.index } local player_name = player_name_flow.add{ type = 'label', name = event_trigger, @@ -364,6 +364,12 @@ Event.add(defines.events.on_player_left_game,function(event) local frame = Gui.get_left_element(player,player_list_container) local scroll_table = frame.container.scroll.table remove_player_base(scroll_table,remove_player) + + local selected_player_name = Store.get(selected_player_store,player) + if selected_player_name == remove_player.name then + Store.clear(selected_player_store,player) + Store.clear(selected_action_store,player) + end end end) diff --git a/modules/gui/readme.lua b/modules/gui/readme.lua index 35691dd9..1f8e8ad4 100644 --- a/modules/gui/readme.lua +++ b/modules/gui/readme.lua @@ -333,4 +333,12 @@ Event.add(defines.events.on_player_joined_game,function(event) if not player.opened then player.gui.center.clear() end +end) + +--- When a player respawns clear center unless the player has something open +Event.add(defines.events.on_player_respawned,function(event) + local player = Game.get_player_by_index(event.player_index) + if not player.opened then + player.gui.center.clear() + end end) \ No newline at end of file