diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index b74bceca1..456dcae3c 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -55,15 +55,6 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset public function prepareInfos(node:Access) return XMLImportedScriptInfo.prepareInfos(node, scripts, (infos) -> xmlImportedScripts.push(infos)); - // backward compat - Nex - private function set_script(script:Script):Script { - if (scripts == null) (scripts = new ScriptPack("Character")).setParent(this); - else scripts.remove(scripts.scripts[0]); - if(script != null) scripts.insert(0, script); - this.script = script; - return script; - } - public var idleSuffix:String = ""; public var stunned(default, set):Bool = false; @@ -443,6 +434,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset return stunned = b; } + // ---- Backwards compat ---- // Interval at which the character will dance (higher number = slower dance) @:noCompletion public var danceInterval(get, set):Int; @:noCompletion private function set_danceInterval(v:Int) @@ -450,6 +442,22 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset @:noCompletion private function get_danceInterval() return beatInterval; + private function set_script(script:Script):Script { + if (scripts == null) (scripts = new ScriptPack("Character")).setParent(this); + + var lastIndex = scripts.scripts.indexOf(this.script); + if(lastIndex >= 0) { + if(script == null) // last != null && new == null + scripts.scripts.splice(lastIndex, 1); + else // last != null && new != null + scripts.scripts[lastIndex] = script; + } else if(script != null) // last == null + scripts.insert(0, script); + + return this.script = script; + } + // ---- end of Backwards compat ---- + public static var FALLBACK_CHARACTER:String = "bf"; public static var FALLBACK_DEAD_CHARACTER:String = "bf-dead";