Fix automator running invalid editor scripts when forceRestart is on (Fixes #3334)

This commit is contained in:
SpectralFlame 2023-04-13 22:37:42 -05:00 committed by cyip92
parent c9fc3e8246
commit 7f8846ed47
2 changed files with 4 additions and 2 deletions

View File

@ -147,7 +147,7 @@ export default {
@click="repeat"
/>
<AutomatorButton
v-tooltip="'Automatically start this script when finishing or restarting a Reality'"
v-tooltip="'Automatically restart the active script when finishing or restarting a Reality'"
class="fa-reply"
:class="{ 'c-automator__button--active' : forceRestartOn }"
@click="restart"

View File

@ -585,7 +585,9 @@ export function finishProcessReality(realityProps) {
}
}
if (Player.automatorUnlocked && AutomatorBackend.state.forceRestart) {
AutomatorBackend.start(player.reality.automator.state.editorScript);
// Make sure to restart the current script instead of using the editor script - the editor script might
// not be a valid script to run; this at best stops it from running and at worst causes a crash
AutomatorBackend.start(AutomatorBackend.state.topLevelScript);
}
if (player.options.automatorEvents.clearOnReality) AutomatorData.clearEventLog();