Improved Tankman Run Script + HScript Warning (#773)

* Improved Tankman Run Script +  HScript Warning

Updated the tankman run custom class and implemented the hscript warning system

* dont mind me

---------

Co-authored-by: ⍚~Nex <87421482+NexIsDumb@users.noreply.github.com>
This commit is contained in:
Jamextreme140
2025-09-21 17:11:22 +02:00
committed by GitHub
co-authored by ⍚~Nex
parent b2049e6285
commit bacd218e0b
2 changed files with 48 additions and 41 deletions
@@ -34,6 +34,7 @@ class HScript extends Script {
__importedPaths = [path];
interp.errorHandler = _errorHandler;
interp.warnHandler = _warnHandler;
interp.importFailedCallback = importFailedCallback;
interp.staticVariables = Script.staticVariables;
interp.allowStaticVariables = interp.allowPublicVariables = true;
@@ -117,6 +118,24 @@ class HScript extends Script {
], ERROR);
}
private function _warnHandler(error:Error) {
var fileName = error.origin;
var oldfn = '$fileName:${error.line}: ';
if(remappedNames.exists(fileName))
fileName = remappedNames.get(fileName);
var fn = '$fileName:${error.line}: ';
var err = error.toString();
while(err.startsWith(oldfn) || err.startsWith(fn)) {
if (err.startsWith(oldfn)) err = err.substr(oldfn.length);
if (err.startsWith(fn)) err = err.substr(fn.length);
}
Logs.traceColored([
Logs.logText(fn, GREEN),
Logs.logText(err, YELLOW)
], WARNING);
}
public override function setParent(parent:Dynamic) {
interp.scriptObject = parent;
}