Fixing script crash message
No more LIB_modname.hx in the logs
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user