2d array type help

how do I type out a 2d array where the components are arrays where the second element is the value type of the first component
arrComponentSet(ent, [
[Health, { Current: 10, Max: 100 }],
[Character, mdl],
[Posture, { Current: 10, Max: 100 }],
[State, CharacterStates.Idle],
[StatusHandler, { Character: ent, Effects: {} }],
[SkillHandler, { Character: ent, RunningSkills: {} }],
]);
arrComponentSet(ent, [
[Health, { Current: 10, Max: 100 }],
[Character, mdl],
[Posture, { Current: 10, Max: 100 }],
[State, CharacterStates.Idle],
[StatusHandler, { Character: ent, Effects: {} }],
[SkillHandler, { Character: ent, RunningSkills: {} }],
]);
import { Entity, Id, InferComponent } from "@rbxts/jecs";
import { ECSWorld } from "../server-ecs/world";

export function arrComponentSet(e: Entity, arr: [Id<unknown>, unknown][]) {
arr.forEach((v) => {
if (v[1] === undefined) {
ECSWorld.add(e, v[0] as Id<undefined>);
} else {
ECSWorld.set(e, v[0], v[1]);
}
});
return e;
}
import { Entity, Id, InferComponent } from "@rbxts/jecs";
import { ECSWorld } from "../server-ecs/world";

export function arrComponentSet(e: Entity, arr: [Id<unknown>, unknown][]) {
arr.forEach((v) => {
if (v[1] === undefined) {
ECSWorld.add(e, v[0] as Id<undefined>);
} else {
ECSWorld.set(e, v[0], v[1]);
}
});
return e;
}
3 Replies
giggleblunts
gigglebluntsOP•3w ago
bump 🥺
roblox-ts
roblox-ts•3w ago
Playground link
Posted by <@214262712753061889>
giggleblunts
gigglebluntsOP•3w ago
No I kinda wanted typings for each component but I figured I probs cant do it with arrays

Did you find this page helpful?