From 1c5c3a0f3707ebd18e4d712b4cf9395b5777ece2 Mon Sep 17 00:00:00 2001 From: Vortex <73261680+Vortex2Oblivion@users.noreply.github.com> Date: Sat, 4 Jan 2025 10:54:30 -0500 Subject: [PATCH] fix some script crashes? --- source/modding/scripts/languages/HScript.hx | 2 +- source/modding/scripts/languages/LuaScript.hx | 25 ++--------------- source/states/PlayState.hx | 27 +++++++++++++++---- 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/source/modding/scripts/languages/HScript.hx b/source/modding/scripts/languages/HScript.hx index e2da1911e5..b92e7eacbc 100644 --- a/source/modding/scripts/languages/HScript.hx +++ b/source/modding/scripts/languages/HScript.hx @@ -79,7 +79,7 @@ class HScript extends Script { parser = null; program = null; interp = null; - + for (script in otherScripts) { script?.destroy(); } diff --git a/source/modding/scripts/languages/LuaScript.hx b/source/modding/scripts/languages/LuaScript.hx index 3a8bc27e86..53bf6385f5 100644 --- a/source/modding/scripts/languages/LuaScript.hx +++ b/source/modding/scripts/languages/LuaScript.hx @@ -131,29 +131,8 @@ class LuaScript extends Script { } override public function destroy() { - PlayState.songMultiplier = oldMultiplier; - - for (sound in LuaScript.lua_Sounds) { - sound?.stop(); - sound?.kill(); - sound?.destroy(); - } - LuaScript.killShaders(); - LuaScript.lua_Characters.clear(); - LuaScript.lua_Sounds.clear(); - LuaScript.lua_Sprites.clear(); - LuaScript.lua_Shaders.clear(); - LuaScript.lua_Custom_Shaders.clear(); - LuaScript.lua_Cameras.clear(); - LuaScript.lua_Jsons.clear(); - trails.clear(); - - for(script in otherScripts){ - script?.destroy(); - } - - Lua.close(lua); - lua = null; + /*Lua.close(lua); + lua = null;*/ } function getLuaErrorMessage(l) { diff --git a/source/states/PlayState.hx b/source/states/PlayState.hx index 9ccb91280c..504d35f677 100644 --- a/source/states/PlayState.hx +++ b/source/states/PlayState.hx @@ -760,6 +760,12 @@ class PlayState extends MusicBeatState { DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyStr + ")", iconRPC); #end + + strumLine = new FlxSprite(0, 100).makeGraphic(FlxG.width, 10); + + if (Options.getData("downscroll")) + strumLine.y = FlxG.height - 100; + // stage maker stage = new StageGroup(Options.getData("charsAndBGs") ? curStage : ""); stageMap.set(stage.stage, stage); @@ -857,11 +863,6 @@ class PlayState extends MusicBeatState { Conductor.songPosition = -5000; - strumLine = new FlxSprite(0, 100).makeGraphic(FlxG.width, 10); - - if (Options.getData("downscroll")) - strumLine.y = FlxG.height - 100; - strumLine.scrollFactor.set(); strumLineNotes = new FlxTypedGroup(); @@ -3987,6 +3988,22 @@ class PlayState extends MusicBeatState { for (script in scripts) { script?.destroy(); } + + for (sound in LuaScript.lua_Sounds) { + sound?.stop(); + sound?.kill(); + sound?.destroy(); + } + LuaScript.killShaders(); + LuaScript.lua_Characters.clear(); + LuaScript.lua_Sounds.clear(); + LuaScript.lua_Sprites.clear(); + LuaScript.lua_Shaders.clear(); + LuaScript.lua_Custom_Shaders.clear(); + LuaScript.lua_Cameras.clear(); + LuaScript.lua_Jsons.clear(); + + scripts.clear(); } public function processEvent(event:Array) {