Skip to content

Commit

Permalink
allow note colors to be set with lua
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Jan 5, 2025
1 parent 1c5c3a0 commit b5dd9dc
Showing 1 changed file with 55 additions and 8 deletions.
63 changes: 55 additions & 8 deletions source/modding/scripts/languages/LuaScript.hx
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ class LuaScript extends Script {
}

override public function destroy() {
trails.clear();
/*Lua.close(lua);
lua = null;*/
lua = null; */
}

function getLuaErrorMessage(l) {
Expand All @@ -142,7 +143,6 @@ class LuaScript extends Script {
return v;
}


override public function set(name:String, value:Any):Void {
Convert.toLua(lua, value);
Lua.setglobal(lua, name);
Expand All @@ -164,7 +164,7 @@ class LuaScript extends Script {
}

public function new(path:String) {
super(path);
super(path);
lua = LuaL.newstate();
LuaL.openlibs(lua);

Expand Down Expand Up @@ -203,7 +203,7 @@ class LuaScript extends Script {

if (result != 0) {
CoolUtil.coolError("Lua ERROR:\n" + Lua.tostring(lua, result), "Leather Engine Modcharts");
//return;
// return;
// FlxG.switchState(new MainMenuState());
}

Expand Down Expand Up @@ -1364,6 +1364,54 @@ class LuaScript extends Script {
return PlayState.instance.notes.members[id].prevNote.isSustainNote;
});

setFunction("setRenderedNoteColor", function(r:Float, g:Float, b:Float, id:Int) {
var note:Note = PlayState.instance.notes.members[id];
note.colorSwap.r = r;
note.colorSwap.g = g;
note.colorSwap.b = b;
});

setFunction("setUnspawnedNoteColor", function(r:Float, g:Float, b:Float, id:Int) {
var note:Note = PlayState.instance.unspawnNotes[id];
note.colorSwap.r = r;
note.colorSwap.g = g;
note.colorSwap.b = b;
});

setFunction("setRenderedNoteColorForce", function(r:Float, g:Float, b:Float, id:Int) {
var note:Note = PlayState.instance.notes.members[id];
note.shader = note.colorSwap.shader;
note.colorSwap.r = r;
note.colorSwap.g = g;
note.colorSwap.b = b;
});

setFunction("setUnspawnedNoteColorForce", function(r:Float, g:Float, b:Float, id:Int) {
var note:Note = PlayState.instance.unspawnNotes[id];
note.shader = note.colorSwap.shader;
note.colorSwap.r = r;
note.colorSwap.g = g;
note.colorSwap.b = b;
});

setFunction("getRenderedNoteColor", function(id:Int):Dynamic {
var note:Note = PlayState.instance.notes.members[id];
return {r: note.colorSwap.r, g: note.colorSwap.g, b: note.colorSwap.b};
});

setFunction("getUnspawnedNoteColor", function(id:Int):Dynamic {
var note:Note = PlayState.instance.unspawnNotes[id];
return {r: note.colorSwap.r, g: note.colorSwap.g, b: note.colorSwap.b};
});

setFunction("getRenderedNoteAffectedByColor", function(id:Int):Bool {
return PlayState.instance.notes.members[id].affectedbycolor;
});

setFunction("getUnspawnedNoteAffectedByColor", function(id:Int):Bool {
return PlayState.instance.notes.members[id].affectedbycolor;
});

setFunction("anyNotes", function() {
return PlayState.instance.notes.members.length != 0;
});
Expand Down Expand Up @@ -3345,7 +3393,7 @@ class LuaScript extends Script {
set('setModifier', function(beat:Float, argsAsString:String) {
ModchartFuncs.set(beat, argsAsString);
});
set('easeModifier', function(beat:Float, time:Float, easeStr:String, argsAsString:String) {
set('easeModifier', function(beat:Float, time:Float, easeStr:String, argsAsString:String) {
ModchartFuncs.ease(beat, time, easeStr, argsAsString);
});
set('ease', function(beat:Float, time:Float, easeStr:String, argsAsString:String) {
Expand Down Expand Up @@ -3491,7 +3539,7 @@ class LuaScript extends Script {
}

public override function call(func:String, ?arguments:Array<Any>):Bool {
if(arguments == null)
if (arguments == null)
arguments = [];

for (script in otherScripts) {
Expand All @@ -3507,8 +3555,7 @@ class LuaScript extends Script {
if (Lua.pcall(lua, arguments.length, 1, 0) != Lua.LUA_OK) {
Lua.pop(lua, 1);
return false;
}
else{
} else {
Lua.pop(lua, 1);
return true;
}
Expand Down

0 comments on commit b5dd9dc

Please sign in to comment.