From 6b6fcac1d17e983c5b7b08d11b772c761b2c916a Mon Sep 17 00:00:00 2001 From: Guillaume ARM Date: Sun, 26 May 2024 05:10:58 +0200 Subject: [PATCH] fix(robot): loadRobotState should set the state using onLoad result --- libs/robot.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/robot.lua b/libs/robot.lua index a10a183..678a217 100644 --- a/libs/robot.lua +++ b/libs/robot.lua @@ -73,7 +73,7 @@ local loadRobotState = function(stateFile, onLoad, onSave) return robot.saveRobotState(stateFile, onSave) end - return onLoad(parsedResult) + return parsedResult, onLoad(parsedResult) end local getAutoSave = function(config, state) @@ -93,7 +93,8 @@ api.create = function(state, givenConfig) local config = getConfig(givenConfig) if config.autoload then - state = loadRobotState(config.stateFilePath, config.onLoad, config.onSave) + local originalState = loadRobotState(config.stateFilePath, config.onLoad, config.onSave) + state = originalState end local autoSave = getAutoSave(config, state) @@ -219,7 +220,9 @@ api.create = function(state, givenConfig) end robot.loadState = function() - return loadRobotState(config.stateFilePath, config.onLoad, config.onSave) + local originalState, transformedState = loadRobotState(config.stateFilePath, config.onLoad, config.onSave) + state = originalState + return transformedState end return robot