deltanedas / entity-lib

Mindustry mod library that adds various utilities for modding Mechs and Units.
Other
11 stars 0 forks source link

"Cannot call method 'extendUnit' of undefined" #1

Open Qix- opened 4 years ago

Qix- commented 4 years ago

Following the examples in all of the Readme, example repo and vbucks, I can't get a simple script to run:

const entityLib = this.global.entityLib;
const ancientOctus = entityLib.extendUnit(UnitType, 'ancient-octus', [{
    drawUnder(parent, rot) {
        Draw.color(Color.red);
        Lines.stroke(4);
        Lines.circle(parent.x, parent.y, 50);
        Lines.circle(parent.x, parent.y, 100);
        Lines.circle(parent.x, parent.y, 150);
    }
}]);

It appears this.global.entityLib is not populated early enough? I don't really understand how mindustry's inclusion system works.

I do have a main.js in the root /scripts/ folder that includes this one (which is located at /scripts/units/ancient-octus.js).

MEEPofFaith commented 4 years ago

I really doesn't help that all of the examples are mechs and none of them are units...

Qix- commented 4 years ago

@MEEPofFaith I got units working here: https://github.com/Qix-/mds-ancients-units