Skip to content

Commit

Permalink
fix some script crashes?
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Jan 4, 2025
1 parent 792fa22 commit 1c5c3a0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion source/modding/scripts/languages/HScript.hx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class HScript extends Script {
parser = null;
program = null;
interp = null;

for (script in otherScripts) {
script?.destroy();
}
Expand Down
25 changes: 2 additions & 23 deletions source/modding/scripts/languages/LuaScript.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
27 changes: 22 additions & 5 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<StrumNote>();
Expand Down Expand Up @@ -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<Dynamic>) {
Expand Down

0 comments on commit 1c5c3a0

Please sign in to comment.