fix(robot): loadRobotState should set the state using onLoad result
This commit is contained in:
parent
37bfb2965a
commit
6b6fcac1d1
@ -73,7 +73,7 @@ local loadRobotState = function(stateFile, onLoad, onSave)
|
|||||||
return robot.saveRobotState(stateFile, onSave)
|
return robot.saveRobotState(stateFile, onSave)
|
||||||
end
|
end
|
||||||
|
|
||||||
return onLoad(parsedResult)
|
return parsedResult, onLoad(parsedResult)
|
||||||
end
|
end
|
||||||
|
|
||||||
local getAutoSave = function(config, state)
|
local getAutoSave = function(config, state)
|
||||||
@ -93,7 +93,8 @@ api.create = function(state, givenConfig)
|
|||||||
local config = getConfig(givenConfig)
|
local config = getConfig(givenConfig)
|
||||||
|
|
||||||
if config.autoload then
|
if config.autoload then
|
||||||
state = loadRobotState(config.stateFilePath, config.onLoad, config.onSave)
|
local originalState = loadRobotState(config.stateFilePath, config.onLoad, config.onSave)
|
||||||
|
state = originalState
|
||||||
end
|
end
|
||||||
|
|
||||||
local autoSave = getAutoSave(config, state)
|
local autoSave = getAutoSave(config, state)
|
||||||
@ -219,7 +220,9 @@ api.create = function(state, givenConfig)
|
|||||||
end
|
end
|
||||||
|
|
||||||
robot.loadState = function()
|
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
|
end
|
||||||
|
|
||||||
return robot
|
return robot
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user