diff --git a/source/psychlua/FunkinLua.hx b/source/psychlua/FunkinLua.hx index 95d127aa4ed..94bf2f6767d 100644 --- a/source/psychlua/FunkinLua.hx +++ b/source/psychlua/FunkinLua.hx @@ -212,6 +212,9 @@ class FunkinLua { var runningScripts:Array = []; for (script in game.luaArray) runningScripts.push(script.scriptName); + + for (script in game.hscriptArray) + runningScripts.push(script.origin); return runningScripts; }); @@ -287,6 +290,9 @@ class FunkinLua { Lua_helper.add_callback(lua, "getVar", function(varName:String) { return MusicBeatState.getVariables().get(varName); }); + Lua_helper.add_callback(lua, "removeVar", function(varName:String) { + return MusicBeatState.getVariables().remove(varName); + }); Lua_helper.add_callback(lua, "addLuaScript", function(luaFile:String, ?ignoreAlreadyRunning:Bool = false) { var luaPath:String = findScript(luaFile); @@ -385,10 +391,16 @@ class FunkinLua { FlxG.sound.music.pause(); FlxG.sound.music.volume = 0; - if(game != null && game.vocals != null) - { - game.vocals.pause(); - game.vocals.volume = 0; + if(game != null) { + if (game.vocals != null) { + game.vocals.pause(); + game.vocals.volume = 0; + } + + if (game.opponentVocals != null) { + game.opponentVocals.pause(); + game.opponentVocals.volume = 0; + } } FlxG.camera.followLerp = 0; }); @@ -461,7 +473,7 @@ class FunkinLua { if(tag != null) { var variables = MusicBeatState.getVariables(); - tag = 'tween_' + LuaUtils.formatVariable(tag); + tag = LuaUtils.formatVariable('tween_$tag'); variables.set(tag, FlxTween.tween(penisExam, values, duration, { type: myOptions.type, ease: myOptions.ease, @@ -847,20 +859,22 @@ class FunkinLua { Lua_helper.add_callback(lua, "getScreenPositionX", function(variable:String, ?camera:String = 'game') { var split:Array = variable.split('.'); var obj:FlxSprite = LuaUtils.getObjectDirectly(split[0]); + var cam:FlxCamera = LuaUtils.cameraFromString(camera); if(split.length > 1) { obj = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); } - if(obj != null) return obj.getScreenPosition().x; + if(obj != null) return obj.getScreenPosition(cam).x; return 0; }); Lua_helper.add_callback(lua, "getScreenPositionY", function(variable:String, ?camera:String = 'game') { var split:Array = variable.split('.'); var obj:FlxSprite = LuaUtils.getObjectDirectly(split[0]); + var cam:FlxCamera = LuaUtils.cameraFromString(camera); if(split.length > 1) { obj = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); } - if(obj != null) return obj.getScreenPosition().y; + if(obj != null) return obj.getScreenPosition(cam).y; return 0; }); diff --git a/source/psychlua/HScript.hx b/source/psychlua/HScript.hx index 10fa652b42d..16ec65f013e 100644 --- a/source/psychlua/HScript.hx +++ b/source/psychlua/HScript.hx @@ -264,7 +264,7 @@ class HScript extends Iris { if(funk == null) funk = parentLua; - if(parentLua != null) funk.addLocalCallback(name, func); + if(funk != null) funk.addLocalCallback(name, func); else FunkinLua.luaTrace('createCallback ($name): 3rd argument is null', false, false, FlxColor.RED); }); #end diff --git a/source/psychlua/LuaUtils.hx b/source/psychlua/LuaUtils.hx index 90520bde0b4..6260f5909fb 100644 --- a/source/psychlua/LuaUtils.hx +++ b/source/psychlua/LuaUtils.hx @@ -28,6 +28,7 @@ class LuaUtils public static function getLuaTween(options:Dynamic) { + if (options == null) options = {} return { type: getTweenTypeByString(options.type), startDelay: options.startDelay, diff --git a/source/psychlua/ReflectionFunctions.hx b/source/psychlua/ReflectionFunctions.hx index 283e6db50ea..e31e356b605 100644 --- a/source/psychlua/ReflectionFunctions.hx +++ b/source/psychlua/ReflectionFunctions.hx @@ -53,7 +53,7 @@ class ReflectionFunctions var myClass:Dynamic = Type.resolveClass(classVar); if(myClass == null) { - FunkinLua.luaTrace('getPropertyFromClass: Class $classVar not found', false, false, FlxColor.RED); + FunkinLua.luaTrace('setPropertyFromClass: Class $classVar not found', false, false, FlxColor.RED); return null; } @@ -227,7 +227,7 @@ class ReflectionFunctions if(myType == null) { - FunkinLua.luaTrace('createInstance: Variable $variableToSave is already being used and cannot be replaced!', false, false, FlxColor.RED); + FunkinLua.luaTrace('createInstance: Class $className not found.', false, false, FlxColor.RED); return false; }