Fixing script crash message

No more LIB_modname.hx in the logs
This commit is contained in:
NeeEoo
2024-02-11 20:46:08 +01:00
parent 7e1db2f4c6
commit e6ff26fd2e
3 changed files with 26 additions and 3 deletions
+17
View File
@@ -302,6 +302,23 @@ class Paths
return content;
*/
}
// Used in Script.hx
@:noCompletion public static function getFilenameFromLibFile(path:String) {
var file = new haxe.io.Path(path);
if(file.file.startsWith("LIB_")) {
return file.dir + "." + file.ext;
}
return path;
}
@:noCompletion public static function getLibFromLibFile(path:String) {
var file = new haxe.io.Path(path);
if(file.file.startsWith("LIB_")) {
return file.file.substr(4);
}
return "";
}
}
class ScriptPathInfo {
+4 -3
View File
@@ -11,7 +11,7 @@ class HScript extends Script {
public var parser:Parser;
public var expr:Expr;
public var code:String = null;
public var folderlessPath:String;
//public var folderlessPath:String;
var __importedPaths:Array<String>;
public static function initParser() {
@@ -27,11 +27,11 @@ class HScript extends Script {
interp = new Interp();
try {
if(Assets.exists(path)) code = Assets.getText(path);
if(Assets.exists(rawPath)) code = Assets.getText(rawPath);
} catch(e) Logs.trace('Error while reading $path: ${Std.string(e)}', ERROR);
parser = initParser();
folderlessPath = Path.directory(path);
//folderlessPath = Path.directory(path);
__importedPaths = [path];
interp.errorHandler = _errorHandler;
@@ -92,6 +92,7 @@ class HScript extends Script {
private function _errorHandler(error:Error) {
// This should be ${error.file} later
var fn = '$fileName:${error.line}: ';
var err = error.toString();
if (err.startsWith(fn)) err = err.substr(fn.length);
@@ -129,6 +129,8 @@ class Script extends FlxBasic implements IFlxDestroyable {
*/
public var path:String = null;
private var rawPath:String = null;
private var didLoad:Bool = false;
/**
@@ -177,6 +179,9 @@ class Script extends FlxBasic implements IFlxDestroyable {
public function new(path:String) {
super();
rawPath = path;
path = Paths.getFilenameFromLibFile(path);
fileName = Path.withoutDirectory(path);
this.path = path;
onCreate(path);