getComponents returns nothing even when it should
hello I have script like this
for some reason it can't find that method in component, when literally there should be 100% chance to be there.
does anyone know why?
if (this.socketAddress.address === 0) {
const components = Dependency<Components>();
const parent = this.instance.Parent?.Parent;
if (parent) {
wait(1); // fix this later
const assemblyRoot = components.getComponents<GetAssemblyUID>(parent);
print("list of assemblyRoots :3", assemblyRoot);
if (assemblyRoot.size() !== 0) {
this.socketAddress.address = assemblyRoot[0].getAssemblyUID();
} else {
warn("address set to automatic, but no root found on instance ", parent);
}
}
if (this.socketAddress.address === 0) {
const components = Dependency<Components>();
const parent = this.instance.Parent?.Parent;
if (parent) {
wait(1); // fix this later
const assemblyRoot = components.getComponents<GetAssemblyUID>(parent);
print("list of assemblyRoots :3", assemblyRoot);
if (assemblyRoot.size() !== 0) {
this.socketAddress.address = assemblyRoot[0].getAssemblyUID();
} else {
warn("address set to automatic, but no root found on instance ", parent);
}
}
@Component({
tag: "model:Engine",
})
export class Engine extends BaseComponent<{}, EngineModel> implements GetAssemblyUID, OnStart {
@Component({
tag: "model:Engine",
})
export class Engine extends BaseComponent<{}, EngineModel> implements GetAssemblyUID, OnStart {
4 Replies
getAssemblyUID(): number {
print("got called :3");
return 128 as number;
///return tonumber(tostring(this.parent.getAssemblyUID()) + "1") as number;
}
getAssemblyUID(): number {
print("got called :3");
return 128 as number;
///return tonumber(tostring(this.parent.getAssemblyUID()) + "1") as number;
}
@Component({ tag: "model:Airship" })
export class Airship extends BaseComponent<IAttributes, AirshipModel> implements OnStart, GetAssemblyUID {
// target speed that is set to be delivered
private targetSpeed: number = 0;
private targetRotationSpeed: number = 0;
//acceleration of rotation and speed
public rotationSpeedAcceleration: number = 2;
public speedAccelaration: number = 2;
// currect rotation and speed
// also might remove later? - currect speed
private speed: number = 0;
// currect rotation speed
private rotationSpeed: number = 0;
// rotation and speed limits
// might remove later?
public maxSpeed: number = 60;
public maxRotationSpeed: number = 200;
// maximum weight of payload that airship can carry
private maxPayloadWeight: number = 2000;
//Gauges
private speedGaugeComponent?: GaugeComponent; // not defined
private gasGaugeComponent?: GaugeComponent; // not defined
private heightGaugeComponent?: GaugeComponent; // not defined
// Rudders
private rotationRudder?: RudderComponent;
private assemblyUID!: number;
// Engine
private engine?: Engine;
// this initializes update so physics is running, it also sets correct payload hold and connects needed components
onStart(): void {
this.update();
this.setPayloadCapacity();
this.assemblyUID = new UID(this.attributes.OwnerID).uid;
this.connectComponents();
}
getAssemblyUID(): number {
return this.assemblyUID;
}
@Component({ tag: "model:Airship" })
export class Airship extends BaseComponent<IAttributes, AirshipModel> implements OnStart, GetAssemblyUID {
// target speed that is set to be delivered
private targetSpeed: number = 0;
private targetRotationSpeed: number = 0;
//acceleration of rotation and speed
public rotationSpeedAcceleration: number = 2;
public speedAccelaration: number = 2;
// currect rotation and speed
// also might remove later? - currect speed
private speed: number = 0;
// currect rotation speed
private rotationSpeed: number = 0;
// rotation and speed limits
// might remove later?
public maxSpeed: number = 60;
public maxRotationSpeed: number = 200;
// maximum weight of payload that airship can carry
private maxPayloadWeight: number = 2000;
//Gauges
private speedGaugeComponent?: GaugeComponent; // not defined
private gasGaugeComponent?: GaugeComponent; // not defined
private heightGaugeComponent?: GaugeComponent; // not defined
// Rudders
private rotationRudder?: RudderComponent;
private assemblyUID!: number;
// Engine
private engine?: Engine;
// this initializes update so physics is running, it also sets correct payload hold and connects needed components
onStart(): void {
this.update();
this.setPayloadCapacity();
this.assemblyUID = new UID(this.attributes.OwnerID).uid;
this.connectComponents();
}
getAssemblyUID(): number {
return this.assemblyUID;
}
I think it's because they didn't load or smth
Or can you actually task.delay it instead of task.wait()?
the reason was cuz script crashed
ðŸ«