Skip to content

Commit

Permalink
Lua 😔
Browse files Browse the repository at this point in the history
  • Loading branch information
LarryFrosty authored Aug 20, 2024
1 parent a78d4cc commit 8ce954b
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions source/psychlua/FunkinLua.hx
Original file line number Diff line number Diff line change
Expand Up @@ -535,22 +535,23 @@ class FunkinLua {
if(tag != null)
{
var variables = MusicBeatState.getVariables();
tag = 'tween_' + LuaUtils.formatVariable(tag);
var originalTag = tag;
tag = LuaUtils.formatVariable('tween_$tag');
variables.set(tag, FlxTween.tween(penisExam, values, duration, {
type: myOptions.type,
ease: myOptions.ease,
startDelay: myOptions.startDelay,
loopDelay: myOptions.loopDelay,

onUpdate: function(twn:FlxTween) {
if(myOptions.onUpdate != null) game.callOnLuas(myOptions.onUpdate, [tag, vars]);
if(myOptions.onUpdate != null) game.callOnLuas(myOptions.onUpdate, [originalTag, vars]);
},
onStart: function(twn:FlxTween) {
if(myOptions.onStart != null) game.callOnLuas(myOptions.onStart, [tag, vars]);
if(myOptions.onStart != null) game.callOnLuas(myOptions.onStart, [originalTag, vars]);
},
onComplete: function(twn:FlxTween) {
if(twn.type == FlxTweenType.ONESHOT || twn.type == FlxTweenType.BACKWARD) variables.remove(tag);
if(myOptions.onComplete != null) game.callOnLuas(myOptions.onComplete, [tag, vars]);
if(myOptions.onComplete != null) game.callOnLuas(myOptions.onComplete, [originalTag, vars]);
}
}));
}
Expand Down Expand Up @@ -853,7 +854,7 @@ class FunkinLua {

Lua_helper.add_callback(lua, "getMidpointX", function(variable:String) {
var split:Array<String> = variable.split('.');
var obj:FlxSprite = LuaUtils.getObjectDirectly(split[0]);
var obj:FlxObject = LuaUtils.getObjectDirectly(split[0]);
if(split.length > 1) {
obj = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]);
}
Expand All @@ -863,7 +864,7 @@ class FunkinLua {
});
Lua_helper.add_callback(lua, "getMidpointY", function(variable:String) {
var split:Array<String> = variable.split('.');
var obj:FlxSprite = LuaUtils.getObjectDirectly(split[0]);
var obj:FlxObject = LuaUtils.getObjectDirectly(split[0]);
if(split.length > 1) {
obj = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]);
}
Expand Down Expand Up @@ -893,7 +894,7 @@ class FunkinLua {
});
Lua_helper.add_callback(lua, "getScreenPositionX", function(variable:String, ?camera:String = 'game') {
var split:Array<String> = variable.split('.');
var obj:FlxSprite = LuaUtils.getObjectDirectly(split[0]);
var obj:FlxObject = LuaUtils.getObjectDirectly(split[0]);
if(split.length > 1) {
obj = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]);
}
Expand All @@ -903,7 +904,7 @@ class FunkinLua {
});
Lua_helper.add_callback(lua, "getScreenPositionY", function(variable:String, ?camera:String = 'game') {
var split:Array<String> = variable.split('.');
var obj:FlxSprite = LuaUtils.getObjectDirectly(split[0]);
var obj:FlxObject = LuaUtils.getObjectDirectly(split[0]);
if(split.length > 1) {
obj = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]);
}
Expand Down Expand Up @@ -1118,11 +1119,12 @@ class FunkinLua {
return (obj != null && Std.isOfType(obj, FlxSprite));
});
Lua_helper.add_callback(lua, "luaTextExists", function(tag:String) {
var obj:FlxSprite = MusicBeatState.getVariables().get(tag);
var obj:FlxText = MusicBeatState.getVariables().get(tag);
return (obj != null && Std.isOfType(obj, FlxText));
});
Lua_helper.add_callback(lua, "luaSoundExists", function(tag:String) {
var obj:FlxSprite = MusicBeatState.getVariables().get(tag);
tag = LuaUtils.formatVariable('sound_$tag');
var obj:FlxSound = MusicBeatState.getVariables().get(tag);
return (obj != null && Std.isOfType(obj, FlxSound));
});

Expand Down Expand Up @@ -1153,7 +1155,7 @@ class FunkinLua {
}

var split:Array<String> = obj.split('.');
var object:FlxSprite = LuaUtils.getObjectDirectly(split[0]);
var object:FlxBasic = LuaUtils.getObjectDirectly(split[0]);
if(split.length > 1) {
object = LuaUtils.getVarInArray(LuaUtils.getPropertyLoop(split), split[split.length-1]);
}
Expand Down Expand Up @@ -1186,7 +1188,7 @@ class FunkinLua {
return false;
});
Lua_helper.add_callback(lua, "screenCenter", function(obj:String, pos:String = 'xy') {
var spr:FlxSprite = game.getLuaObject(obj);
var spr:FlxObject = game.getLuaObject(obj);

if(spr==null){
var split:Array<String> = obj.split('.');
Expand Down

0 comments on commit 8ce954b

Please sign in to comment.