diff --git a/source/psychlua/ReflectionFunctions.hx b/source/psychlua/ReflectionFunctions.hx index 283e6db50ea..fda913c7ec9 100644 --- a/source/psychlua/ReflectionFunctions.hx +++ b/source/psychlua/ReflectionFunctions.hx @@ -22,13 +22,13 @@ class ReflectionFunctions return LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split, true, allowMaps), split[split.length-1], allowMaps); return LuaUtils.getVarInArray(LuaUtils.getTargetInstance(), variable, allowMaps); }); - Lua_helper.add_callback(lua, "setProperty", function(variable:String, value:Dynamic, ?allowMaps:Bool = false) { + Lua_helper.add_callback(lua, "setProperty", function(variable:String, value:Dynamic, ?allowMaps:Bool = false, ?allowInstances:Bool = false) { var split:Array = variable.split('.'); if(split.length > 1) { - LuaUtils.setVarInArray(LuaUtils.getPropertyLoop(split, true, allowMaps), split[split.length-1], value, allowMaps); + LuaUtils.setVarInArray(LuaUtils.getPropertyLoop(split, true, allowMaps), split[split.length-1], allowInstances ? parseSingleInstance(value) : value, allowMaps); return value; } - LuaUtils.setVarInArray(LuaUtils.getTargetInstance(), variable, value, allowMaps); + LuaUtils.setVarInArray(LuaUtils.getTargetInstance(), variable, allowInstances ? parseSingleInstance(value) : value, allowMaps); return value; }); Lua_helper.add_callback(lua, "getPropertyFromClass", function(classVar:String, variable:String, ?allowMaps:Bool = false) { @@ -49,7 +49,7 @@ class ReflectionFunctions } return LuaUtils.getVarInArray(myClass, variable, allowMaps); }); - Lua_helper.add_callback(lua, "setPropertyFromClass", function(classVar:String, variable:String, value:Dynamic, ?allowMaps:Bool = false) { + Lua_helper.add_callback(lua, "setPropertyFromClass", function(classVar:String, variable:String, value:Dynamic, ?allowMaps:Bool = false, ?allowInstances:Bool = false) { var myClass:Dynamic = Type.resolveClass(classVar); if(myClass == null) { @@ -63,10 +63,10 @@ class ReflectionFunctions for (i in 1...split.length-1) obj = LuaUtils.getVarInArray(obj, split[i], allowMaps); - LuaUtils.setVarInArray(obj, split[split.length-1], value, allowMaps); + LuaUtils.setVarInArray(obj, split[split.length-1], allowInstances ? parseSingleInstance(value) : value, allowMaps); return value; } - LuaUtils.setVarInArray(myClass, variable, value, allowMaps); + LuaUtils.setVarInArray(myClass, variable, allowInstances ? parseSingleInstance(value) : value, allowMaps); return value; }); Lua_helper.add_callback(lua, "getPropertyFromGroup", function(group:String, index:Int, variable:Dynamic, ?allowMaps:Bool = false) { @@ -231,7 +231,7 @@ class ReflectionFunctions return false; } - var obj:Dynamic = Type.createInstance(myType, args); + var obj:Dynamic = Type.createInstance(myType, parseInstances(args)); if(obj != null) MusicBeatState.getVariables().set(variableToSave, obj); else