roblox-ts

R

roblox-ts

Join the community to ask questions about roblox-ts and get answers from other members.

Join

Need help with a @rbxts/react item component for a Tarkov-themed inventory.

I am working on a tarkov/arena breakout themed inventory system. I have two of the primary components I will likely need mostly completed. The issue I am having is regarding the InventoryItem component. This component will be responsible for displaying the actual item in whatever configuration it is set in (e.g. slot sizes x. y and rotation) I have a few issues with how I am going to make this component work but first let me share the code for the component in question: ```tsx...

getAllComponents and onComponentAdded don't work

why could Flamework's getAllComponents always return empty table and onComponentAdded never work? With any class provided. Even though I'm sure there are some components in the game as I can see them if I print the object that's being returned with Dependency<Components>?
Solution:
Getting id from the generic type and passing it as a component specifier solved the issue ```typescript /** @metadata macro {@link Flamework.resolveDependency intrinsic-flamework-rewrite} */ export function useAllComponents<T extends BaseComponent>(id?: IntrinsicSymbolId<T>): T[] {...

WCS Example Repo?

Hello! I am looking at @wAD 's WCS combat framework and love what I seen so far. I was wondering if there's any open source games/code that uses it that I can reference? I am particularly curious on how syncing VFX and animations may work. especially grabbing type attacks that require both characters to be synced up to look correct

Proxy error function does not cause unreachable/terminate thread

I have an error/warning function that will print out standardized error codes to make debugging easier: ```ts export const FATAL = (code: ErrorCode) => { error('Fatal error occured: ' + code); };...
Solution:
function FATAL(code: ErrorCode): never {
error("Fatal error occured: " + code);
}
function FATAL(code: ErrorCode): never {
error("Fatal error occured: " + code);
}
...

JSX not working in react project.

I can't seem to figure out why the JSX isn't working In my react project. I have the JSX compiler option set but I'm still getting errors when trying to compile the Typescript. ```json "jsx": "react", "jsxFactory": "React.createElement",...
Solution:
you need .tsx for react

Invalid attribute

I have a component which takes an attribute "acoustic_zone", the type of which is; ```ts // component acoustic_zone: Exclude<keyof typeof Workspace.AcousticZones, keyof Folder>; ...
No description

Ignore unused folders inside src/

Here's my folder structure: ``` src ├── game │   ├── client...

something is wrong with ripple motion

cc @littensy something is wrong with motion when i set the velocity ripple 10 a3. if i setVelocity it works exactly once and doesnt work anymore. it works again only if i do motion.getVelocity() ...

Component on all instances of class

Is there any way to construct a component on all instances of a class like a Humanoid? I could create a controller and add a component on player joined/character added but I think that is unnecessary
Solution:
I just used a controller and a macro to create them

Create components at runtime

I have a function external to flamework which components/services/controllers can call to create components at runtime without having to set the instance up with attributes or having to call some setup method so that components can always be expected to work solely on attributes. This makes it a lot easier to create components that depend on each other or need to construct each other without implementing special handling for components created outside of those cases. ```ts // runtime_create.ts export const createComponent = (component: BaseComponent, attributes?: { [key: string]: AttributeValue }, instance?: Instance) => { const components = Dependency<Components>();...
Solution:
Solution was to pass the component specifier to addComponent instead of the class: ```ts /** @metadata macro */ export function makeComponent<T>(attributes?: { [key: string]: AttributeValue }, instance?: Instance, id?: Modding.Generic<T, 'id'>) { const components = Dependency<Components>();...

Eslint: allowDefaultProject

@iSentinel
Parsing error: C:/{redacted} was included by allowDefaultProject but also was found in the project service. Consider removing it from allowDefaultProject. (eslint)
Parsing error: C:/{redacted} was included by allowDefaultProject but also was found in the project service. Consider removing it from allowDefaultProject. (eslint)
...
Solution:
well i was thinking if it works fine from terminal then its a zed ide issue

replecs networked error

const playerEntity = world.entity();
world.add(playerEntity, networked); // errors on this line, specifically on 'networked'
const playerEntity = world.entity();
world.add(playerEntity, networked); // errors on this line, specifically on 'networked'
```...
Solution:
networked isnt a tag its a component and the type of value it stores is a member filter. if you want to network to all players then do
world.set(playerEntity, networked, undefined);
world.set(playerEntity, networked, undefined);
i recommend reading the docs https://deepwiki.com/PepeElToro41/replecs/1-overview...
Message Not Public
Sign In & Join Server To View

component constructor parameters

is there any way to create a component that takes parameters? eg. ```ts @Component({ tag: '...' }) export class example extends BaseComponent { constructor(...args[]: unknown[])...
Solution:
Late but there is a simple way to do it with a macro: ```ts /** @metadata macro */ export function makeComponent<T>(attributes?: { [key: string]: AttributeValue }, instance?: Instance, id?: Modding.Generic<T, 'id'>) { const components = Dependency<Components>();...

attempt to modify a readonly table

why would an attempt to modify a readonly table error happen with jecs here? (if i uncomment any of them it errors) ```ts const playerEntity = world.entity(); // world.set(playerEntity, Player, player); // world.set(playerEntity, HealthAttribute, { max: 100, value: 0 });...
Solution:
so, using jecs.component() is for preregistration, and world:component() for normal component creation

Using regular RegEx instead of Luau Patterns

Trying to use regualar typescript regex gives the error that they are unsupported: Regex literals are not supported in roblox-ts I also cant seem to find a relevant package that provides support for RegEx in roblox-ts I can't see anyone anywhere asking the same question so maybe it's obvious and I'm dumb but yea...
Solution:
roblox themselves have a regex implementation on their github if you do want to spend the time checking it out
Message Not Public
Sign In & Join Server To View

Atom with array does not update react components

any obvious reason my react component is not re-rendering when I update the atom? is this because the atom is holding an array? ```tsx // flamework controller... private _alerts: Charm.Atom<AlertContext[]> ...
Solution:
```ts private _alerts: Charm.Atom<AlertContext[]> updateMethod(alert) { const t = this._alerts((old) => {...

Adding underscore to file name changes require casing

?! The proper case is "Alerts" but it compiles to "alerts" if there is no underscore in the name? I had to disable forceConsistentCasingInFileNames because I could not figure out any other way to fix it but it was complaining about casings being different even though they were not...
Solution:
Can you restart the vsc?

syncing still not working...

why .sync don't work? i give it payloads, it don't give any error, but atom don't changes
Solution:
i think the init payload is missing
No description

Is defining generics of a Component again when it's being used, really necessary in Flamework?

Solution:
apparently you could do something like <A extends Attributes = {}, I extends Tool = Tool>...
No description

syncing dont work!!

i set up syncing with cahrm-sync but when i change server atom nothing happens! sync:connect() dont fire and subscriptions to server atom too
Solution:
charm is immutable, u should clone the tables before writing data in your updater function
server
Next