diff --git a/expcore/datastore.lua b/expcore/datastore.lua index 3fb93017..241699cd 100644 --- a/expcore/datastore.lua +++ b/expcore/datastore.lua @@ -522,7 +522,7 @@ function Datastore:increment(key, delta) return self:set(key, value + (delta or 1)) end -local function update_error(err) error('An error ocurred in datastore update: '..trace(err), 2) end +local function update_error(err) log('An error occurred in datastore update: '..trace(err)) end --[[-- Use a function to update the value locally, will trigger on_update then on_save, save_to_disk and auto_save is required for on_save @tparam any key The key that you want to apply the update to, must be a string unless a serializer is set @tparam function callback The function that will be used to update the value at this key @@ -539,7 +539,9 @@ function Datastore:update(key, callback) local value = self:raw_get(key) local old_value = copy(self:raw_get(key)) local success, new_value = xpcall(callback, update_error, key, value) - if success and new_value ~= nil then + if not success then + self:raw_set(key, old_value) + elseif new_value ~= nil then self:set(key, new_value) else self:raise_event('on_update', key, value, old_value) diff --git a/expcore/gui/top_flow.lua b/expcore/gui/top_flow.lua index e2cb38c1..39bfb99f 100644 --- a/expcore/gui/top_flow.lua +++ b/expcore/gui/top_flow.lua @@ -91,13 +91,15 @@ Gui.toggle_top_flow(game.player, true) ]] function Gui.toggle_top_flow(player, state) - -- Get the top flow and hide button - local top_flow = Gui.get_top_flow(player) + -- Get the top flow, we need the parent as we want to toggle the outer frame + local top_flow = Gui.get_top_flow(player).parent if state == nil then state = not top_flow.visible end - -- Change the visiblty of the flow + -- Get the show button for the top flow local left_flow = Gui.get_left_flow(player) local show_button = left_flow.gui_core_buttons[show_top_flow] + + -- Change the visibility of the top flow and show top flow button show_button.visible = not state top_flow.visible = state diff --git a/expcore/roles.lua b/expcore/roles.lua index edcc989e..2028cd23 100644 --- a/expcore/roles.lua +++ b/expcore/roles.lua @@ -1012,9 +1012,14 @@ local function auto_assign(event) local roles = Roles.config.players[player.name] or {} local lookup = {} - for _, role in ipairs(roles) do lookup[role] = true end + -- Create a lookup table for existing roles, and check for block auto assign + for _, role in ipairs(roles) do + if role.block_auto_assign then return end + lookup[role] = true + end local assigns, ctn = {}, 0 + -- Check roles with auto assign conditions and run the handler for role, condition in pairs(Roles.config.auto_assign) do if not lookup[role] then local success, rtn = pcall(condition, player) @@ -1027,6 +1032,7 @@ local function auto_assign(event) end end + -- Assign new roles if any were passed if ctn > 0 then Roles.assign_player(player, assigns) end end diff --git a/modules/gui/player-list.lua b/modules/gui/player-list.lua index 8d273a5f..06f614f6 100644 --- a/modules/gui/player-list.lua +++ b/modules/gui/player-list.lua @@ -258,7 +258,7 @@ end) :add_to_left_flow(true) --- Button on the top flow used to toggle the player list container --- @element toggle_left_element +-- @element toggle_player_list Gui.left_toolbar_button('entity/character', {'player-list.main-tooltip'}, player_list_container, function(player) return Roles.player_allowed(player, 'gui/player-list') end) diff --git a/modules/gui/rocket-info.lua b/modules/gui/rocket-info.lua index 87a6378c..a8cb673c 100644 --- a/modules/gui/rocket-info.lua +++ b/modules/gui/rocket-info.lua @@ -521,7 +521,7 @@ end) end) --- Button on the top flow used to toggle the container --- @element toggle_left_element +-- @element toggle_rocket_info Gui.left_toolbar_button('item/satellite', {'rocket-info.main-tooltip'}, rocket_list_container, function(player) return Roles.player_allowed(player, 'gui/rocket-info') end) diff --git a/modules/gui/science-info.lua b/modules/gui/science-info.lua index dad0e6c6..345ab04a 100644 --- a/modules/gui/science-info.lua +++ b/modules/gui/science-info.lua @@ -318,7 +318,7 @@ end) :add_to_left_flow() --- Button on the top flow used to toggle the task list container --- @element toggle_left_element +-- @element toggle_science_info Gui.left_toolbar_button('entity/lab', {'science-info.main-tooltip'}, science_info_container, function(player) return Roles.player_allowed(player, 'gui/science-info') end) diff --git a/modules/gui/task-list.lua b/modules/gui/task-list.lua index 4b5c8ed4..276a1c3f 100644 --- a/modules/gui/task-list.lua +++ b/modules/gui/task-list.lua @@ -572,6 +572,12 @@ local update_task = function(player, task_list_element, task_id) element[task_list_item.name].tooltip = {"task-list.last-edit", last_edit_name, format_time(last_edit_time)} end +--- Button on the top flow used to toggle the task list container +-- @element toggle_task_list +Gui.left_toolbar_button('utility/not_enough_repair_packs_icon', {'task-list.main-tooltip'}, task_list_container, function(player) + return Roles.player_allowed(player, 'gui/task-list') +end) + -- Update the footer task edit view local update_task_edit_footer = function(player, task_id) local task = Tasks.get_task(task_id) diff --git a/modules/gui/warp-list.lua b/modules/gui/warp-list.lua index 7f73bde5..69607dcb 100644 --- a/modules/gui/warp-list.lua +++ b/modules/gui/warp-list.lua @@ -687,7 +687,7 @@ end) :add_to_left_flow() --- Button on the top flow used to toggle the warp list container --- @element warp_list_toggle +-- @element toggle_warp_list Gui.left_toolbar_button(config.default_icon.type ..'/'..config.default_icon.name, {'warp-list.main-tooltip', config.standard_proximity_radius}, warp_list_container, function(player) return Roles.player_allowed(player, 'gui/warp-list') end)