Skip to content

Commit

Permalink
crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Dec 2, 2023
1 parent 6525680 commit 95a7422
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
3 changes: 3 additions & 0 deletions source/game/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -254,6 +255,8 @@ class Note extends FlxSprite {
override function update(elapsed:Float) {
super.update(elapsed);

angle = angle + modAngle + localAngle;

calculateCanBeHit();

if (!inEditor) {
Expand Down
33 changes: 20 additions & 13 deletions source/modding/ModchartUtilities.hx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class ModchartUtilities {

public var functions_called:Array<String> = [];

private var localFilters:Array<CustomShader> = [];

function getActorByName(id:String):Dynamic {
// lua objects or what ever
if (lua_Sprites.exists(id))
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
});
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
});

Expand Down Expand Up @@ -2727,25 +2736,23 @@ 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) {
var funnyCustomShader:CustomShader = lua_Custom_Shaders.get(id);
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);
}
Expand Down
32 changes: 13 additions & 19 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1840,9 +1834,9 @@ class PlayState extends MusicBeatState {
#end
#end
executeALuaState("startSong", []);
allScriptCall("startSong", []);
allScriptCall("startSong");
executeALuaState("songStart", []);
allScriptCall("songStart", []);
allScriptCall("songStart");

resyncVocals();
}
Expand Down
2 changes: 2 additions & 0 deletions source/substates/PauseSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 95a7422

Please sign in to comment.