diff --git a/source/funkin/backend/MusicBeatState.hx b/source/funkin/backend/MusicBeatState.hx index 725320b4c..11089f0bc 100644 --- a/source/funkin/backend/MusicBeatState.hx +++ b/source/funkin/backend/MusicBeatState.hx @@ -99,6 +99,9 @@ class MusicBeatState extends FlxState implements IBeatReceiver public var scriptsAllowed:Bool = true; + public static var lastScriptName:String = null; + public static var lastStateName:String = null; + public var scriptName:String = null; public static var skipTransOut:Bool = false; @@ -220,7 +223,12 @@ class MusicBeatState extends FlxState implements IBeatReceiver public function new(scriptsAllowed:Bool = true, ?scriptName:String) { super(); this.scriptsAllowed = #if SOFTCODED_STATES scriptsAllowed #else false #end; - this.scriptName = scriptName; + + if(lastStateName != (lastStateName = Type.getClassName(Type.getClass(this)))) { + lastScriptName = null; + } + this.scriptName = scriptName != null ? scriptName : lastScriptName; + lastScriptName = this.scriptName; } function loadScript() {