Skip to content

Commit

Permalink
fix hscript error printing
Browse files Browse the repository at this point in the history
just pulling commits from psych to here, again
  • Loading branch information
charlesisfeline committed Nov 7, 2023
1 parent 420d84d commit 492291a
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2188,7 +2188,9 @@ class PlayState extends MusicBeatState
}
catch(e:Dynamic)
{
addTextToDebug('ERROR ("Set Property" Event) - ' + e.message.substr(0, e.message.indexOf('\n')), FlxColor.RED);
var len:Int = e.message.indexOf('\n') + 1;
if(len <= 0) len = e.message.length;
addTextToDebug('ERROR ("Set Property" Event) - ' + e.message.substr(0, len), FlxColor.RED);
}

case 'Play Sound':
Expand Down Expand Up @@ -3223,10 +3225,14 @@ class PlayState extends MusicBeatState
var callValue = newScript.call('onCreate');
if(!callValue.succeeded)
{
for (e in callValue.exceptions)
{
if (e != null)
addTextToDebug('ERROR ($file: onCreate) - ${e.message.substr(0, e.message.indexOf('\n'))}', FlxColor.RED);

{
var len:Int = e.message.indexOf('\n') + 1;
if(len <= 0) len = e.message.length;
addTextToDebug('ERROR ($file: onCreate) - ${e.message.substr(0, len)}', FlxColor.RED);
}
}
newScript.destroy();
hscriptArray.remove(newScript);
trace('failed to initialize tea interp!!! ($file)');
Expand All @@ -3237,7 +3243,9 @@ class PlayState extends MusicBeatState
}
catch(e)
{
addTextToDebug('ERROR ($file) - ' + e.message.substr(0, e.message.indexOf('\n')), FlxColor.RED);
var len:Int = e.message.indexOf('\n') + 1;
if(len <= 0) len = e.message.length;
addTextToDebug('ERROR ($file) - ' + e.message.substr(0, len), FlxColor.RED);
var newScript:HScript = cast (SScript.global.get(file), HScript);
if(newScript != null)
{
Expand Down Expand Up @@ -3303,8 +3311,7 @@ class PlayState extends MusicBeatState
excludeValues.push(psychlua.FunkinLua.Function_Continue);

var len:Int = hscriptArray.length;
if (len < 1)
return returnVal;
if(len < 1) return returnVal;
for(i in 0...len)
{
var script:HScript = hscriptArray[i];
Expand All @@ -3315,14 +3322,14 @@ class PlayState extends MusicBeatState
try
{
var callValue = script.call(funcToCall, args);
if(!callValue.succeeded)
{
if(!callValue.succeeded){
var e = callValue.exceptions[0];
if(e != null)
FunkinLua.luaTrace('ERROR (${script.origin}: ${callValue.calledFunction}) - ' + e.message.substr(0, e.message.indexOf('\n') + 1), true, false, FlxColor.RED);
}
else
{
if(e != null){
var len:Int = e.message.indexOf('\n') + 1;
if(len <= 0) len = e.message.length;
FunkinLua.luaTrace('ERROR (${script.origin}: ${callValue.calledFunction}) - ' + e.message.substr(0, len), true, false, FlxColor.RED);
}
}else{
myValue = callValue.returnValue;
if((myValue == FunkinLua.Function_StopHScript || myValue == FunkinLua.Function_StopAll) && !excludeValues.contains(myValue) && !ignoreStops)
{
Expand Down

0 comments on commit 492291a

Please sign in to comment.