1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-06-16 12:29:28 +00:00

ecs: added eid cmd

This commit is contained in:
Steven Hugg 2022-02-19 17:52:24 -06:00
parent eb30e5cf85
commit 38462bceac

View File

@ -775,6 +775,7 @@ class ActionEval {
case '$': return this.__local(args); case '$': return this.__local(args);
case '^': return this.__use(args); case '^': return this.__use(args);
case '#': return this.__arg(args); case '#': return this.__arg(args);
case '&': return this.__eid(args);
case '<': return this.__get([arg0, '0']); case '<': return this.__get([arg0, '0']);
case '>': return this.__get([arg0, '8']); case '>': return this.__get([arg0, '8']);
default: default:
@ -842,6 +843,11 @@ class ActionEval {
return this.dialect.indexed_x(ident, index); //TODO? return this.dialect.indexed_x(ident, index); //TODO?
} }
} }
__eid(args: string[]) {
let e = this.scope.getEntityByName(args[0] || '?');
if (!e) throw new ECSError(`can't find entity named "${args[0]}"`, this.action);
return e.id.toString();
}
__use(args: string[]) { __use(args: string[]) {
return this.scope.includeResource(args[0]); return this.scope.includeResource(args[0]);
} }