From 95a742236da07a5de0ef21e1d26e1b2a9fd966d3 Mon Sep 17 00:00:00 2001 From: Vortex2Oblivion <73261680+Vortex2Oblivion@users.noreply.github.com> Date: Sat, 2 Dec 2023 11:37:02 -0500 Subject: [PATCH] crash fix --- source/game/Note.hx | 3 +++ source/modding/ModchartUtilities.hx | 33 +++++++++++++++++------------ source/states/PlayState.hx | 32 ++++++++++++---------------- source/substates/PauseSubState.hx | 2 ++ 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/source/game/Note.hx b/source/game/Note.hx index bc30464204..8f63141577 100644 --- a/source/game/Note.hx +++ b/source/game/Note.hx @@ -45,6 +45,7 @@ class Note extends FlxSprite { public var rawNoteData:Int = 0; + public var modAngle:Float = 0; public var localAngle:Float = 0; public var character:Int = 0; @@ -254,6 +255,8 @@ class Note extends FlxSprite { override function update(elapsed:Float) { super.update(elapsed); + angle = angle + modAngle + localAngle; + calculateCanBeHit(); if (!inEditor) { diff --git a/source/modding/ModchartUtilities.hx b/source/modding/ModchartUtilities.hx index 6b56d4f816..e383529f7b 100644 --- a/source/modding/ModchartUtilities.hx +++ b/source/modding/ModchartUtilities.hx @@ -72,6 +72,8 @@ class ModchartUtilities { public var functions_called:Array = []; + private var localFilters:Array = []; + function getActorByName(id:String):Dynamic { // lua objects or what ever if (lua_Sprites.exists(id)) @@ -216,6 +218,8 @@ class ModchartUtilities { if (path == null) path = PolymodAssets.getPath(Paths.lua("modcharts/" + PlayState.SONG.modchartPath)); + //trace('Loaded script file at: $path'); + var result = LuaL.dofile(lua, path); // execute le file if (result != 0) { @@ -1206,7 +1210,7 @@ class ModchartUtilities { }); setLuaFunction("setUnspawnedNoteAngle", function(id:Int, offset:Float) { - PlayState.instance.unspawnNotes[id].angle = offset; + PlayState.instance.unspawnNotes[id].localAngle = offset; }); setLuaFunction("getRenderedNotes", function() { @@ -1248,7 +1252,6 @@ class ModchartUtilities { return PlayState.strumLineNotes.members[Math.floor(Math.abs(PlayState.instance.notes.members[id].noteData))].x; }); - setLuaFunction("getRenderedNoteStrumtime", function(id:Int) { return PlayState.instance.notes.members[id].strumTime; }); @@ -1336,7 +1339,7 @@ class ModchartUtilities { }); setLuaFunction("setRenderedNoteAngle", function(angle:Float, id:Int) { - PlayState.instance.notes.members[id].angle = angle; + PlayState.instance.notes.members[id].modAngle = angle; }); setLuaFunction("setUnspawnedNoteSingAnimPrefix", function(id:Int, prefix:String) { @@ -2668,16 +2671,22 @@ class ModchartUtilities { }); setLuaFunction("setCameraCustomShader", function(id:String, camera:String){ + if (!Options.getData("shaders")) + return; var funnyCustomShader:CustomShader = lua_Custom_Shaders.get(id); cameraFromString(camera).filters = [new ShaderFilter(funnyCustomShader)]; }); setLuaFunction("pushShaderToCamera", function(id:String, camera:String){ + if (!Options.getData("shaders")) + return; var funnyCustomShader:CustomShader = lua_Custom_Shaders.get(id); cameraFromString(camera).filters.push(new ShaderFilter(funnyCustomShader)); }); setLuaFunction("setCameraNoCustomShader", function(camera:String){ + if (!Options.getData("shaders")) + return; cameraFromString(camera).filters = null; }); @@ -2727,15 +2736,16 @@ class ModchartUtilities { }); setLuaFunction("setCameraShader", function(camera:String, id:String){ + if (!Options.getData("shaders")) + return; + + var cam = lua_Cameras.get(camera); var funnyCustomShader:CustomShader = lua_Custom_Shaders.get(id); - if(cameraFromString(camera).filters.length == 0){ - cameraFromString(camera).filters = [new ShaderFilter(funnyCustomShader)]; + if(cam != null && funnyCustomShader != null){ + cam.shaders.push(new ShaderFilter(funnyCustomShader)); //use reflect to workaround compiler errors + cam.shaderNames.push(id); + cam.cam.filters = cam.shaders; } - else{ - cameraFromString(camera).filters.push(new ShaderFilter(funnyCustomShader)); - } - trace("shaders"); - trace(cameraFromString(camera).filters); }); setLuaFunction("setShaderProperty", function(id:String, property:String, value:Dynamic) { @@ -2743,9 +2753,6 @@ class ModchartUtilities { if(Std.isOfType(value, Float)){ funnyCustomShader.setFloat(property, Std.parseFloat(value)); } - else if(Std.isOfType(value, Int)){ - funnyCustomShader.setInt(property, Std.parseInt(value)); - } else{ funnyCustomShader.setBool(property, value); } diff --git a/source/states/PlayState.hx b/source/states/PlayState.hx index fc088c794c..d0b9da7785 100644 --- a/source/states/PlayState.hx +++ b/source/states/PlayState.hx @@ -1447,25 +1447,19 @@ class PlayState extends MusicBeatState { } } - public function reorderCameras(?newCam:FlxCamera = null) - { - var cameras = FlxG.cameras.list.copy(); - for (c in cameras) - { - FlxG.cameras.remove(c, false); - } - for (i in 0...cameras.length) - { - if (i == cameras.length-1 && newCam != null) - { - FlxG.cameras.add(newCam, false); - } - FlxG.cameras.add(cameras[i], false); + public function reorderCameras(?newCam:FlxCamera = null){ + var cameras = FlxG.cameras.list.copy(); + for (c in cameras){ + FlxG.cameras.remove(c, false); + } + for (i in 0...cameras.length){ + if (i == cameras.length-1 && newCam != null){ + FlxG.cameras.add(newCam, false); } - FlxG.cameras.setDefaultDrawTarget(camGame, true); - executeALuaState("onReorderCameras", [newCam]); - allScriptCall("onReorderCameras", [newCam]); + FlxG.cameras.add(cameras[i], false); } + FlxG.cameras.setDefaultDrawTarget(camGame, true); + } public static var playCutsceneLmao:Bool = false; public static var playCutsceneOnPauseLmao:Bool = false; @@ -1840,9 +1834,9 @@ class PlayState extends MusicBeatState { #end #end executeALuaState("startSong", []); - allScriptCall("startSong", []); + allScriptCall("startSong"); executeALuaState("songStart", []); - allScriptCall("songStart", []); + allScriptCall("songStart"); resyncVocals(); } diff --git a/source/substates/PauseSubState.hx b/source/substates/PauseSubState.hx index cb94fe1693..339a89ccd2 100644 --- a/source/substates/PauseSubState.hx +++ b/source/substates/PauseSubState.hx @@ -105,6 +105,8 @@ class PauseSubState extends MusicBeatSubstate { updateAlphabets(); cameras = [pauseCamera]; + if (PlayState.instance.usedLuaCameras) + cameras = [FlxG.cameras.list[FlxG.cameras.list.length-1]]; } var justPressedAcceptLol:Bool = true;