Inhereting attributes are nil

Hello, I was trying to inhereted some attributes because of repeating code, but for some unknown reason they are "nil" no matter what I do
interface IAttributes extends ControlInterfaceAttributes {
acceleration: number;
maxSpeed: number;
}

@Component({
tag: "model:CrankLever",
})
/**
* this is simple crank lever, it slowly gathers speed
*/
export class CrankLever extends ControlInterface<IAttributes, crankLever> implements OnStart {
SelectedSide: number = 0;
isTriggered: boolean = false;

private currentSpeed: number = 0; // aktuální rychlost

constructor() {
super();
print("my addres :3 ", this.socketAddress);
}
onStart(): void {
print("test: ", this.attributes.Address);
print("test2: ", this.attributes.acceleration);
Events.controlInput.connect((player, vector) => {
this.rotateLever(player, vector);
});
}
interface IAttributes extends ControlInterfaceAttributes {
acceleration: number;
maxSpeed: number;
}

@Component({
tag: "model:CrankLever",
})
/**
* this is simple crank lever, it slowly gathers speed
*/
export class CrankLever extends ControlInterface<IAttributes, crankLever> implements OnStart {
SelectedSide: number = 0;
isTriggered: boolean = false;

private currentSpeed: number = 0; // aktuální rychlost

constructor() {
super();
print("my addres :3 ", this.socketAddress);
}
onStart(): void {
print("test: ", this.attributes.Address);
print("test2: ", this.attributes.acceleration);
Events.controlInput.connect((player, vector) => {
this.rotateLever(player, vector);
});
}
No description
No description
22 Replies
Lukas :3
Lukas :3OP2mo ago
export interface ControlInterfaceAttributes {
Address: number;
Direction: number;
Port: number;
}


/**
* this is abstract component connected to the network, it's ready for weld creation, camera set, physics update and simple data reading
*/
export abstract class ControlInterface<
A extends ControlInterfaceAttributes = ControlInterfaceAttributes,
I extends ControlInterfaceModel = ControlInterfaceModel,
> extends Endpoint<A, I> {
public owner: undefined | Player;

constructor() {
super();
this.instance.ControlElement.Use.Triggered.Connect((plr) => {
this.onTriggered(plr);
});
Events.ExitKey.connect((plr) => {
this.exit(plr);
});
RunService.Heartbeat.Connect((delta) => {
this.update(delta);
});
const address: socketAddress = {
address: this.attributes.Address,
direction: this.attributes.Direction,
port: this.attributes.Port,
};
print("control interface address:", address);
this.initialize(address);
}
export interface ControlInterfaceAttributes {
Address: number;
Direction: number;
Port: number;
}


/**
* this is abstract component connected to the network, it's ready for weld creation, camera set, physics update and simple data reading
*/
export abstract class ControlInterface<
A extends ControlInterfaceAttributes = ControlInterfaceAttributes,
I extends ControlInterfaceModel = ControlInterfaceModel,
> extends Endpoint<A, I> {
public owner: undefined | Player;

constructor() {
super();
this.instance.ControlElement.Use.Triggered.Connect((plr) => {
this.onTriggered(plr);
});
Events.ExitKey.connect((plr) => {
this.exit(plr);
});
RunService.Heartbeat.Connect((delta) => {
this.update(delta);
});
const address: socketAddress = {
address: this.attributes.Address,
direction: this.attributes.Direction,
port: this.attributes.Port,
};
print("control interface address:", address);
this.initialize(address);
}
Tester
Tester2mo ago
Can you try accessing via super.attributes? I think it will work
Lukas :3
Lukas :3OP2mo ago
dosen't seem so
No description
Lukas :3
Lukas :3OP2mo ago
like I am inhereting it inside the class, I am inhereting an interface
Tester
Tester2mo ago
Oh, I see Can you dig in definitions and make . attributes protected? Ctrl + Left click on "BaseComponent" class and can you check whether the attributes are private @Nightmare Oh... Wait The super class I think will not have them apparently cause it's getting overwriten by inherited class ig
Lukas :3
Lukas :3OP2mo ago
wait i sent script without some info fixed it I mean i can access the attributes but they are nil but only the inhereted one for example i can completly normally accerss acceleration
Tester
Tester2mo ago
Oh I see So the base component just doesn't read them? Interesting Can you do
interface NewAttributes extends OldAttributes {}
interface NewAttributes extends OldAttributes {}
Lukas :3
Lukas :3OP2mo ago
I do that?
interface IAttributes extends ControlInterfaceAttributes {
acceleration: number;
maxSpeed: number;
}
interface IAttributes extends ControlInterfaceAttributes {
acceleration: number;
maxSpeed: number;
}
or wait okey i did just this
interface IAttributes extends ControlInterfaceAttributes {}
interface IAttributes extends ControlInterfaceAttributes {}
same issue
Tester
Tester2mo ago
Wait where do you print the attributes? Can you print them in OnStart?
Lukas :3
Lukas :3OP2mo ago
sorry for so long response, I do.
onStart(): void {
print("test: ", this.attributes.Address);
print("test2: ", this.attributes.acceleration);
Events.controlInput.connect((player, vector) => {
this.rotateLever(player, vector);
});
}
onStart(): void {
print("test: ", this.attributes.Address);
print("test2: ", this.attributes.acceleration);
Events.controlInput.connect((player, vector) => {
this.rotateLever(player, vector);
});
}
Tester
Tester2mo ago
Dis you put attributes interface on the new(child) component?
Lukas :3
Lukas :3OP2mo ago
um, I don't think so?
Tester
Tester2mo ago
Can you? 🥺
Lukas :3
Lukas :3OP2mo ago
export interface ControlInterfaceModel extends Model {
Root: BasePart;
ControlElement: BasePart & {
Use: ProximityPrompt;
};
Camera: BasePart;
}

export interface ControlInterfaceAttributes {
Address: number;
Direction: number;
Port: number;
}

/**
* this is abstract component connected to the network, it's ready for weld creation, camera set, physics update and simple data reading
* TODO: data inserting if component is INPUT
*/
export abstract class ControlInterface<
A extends ControlInterfaceAttributes = ControlInterfaceAttributes,
I extends ControlInterfaceModel = ControlInterfaceModel,
> extends Endpoint<A, I> {
public owner: undefined | Player;

constructor() {
super();
this.instance.ControlElement.Use.Triggered.Connect((plr) => {
this.onTriggered(plr);
});
Events.ExitKey.connect((plr) => {
this.exit(plr);
});
RunService.Heartbeat.Connect((delta) => {
this.update(delta);
});
const address: socketAddress = {
address: this.attributes.Address,
direction: this.attributes.Direction,
port: this.attributes.Port,
};
print("control interface address:", address);
this.initialize(address);
}
export interface ControlInterfaceModel extends Model {
Root: BasePart;
ControlElement: BasePart & {
Use: ProximityPrompt;
};
Camera: BasePart;
}

export interface ControlInterfaceAttributes {
Address: number;
Direction: number;
Port: number;
}

/**
* this is abstract component connected to the network, it's ready for weld creation, camera set, physics update and simple data reading
* TODO: data inserting if component is INPUT
*/
export abstract class ControlInterface<
A extends ControlInterfaceAttributes = ControlInterfaceAttributes,
I extends ControlInterfaceModel = ControlInterfaceModel,
> extends Endpoint<A, I> {
public owner: undefined | Player;

constructor() {
super();
this.instance.ControlElement.Use.Triggered.Connect((plr) => {
this.onTriggered(plr);
});
Events.ExitKey.connect((plr) => {
this.exit(plr);
});
RunService.Heartbeat.Connect((delta) => {
this.update(delta);
});
const address: socketAddress = {
address: this.attributes.Address,
direction: this.attributes.Direction,
port: this.attributes.Port,
};
print("control interface address:", address);
this.initialize(address);
}
tbh i have no idea how
Tester
Tester2mo ago
Uhhh class NewComponent extends YourBaseComponent<IAttribues, IInstanceSteucture> I think like this
Lukas :3
Lukas :3OP2mo ago
I am so much confused tested few stuff and discovered that even type guard ignores it
Tester
Tester2mo ago
Oh, did you pass it in base component?
Lukas :3
Lukas :3OP2mo ago
i think so
export class Endpoint<A extends {} = {}, I extends Instance = Instance> extends BaseComponent<A, I> {
public readonly onStateChanged = new Signal<(newState: number) => void>();
public socketAddress!: socketAddress;

public initialize(address: socketAddress) {
this.socketAddress = address;
// checks if dynamic addressing enabled
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);
if (assemblyRoot.size() !== 0) {
this.socketAddress.address = assemblyRoot[0].getAssemblyUID();
}
}
}
networkInstances.push(this);
}
}
export class Endpoint<A extends {} = {}, I extends Instance = Instance> extends BaseComponent<A, I> {
public readonly onStateChanged = new Signal<(newState: number) => void>();
public socketAddress!: socketAddress;

public initialize(address: socketAddress) {
this.socketAddress = address;
// checks if dynamic addressing enabled
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);
if (assemblyRoot.size() !== 0) {
this.socketAddress.address = assemblyRoot[0].getAssemblyUID();
}
}
}
networkInstances.push(this);
}
}
Tester
Tester2mo ago
Oh I see Hmm Strange
Lukas :3
Lukas :3OP2mo ago
might be this a bug? @Tester (Ping in reply pls!) i would tag flamework creator but no idea what is his nick
Tester
Tester2mo ago
Fireboltdeath
Lukas :3
Lukas :3OP2mo ago
@Fireboltofdeath not ideal fix, i just put the methods i need to use over there to all other sub-classes still would like to resolve this do to better readablity

Did you find this page helpful?