Skip to content

Commit

Permalink
guh
Browse files Browse the repository at this point in the history
  • Loading branch information
LarryFrosty committed Sep 8, 2024
1 parent ae3c50a commit 9c369be
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
18 changes: 18 additions & 0 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,24 @@ class Main extends Sprite
fpsVar.visible = ClientPrefs.data.showFPS;
}

#if HSCRIPT_ALLOWED
crowplexus.iris.Iris.error = function(level:crowplexus.iris.ErrorSeverity, x, ?pos:haxe.PosInfos):Void {
if (pos == null) {
pos = crowplexus.iris.Iris.getDefaultPos();
}

var errorMsg = 'ERROR (${pos.fileName})';
if (pos.lineNumber != -1)
errorMsg += ':${pos.lineNumber}';
errorMsg += ' - ${x}';

if (PlayState.instance != null) {
PlayState.instance.addTextToDebug(errorMsg, FlxColor.RED);
}
trace(errorMsg);
}
#end

#if linux
var icon = Image.fromFile("icon.png");
Lib.current.stage.window.setIcon(icon);
Expand Down
18 changes: 4 additions & 14 deletions source/psychlua/HScript.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import psychlua.FunkinLua;
#end

#if HSCRIPT_ALLOWED
import crowplexus.iris.Iris;
import crowplexus.iris.IrisConfig;
import crowplexus.iris.*;

class HScript extends Iris
{
Expand Down Expand Up @@ -46,7 +45,7 @@ class HScript extends Iris
}
catch(e:Dynamic)
{
PlayState.instance.addTextToDebug('ERROR (${hs.origin}) - $e', FlxColor.RED);
Iris.error(ERROR, e, hs.interp.posInfos());
}
}
}
Expand Down Expand Up @@ -476,17 +475,8 @@ class HScript extends Iris
{
this.varsToBring = varsToBring;
scriptCode = code;
try
{
parse(true);
returnValue = execute();
return returnValue;
}
catch(e)
{
PlayState.instance.addTextToDebug('ERROR (${this.origin}):${this.interp.posInfos().lineNumber} - ${e}', FlxColor.RED);
}
return null;
parse(true);
return returnValue = execute();
}

/*override function irisPrint(v):Void
Expand Down
3 changes: 1 addition & 2 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3284,9 +3284,8 @@ class PlayState extends MusicBeatState
{
var newScript:HScript = cast (Iris.instances.get(file), HScript);
@:privateAccess
var line = newScript != null ? newScript.interp.posInfos().lineNumber : -1;
Iris.error(crowplexus.iris.ErrorSeverity.ERROR, e, newScript.posInfos());

addTextToDebug('ERROR ON LOADING ($file):${line} - ${e}', FlxColor.RED);
if(newScript != null)
newScript.destroy();
}
Expand Down

0 comments on commit 9c369be

Please sign in to comment.