diff --git a/source/backend/CoolUtil.hx b/source/backend/CoolUtil.hx index 7babc16f9da..9e0d759470f 100644 --- a/source/backend/CoolUtil.hx +++ b/source/backend/CoolUtil.hx @@ -30,7 +30,7 @@ class CoolUtil { var hideChars = ~/[\t\n\r]/; var color:String = hideChars.split(color).join('').trim(); - if(color.startsWith('0x')) color = color.substring(color.length - 6); + if(color.startsWith('0x')) color = color.substring(color.length - (color.length >= 10 ? 8 : 6)); var colorNum:Null = FlxColor.fromString(color); if(colorNum == null) colorNum = FlxColor.fromString('#$color'); diff --git a/source/psychlua/FunkinLua.hx b/source/psychlua/FunkinLua.hx index 0ea6c6dcf6e..719d0909e8e 100644 --- a/source/psychlua/FunkinLua.hx +++ b/source/psychlua/FunkinLua.hx @@ -194,6 +194,7 @@ class FunkinLua { set('healthBarAlpha', ClientPrefs.data.healthBarAlpha); set('noResetButton', ClientPrefs.data.noReset); set('lowQuality', ClientPrefs.data.lowQuality); + set('antialiasing', ClientPrefs.data.antialiasing); set('shadersEnabled', ClientPrefs.data.shaders); set('scriptName', scriptName); set('currentModDirectory', Mods.currentModDirectory); @@ -290,6 +291,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); @@ -388,35 +392,34 @@ class FunkinLua { FlxG.sound.music.pause(); FlxG.sound.music.volume = 0; - if(game != null && game.vocals != null) + if(game != null) { - game.vocals.pause(); - game.vocals.volume = 0; + 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; }); Lua_helper.add_callback(lua, "loadGraphic", function(variable:String, image:String, ?gridX:Int = 0, ?gridY:Int = 0) { - var split:Array = variable.split('.'); - var spr:FlxSprite = LuaUtils.getObjectDirectly(split[0]); + var spr:FlxSprite = LuaUtils.getObjectLoop(variable); var animated = gridX != 0 || gridY != 0; - if(split.length > 1) { - spr = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } - if(spr != null && image != null && image.length > 0) { spr.loadGraphic(Paths.image(image), animated, gridX, gridY); } }); Lua_helper.add_callback(lua, "loadFrames", function(variable:String, image:String, spriteType:String = 'auto') { - var split:Array = variable.split('.'); - var spr:FlxSprite = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - spr = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } - + var spr:FlxSprite = LuaUtils.getObjectLoop(variable); if(spr != null && image != null && image.length > 0) { LuaUtils.loadFrames(spr, image, spriteType); @@ -425,7 +428,7 @@ class FunkinLua { //shitass stuff for epic coders like me B) *image of obama giving himself a medal* Lua_helper.add_callback(lua, "getObjectOrder", function(obj:String, ?group:String = null) { - var leObj:FlxBasic = LuaUtils.getObjectDirectly(obj); + var leObj:FlxBasic = LuaUtils.getObjectLoop(obj); if(leObj != null) { if(group != null) @@ -454,7 +457,7 @@ class FunkinLua { return -1; }); Lua_helper.add_callback(lua, "setObjectOrder", function(obj:String, position:Int, ?group:String = null) { - var leObj:FlxBasic = LuaUtils.getObjectDirectly(obj); + var leObj:FlxBasic = LuaUtils.getObjectLoop(obj); if(leObj != null) { if(group != null) @@ -496,7 +499,8 @@ class FunkinLua { if(tag != null) { var variables = MusicBeatState.getVariables(); - var originalTag:String = 'tween_' + LuaUtils.formatVariable(tag); + var originalTag = tag; + tag = LuaUtils.formatVariable('tween_$tag'); variables.set(tag, FlxTween.tween(penisExam, values, duration, myOptions != null ? { type: myOptions.type, ease: myOptions.ease, @@ -565,15 +569,19 @@ class FunkinLua { Lua_helper.add_callback(lua, "doTweenColor", function(tag:String, vars:String, targetColor:String, duration:Float, ?ease:String = 'linear') { var penisExam:Dynamic = LuaUtils.tweenPrepare(tag, vars); if(penisExam != null) { + targetColor = targetColor.trim(); + var newColor:FlxColor = CoolUtil.colorFromString(targetColor); + if(targetColor.startsWith('0x') && targetColor.length == 8 || !FlxColor.colorLookup.exists(targetColor.toUpperCase()) && targetColor.length == 6) newColor.alphaFloat = penisExam.alpha; + var curColor:FlxColor = penisExam.color; curColor.alphaFloat = penisExam.alpha; - + if(tag != null) { var originalTag:String = tag; tag = LuaUtils.formatVariable('tween_$tag'); var variables = MusicBeatState.getVariables(); - variables.set(tag, FlxTween.color(penisExam, duration, curColor, CoolUtil.colorFromString(targetColor), {ease: LuaUtils.getTweenEaseByString(ease), + variables.set(tag, FlxTween.color(penisExam, duration, curColor, newColor, {ease: LuaUtils.getTweenEaseByString(ease), onComplete: function(twn:FlxTween) { variables.remove(tag); @@ -855,61 +863,37 @@ class FunkinLua { }); Lua_helper.add_callback(lua, "getMidpointX", function(variable:String) { - var split:Array = variable.split('.'); - var obj:FlxObject = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - obj = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } + var obj:FlxObject = LuaUtils.getObjectLoop(variable); if(obj != null) return obj.getMidpoint().x; return 0; }); Lua_helper.add_callback(lua, "getMidpointY", function(variable:String) { - var split:Array = variable.split('.'); - var obj:FlxObject = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - obj = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } + var obj:FlxObject = LuaUtils.getObjectLoop(variable); if(obj != null) return obj.getMidpoint().y; return 0; }); Lua_helper.add_callback(lua, "getGraphicMidpointX", function(variable:String) { - var split:Array = variable.split('.'); - var obj:FlxSprite = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - obj = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } + var obj:FlxSprite = LuaUtils.getObjectLoop(variable); if(obj != null) return obj.getGraphicMidpoint().x; return 0; }); Lua_helper.add_callback(lua, "getGraphicMidpointY", function(variable:String) { - var split:Array = variable.split('.'); - var obj:FlxSprite = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - obj = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } + var obj:FlxSprite = LuaUtils.getObjectLoop(variable); if(obj != null) return obj.getGraphicMidpoint().y; return 0; }); Lua_helper.add_callback(lua, "getScreenPositionX", function(variable:String, ?camera:String = 'game') { - var split:Array = variable.split('.'); - var obj:FlxObject = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - obj = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } + var obj:FlxObject = LuaUtils.getObjectLoop(variable); if(obj != null) return obj.getScreenPosition(LuaUtils.cameraFromString(camera)).x; return 0; }); Lua_helper.add_callback(lua, "getScreenPositionY", function(variable:String, ?camera:String = 'game') { - var split:Array = variable.split('.'); - var obj:FlxObject = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - obj = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } + var obj:FlxObject = LuaUtils.getObjectLoop(variable); if(obj != null) return obj.getScreenPosition(LuaUtils.cameraFromString(camera)).y; return 0; @@ -943,7 +927,7 @@ class FunkinLua { }); Lua_helper.add_callback(lua, "makeGraphic", function(obj:String, width:Int = 256, height:Int = 256, color:String = 'FFFFFF') { - var spr:FlxSprite = LuaUtils.getObjectDirectly(obj); + var spr:FlxSprite = LuaUtils.getObjectLoop(obj); if(spr != null) spr.makeGraphic(width, height, CoolUtil.colorFromString(color)); }); Lua_helper.add_callback(lua, "addAnimationByPrefix", function(obj:String, name:String, prefix:String, framerate:Float = 24, loop:Bool = true) { @@ -997,12 +981,7 @@ class FunkinLua { }); Lua_helper.add_callback(lua, "setScrollFactor", function(obj:String, scrollX:Float, scrollY:Float) { - if(game.getLuaObject(obj) != null) { - game.getLuaObject(obj).scrollFactor.set(scrollX, scrollY); - return; - } - - var object:FlxObject = Reflect.getProperty(LuaUtils.getTargetInstance(), obj); + var object:FlxObject = LuaUtils.getObjectLoop(obj); if(object != null) { object.scrollFactor.set(scrollX, scrollY); } @@ -1023,19 +1002,7 @@ class FunkinLua { } }); Lua_helper.add_callback(lua, "setGraphicSize", function(obj:String, x:Float, y:Float = 0, updateHitbox:Bool = true) { - if(game.getLuaObject(obj)!=null) { - var shit:FlxSprite = game.getLuaObject(obj); - shit.setGraphicSize(x, y); - if(updateHitbox) shit.updateHitbox(); - return; - } - - var split:Array = obj.split('.'); - var poop:FlxSprite = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - poop = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } - + var poop:FlxSprite = LuaUtils.getObjectLoop(obj); if(poop != null) { poop.setGraphicSize(x, y); if(updateHitbox) poop.updateHitbox(); @@ -1044,19 +1011,7 @@ class FunkinLua { luaTrace('setGraphicSize: Couldnt find object: ' + obj, false, false, FlxColor.RED); }); Lua_helper.add_callback(lua, "scaleObject", function(obj:String, x:Float, y:Float, updateHitbox:Bool = true) { - if(game.getLuaObject(obj)!=null) { - var shit:FlxSprite = game.getLuaObject(obj); - shit.scale.set(x, y); - if(updateHitbox) shit.updateHitbox(); - return; - } - - var split:Array = obj.split('.'); - var poop:FlxSprite = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - poop = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } - + var poop:FlxSprite = LuaUtils.getObjectLoop(obj); if(poop != null) { poop.scale.set(x, y); if(updateHitbox) poop.updateHitbox(); @@ -1065,18 +1020,7 @@ class FunkinLua { luaTrace('scaleObject: Couldnt find object: ' + obj, false, false, FlxColor.RED); }); Lua_helper.add_callback(lua, "updateHitbox", function(obj:String) { - if(game.getLuaObject(obj)!=null) { - var shit:FlxSprite = game.getLuaObject(obj); - shit.updateHitbox(); - return; - } - - var split:Array = obj.split('.'); - var poop:FlxSprite = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - poop = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } - + var poop:FlxSprite = LuaUtils.getObjectLoop(obj); if(poop != null) { poop.updateHitbox(); return; @@ -1110,7 +1054,7 @@ class FunkinLua { return (obj != null && Std.isOfType(obj, FlxText)); }); Lua_helper.add_callback(lua, "luaSoundExists", function(tag:String) { - var obj:FlxSound = MusicBeatState.getVariables().get('sound_$tag'); + var obj:FlxSound = MusicBeatState.getVariables().get(LuaUtils.formatVariable('sound_$tag')); return (obj != null && Std.isOfType(obj, FlxSound)); }); @@ -1134,18 +1078,7 @@ class FunkinLua { }); Lua_helper.add_callback(lua, "setObjectCamera", function(obj:String, camera:String = 'game') { - var real:FlxBasic = game.getLuaObject(obj); - if(real != null) { - real.cameras = [LuaUtils.cameraFromString(camera)]; - return true; - } - - var split:Array = obj.split('.'); - var object:FlxBasic = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - object = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } - + var object:FlxBasic = LuaUtils.getObjectLoop(obj); if(object != null) { object.cameras = [LuaUtils.cameraFromString(camera)]; return true; @@ -1154,18 +1087,7 @@ class FunkinLua { return false; }); Lua_helper.add_callback(lua, "setBlendMode", function(obj:String, blend:String = '') { - var real:FlxSprite = game.getLuaObject(obj); - if(real != null) { - real.blend = LuaUtils.blendModeFromString(blend); - return true; - } - - var split:Array = obj.split('.'); - var spr:FlxSprite = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - spr = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } - + var spr:FlxSprite = LuaUtils.getObjectLoop(obj); if(spr != null) { spr.blend = LuaUtils.blendModeFromString(blend); return true; @@ -1174,53 +1096,36 @@ class FunkinLua { return false; }); Lua_helper.add_callback(lua, "screenCenter", function(obj:String, pos:String = 'xy') { - var spr:FlxObject = game.getLuaObject(obj); - - if(spr==null){ - var split:Array = obj.split('.'); - spr = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - spr = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } - } - + var spr:FlxObject = LuaUtils.getObjectLoop(obj); if(spr != null) { switch(pos.trim().toLowerCase()) { case 'x': spr.screenCenter(X); - return; case 'y': spr.screenCenter(Y); - return; default: spr.screenCenter(XY); - return; } + return; } luaTrace("screenCenter: Object " + obj + " doesn't exist!", false, false, FlxColor.RED); }); Lua_helper.add_callback(lua, "objectsOverlap", function(obj1:String, obj2:String) { var namesArray:Array = [obj1, obj2]; var objectsArray:Array = []; - for (i in 0...namesArray.length) + for (tag in namesArray) { - var real:FlxBasic = game.getLuaObject(namesArray[i]); - if(real != null) - objectsArray.push(real); - else - objectsArray.push(Reflect.getProperty(LuaUtils.getTargetInstance(), namesArray[i])); + var obj:FlxBasic = LuaUtils.getObjectLoop(tag); + if(obj != null) { + objectsArray.push(obj); + } } return (!objectsArray.contains(null) && FlxG.overlap(objectsArray[0], objectsArray[1])); }); Lua_helper.add_callback(lua, "getPixelColor", function(obj:String, x:Int, y:Int) { - var split:Array = obj.split('.'); - var spr:FlxSprite = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - spr = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } - + var spr:FlxSprite = LuaUtils.getObjectLoop(obj); if(spr != null) return spr.pixels.getPixel32(x, y); return FlxColor.BLACK; }); diff --git a/source/psychlua/LuaUtils.hx b/source/psychlua/LuaUtils.hx index 9f84dc581fe..e5923565d8f 100644 --- a/source/psychlua/LuaUtils.hx +++ b/source/psychlua/LuaUtils.hx @@ -231,6 +231,12 @@ class LuaUtils return Reflect.getProperty(leArray, variable); } + public static function getObjectLoop(objectName:String, ?allowMaps:Bool = false):Dynamic + { + var split:Array = objectName.split('.'); + return split.length > 1 ? getVarInArray(getPropertyLoop(split, true, allowMaps), split[split.length-1], allowMaps) : getObjectDirectly(objectName); + } + public static function getPropertyLoop(split:Array, ?getProperty:Bool=true, ?allowMaps:Bool = false):Dynamic { var obj:Dynamic = getObjectDirectly(split[0]); @@ -250,7 +256,7 @@ class LuaUtils default: var obj:Dynamic = MusicBeatState.getVariables().get(objectName); - if(obj == null) obj = getVarInArray(MusicBeatState.getState(), objectName, allowMaps); + if(obj == null) obj = getVarInArray(getTargetInstance(), objectName, allowMaps); return obj; } } @@ -386,10 +392,7 @@ class LuaUtils public static function tweenPrepare(tag:String, vars:String) { if(tag != null) cancelTween(tag); - var variables:Array = vars.split('.'); - var sexyProp:Dynamic = LuaUtils.getObjectDirectly(variables[0]); - if(variables.length > 1) sexyProp = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(variables), variables[variables.length-1]); - return sexyProp; + return getObjectLoop(vars); } public static function getBuildTarget():String diff --git a/source/psychlua/ReflectionFunctions.hx b/source/psychlua/ReflectionFunctions.hx index 3d6adc273c9..a3b07f8e68f 100644 --- a/source/psychlua/ReflectionFunctions.hx +++ b/source/psychlua/ReflectionFunctions.hx @@ -95,7 +95,7 @@ class ReflectionFunctions FunkinLua.luaTrace('getPropertyFromGroup: Object #$index from group: $group doesn\'t exist!', false, false, FlxColor.RED); default: //Is Group - var result:Dynamic = LuaUtils.getGroupStuff(realObject.members[index], variable, allowMaps); + var result:Dynamic = LuaUtils.getGroupStuff(Reflect.getProperty(realObject, 'members')[index], variable, allowMaps); return result; } } @@ -127,7 +127,7 @@ class ReflectionFunctions } default: //Is Group - LuaUtils.setGroupStuff(realObject.members[index], variable, allowInstances ? parseSingleInstance(value) : value, allowMaps); + LuaUtils.setGroupStuff(Reflect.getProperty(realObject, 'members')[index], variable, allowInstances ? parseSingleInstance(value) : value, allowMaps); } } else FunkinLua.luaTrace('setPropertyFromGroup: Group/Array $group doesn\'t exist!', false, false, FlxColor.RED); @@ -191,7 +191,7 @@ class ReflectionFunctions else groupOrArray.remove(groupOrArray[index]); default: //Is Group - if(obj == null) obj = groupOrArray.members[index]; + if(obj == null) obj = Reflect.getProperty(groupOrArray, 'members')[index]; // Reflect here because of FlxTypedSpriteGroup groupOrArray.remove(obj, true); if(destroy) obj.destroy(); } diff --git a/source/psychlua/ShaderFunctions.hx b/source/psychlua/ShaderFunctions.hx index 772f6f8916f..f467aa0f2c0 100644 --- a/source/psychlua/ShaderFunctions.hx +++ b/source/psychlua/ShaderFunctions.hx @@ -31,12 +31,7 @@ class ShaderFunctions return false; } - var split:Array = obj.split('.'); - var leObj:FlxSprite = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - leObj = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } - + var leObj:FlxSprite = LuaUtils.getObjectLoop(obj); if(leObj != null) { var arr:Array = funk.runtimeShaders.get(shader); leObj.shader = new FlxRuntimeShader(arr[0], arr[1]); @@ -48,12 +43,7 @@ class ShaderFunctions return false; }); Lua_helper.add_callback(lua, "removeSpriteShader", function(obj:String) { - var split:Array = obj.split('.'); - var leObj:FlxSprite = LuaUtils.getObjectDirectly(split[0]); - if(split.length > 1) { - leObj = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - } - + var leObj:FlxSprite = LuaUtils.getObjectLoop(obj); if(leObj != null) { leObj.shader = null; return true; @@ -268,11 +258,7 @@ class ShaderFunctions #if (!flash && MODS_ALLOWED && sys) public static function getShader(obj:String):FlxRuntimeShader { - var split:Array = obj.split('.'); - var target:FlxSprite = null; - if(split.length > 1) target = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]); - else target = LuaUtils.getObjectDirectly(split[0]); - + var target:FlxSprite = LuaUtils.getObjectLoop(obj); if(target == null) { FunkinLua.luaTrace('Error on getting shader: Object $obj not found', false, false, FlxColor.RED); diff --git a/source/psychlua/TextFunctions.hx b/source/psychlua/TextFunctions.hx index 2412a55f95b..dee85b28b33 100644 --- a/source/psychlua/TextFunctions.hx +++ b/source/psychlua/TextFunctions.hx @@ -18,8 +18,7 @@ class TextFunctions }); Lua_helper.add_callback(lua, "setTextString", function(tag:String, text:String) { - var split:Array = tag.split('.'); - var obj:FlxText = split.length > 1 ? (LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1])) : LuaUtils.getObjectDirectly(split[0]); + var obj:FlxText = LuaUtils.getObjectLoop(tag); if(obj != null) { obj.text = text; @@ -29,8 +28,7 @@ class TextFunctions return false; }); Lua_helper.add_callback(lua, "setTextSize", function(tag:String, size:Int) { - var split:Array = tag.split('.'); - var obj:FlxText = split.length > 1 ? (LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1])) : LuaUtils.getObjectDirectly(split[0]); + var obj:FlxText = LuaUtils.getObjectLoop(tag); if(obj != null) { obj.size = size; @@ -40,8 +38,7 @@ class TextFunctions return false; }); Lua_helper.add_callback(lua, "setTextWidth", function(tag:String, width:Float) { - var split:Array = tag.split('.'); - var obj:FlxText = split.length > 1 ? (LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1])) : LuaUtils.getObjectDirectly(split[0]); + var obj:FlxText = LuaUtils.getObjectLoop(tag); if(obj != null) { obj.fieldWidth = width; @@ -51,8 +48,7 @@ class TextFunctions return false; }); Lua_helper.add_callback(lua, "setTextHeight", function(tag:String, height:Float) { - var split:Array = tag.split('.'); - var obj:FlxText = split.length > 1 ? (LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1])) : LuaUtils.getObjectDirectly(split[0]); + var obj:FlxText = LuaUtils.getObjectLoop(tag); if(obj != null) { obj.fieldHeight = height; @@ -62,8 +58,7 @@ class TextFunctions return false; }); Lua_helper.add_callback(lua, "setTextAutoSize", function(tag:String, value:Bool) { - var split:Array = tag.split('.'); - var obj:FlxText = split.length > 1 ? (LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1])) : LuaUtils.getObjectDirectly(split[0]); + var obj:FlxText = LuaUtils.getObjectLoop(tag); if(obj != null) { obj.autoSize = value; @@ -73,8 +68,7 @@ class TextFunctions return false; }); Lua_helper.add_callback(lua, "setTextBorder", function(tag:String, size:Float, color:String, ?style:String = 'outline') { - var split:Array = tag.split('.'); - var obj:FlxText = split.length > 1 ? (LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1])) : LuaUtils.getObjectDirectly(split[0]); + var obj:FlxText = LuaUtils.getObjectLoop(tag); if(obj != null) { CoolUtil.setTextBorderFromString(obj, (size > 0 ? style : 'none')); @@ -88,8 +82,7 @@ class TextFunctions return false; }); Lua_helper.add_callback(lua, "setTextColor", function(tag:String, color:String) { - var split:Array = tag.split('.'); - var obj:FlxText = split.length > 1 ? (LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1])) : LuaUtils.getObjectDirectly(split[0]); + var obj:FlxText = LuaUtils.getObjectLoop(tag); if(obj != null) { obj.color = CoolUtil.colorFromString(color); @@ -99,8 +92,7 @@ class TextFunctions return false; }); Lua_helper.add_callback(lua, "setTextFont", function(tag:String, newFont:String) { - var split:Array = tag.split('.'); - var obj:FlxText = split.length > 1 ? (LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1])) : LuaUtils.getObjectDirectly(split[0]); + var obj:FlxText = LuaUtils.getObjectLoop(tag); if(obj != null) { obj.font = Paths.font(newFont); @@ -110,8 +102,7 @@ class TextFunctions return false; }); Lua_helper.add_callback(lua, "setTextItalic", function(tag:String, italic:Bool) { - var split:Array = tag.split('.'); - var obj:FlxText = split.length > 1 ? (LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1])) : LuaUtils.getObjectDirectly(split[0]); + var obj:FlxText = LuaUtils.getObjectLoop(tag); if(obj != null) { obj.italic = italic; @@ -121,8 +112,7 @@ class TextFunctions return false; }); Lua_helper.add_callback(lua, "setTextAlignment", function(tag:String, alignment:String = 'left') { - var split:Array = tag.split('.'); - var obj:FlxText = split.length > 1 ? (LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1])) : LuaUtils.getObjectDirectly(split[0]); + var obj:FlxText = LuaUtils.getObjectLoop(tag); if(obj != null) { obj.alignment = LEFT; @@ -142,8 +132,7 @@ class TextFunctions }); Lua_helper.add_callback(lua, "getTextString", function(tag:String) { - var split:Array = tag.split('.'); - var obj:FlxText = split.length > 1 ? (LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1])) : LuaUtils.getObjectDirectly(split[0]); + var obj:FlxText = LuaUtils.getObjectLoop(tag); if(obj != null && obj.text != null) { return obj.text; @@ -152,8 +141,7 @@ class TextFunctions return null; }); Lua_helper.add_callback(lua, "getTextSize", function(tag:String) { - var split:Array = tag.split('.'); - var obj:FlxText = split.length > 1 ? (LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1])) : LuaUtils.getObjectDirectly(split[0]); + var obj:FlxText = LuaUtils.getObjectLoop(tag); if(obj != null) { return obj.size; @@ -162,8 +150,7 @@ class TextFunctions return -1; }); Lua_helper.add_callback(lua, "getTextFont", function(tag:String) { - var split:Array = tag.split('.'); - var obj:FlxText = split.length > 1 ? (LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1])) : LuaUtils.getObjectDirectly(split[0]); + var obj:FlxText = LuaUtils.getObjectLoop(tag); if(obj != null) { return obj.font; @@ -172,8 +159,7 @@ class TextFunctions return null; }); Lua_helper.add_callback(lua, "getTextWidth", function(tag:String) { - var split:Array = tag.split('.'); - var obj:FlxText = split.length > 1 ? (LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1])) : LuaUtils.getObjectDirectly(split[0]); + var obj:FlxText = LuaUtils.getObjectLoop(tag); if(obj != null) { return obj.fieldWidth;