Skip to content

Commit

Permalink
Update HScript.hx
Browse files Browse the repository at this point in the history
guh..
  • Loading branch information
inky03 authored Oct 3, 2024
1 parent 31be084 commit 2142a4b
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions source/psychlua/HScript.hx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class HScript extends Iris
{
public var filePath:String;
public var modFolder:String;
public var returnValue:Dynamic = null;

#if LUA_ALLOWED
public var parentLua:FunkinLua;
Expand All @@ -35,18 +36,24 @@ class HScript extends Iris
{
trace('initializing haxe interp for: ${parent.scriptName}');
parent.hscript = new HScript(parent, code, varsToBring);
return parent.hscript.returnValue;
}
else
{
hs.varsToBring = varsToBring;
try
{
hs.scriptCode = code;
return hs.execute();
if (hs.scriptCode != code) {
hs.scriptCode = code;
hs.parse(true);
}
hs.returnValue = hs.execute();
return hs.returnValue;
}
catch(e:Dynamic)
{
FunkinLua.luaTrace('ERROR (${hs.origin}) - $e', false, false, FlxColor.RED);
hs.returnValue = null;
}
}
return null;
Expand Down Expand Up @@ -90,11 +97,19 @@ class HScript extends Iris
scriptThing = File.getContent(f);
}
}
this.scriptCode = scriptThing;

preset();
execute();
this.scriptCode = scriptThing;
this.varsToBring = varsToBring;
try {
this.returnValue = execute();
} catch (e:Dynamic) {
#if LUA_ALLOWED
FunkinLua.luaTrace('ERROR (${hs.origin}) - $e', false, false, FlxColor.RED);
#else
PlayState.instance.addTextToDebug('ERROR (${hs.origin}) - $e', FlxColor.RED);
#end
this.returnValue = null;
}
}

var varsToBring(default, set):Any = null;
Expand Down

0 comments on commit 2142a4b

Please sign in to comment.