R
roblox-ts5mo ago
Ego*

Charm + Vide How To Update UI

I have just started using vide and charm, but i am still not sure how i could use the two of them to update my UIs, i would really appreciate any help!
123 Replies
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Ego*
Ego*OP5mo ago
like how could i make it so that for example when the enemy's object health value changes, his overhead UI would update accordingly in the past in luau when i used to use react i used to expose my useState from inside the overhead component to the enemy object so that it can call it when health changes, but people always said that was a bad way, so i am not sure how to do it with atoms now
wAD
wAD5mo ago
in react you would subscribe to health changes from the component itself
Ego*
Ego*OP5mo ago
react was just an example, i have switched to vide
Tester
Tester5mo ago
@wAD does the vide have Bindings?
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Tester
Tester5mo ago
with react i think you can still do amazing things and it depends on the structure
Ego*
Ego*OP5mo ago
i had seen how littensy had done it, he had a module for each atom in his example, and not sure if the UI updates when the value changes or not
wAD
wAD5mo ago
no vide does not need them because they don't re-render stuff anyway
Tester
Tester5mo ago
at least they have useAtom hook 🫠 hmm is it possible to add and remove components dynamically like in react?
wAD
wAD5mo ago
react & vide are conceptually different, vide does not have a vdom it's more similar to fusion ye
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Tester
Tester5mo ago
like i wanted to try vide but still havent
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Tester
Tester5mo ago
man charm is so good i even ported it to js
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
can you use vide sources outside ui
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
i saw people raw dog state with fusion values outside UI
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
ok one benefit of charm is that it offers cool sync functionality
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
yeah
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
ah i also don't use vide
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
personal preference 🤷‍♂️
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
directly manipulating instances is kinda powerful
in what way
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
you can do that with react ?
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
i wouldn't say one useState hook is a lot of boilerplate but k
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
i tried vide
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
the latter, i don't care and i won't switch anyway
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
second one Ive seen that has this flipped ui should consume outside state the outside state shouldnt update itself XD but ig its whatever
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
you should consume the state, ui should be a reflection of it so the ui consumes the state
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
in react would make more sense because you wouldnt be able to do that for example for matter (not sure what ecs you use) somebody made hooks for react
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
useWorld useComponent, useQuery
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
no, not matter hooks sorry like I mean somebody made tooling hooks for consuming state in matter its all about state purity, no side effects, and all of that
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
it is backwards, you are "handfeeding" the UI state from the outside
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
right, but you could query the state from the UI
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
no it doesnt, thats the whole point Im talking about if you edit some state from ecs for the ui then the ui becomes the central state, because the ecs is responsible of that (ecs shouldnt be responsible of the UI) similar to the charm useAtom it consumes that atom state, but you shouldnt create sources somewhere and update them with the atom you do useAtom
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
I thini for ecs, you might use jabby I think its called right
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
right it would consume the state from your world you dont update it in your ecs ecs would be responsible for exposing the state not providing it, and updating it
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
ya, like charm useAtom
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
its an example charm has useAtom
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
local health = useAtom(selectHealth)
local health = useAtom(selectHealth)
you have your health this in any component where you use health
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
just an exposed state, it could be a single atom, or just a function accessing the state
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
Im not creating a global states script with health inside and listening to charm outside of the ui you wouldnt use charm there, you can have something like useEntity(Player) and useComponent(Player, Health) that would subscribe to the state and update it but that will be everytime you want to use it you mightve done that in react because you cant expose UI state
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
couldnt you have the health component or something, I dont use jecs so I wouldnt know
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
I think you should be able to get one specific state like, health
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
you create a state, and do setState() with your health
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
you query it, dunno how it works, but maybe subscribe every frame and update it or however you consume state it would be a hook, so can be abstracted and its only done once but react, react is more strict with that, and the ui state is locked in react, and hidden (for a very good reason)
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
but it would only update it if it actually changes? I mean its a number
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
Immutability
PepeElToro41
PepeElToro415mo ago
ya thats better in na immutable approach but ig its a different pattern
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
you get what I mean right 🧐
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
it's not about performance
PepeElToro41
PepeElToro415mo ago
not performance, its more of an antipattern easier to debug, the state is pure theres no side effects all of that
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
maybe it something about jecs Im pretty sure in matter is easy to just query one part of the state
wAD
wAD5mo ago
i reacted with facepalm because you said "I get what you are trying to say now yeah" and then proved that wrong in the next sentence ok maybe i missunderstood mb
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
oh mb
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
ya, I mean I said its "whatever" it might not be a problem, specially if your ui is small but yeah its backwards XD
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
you totally right 🙌 Id say so, the other person that did the same approach also used ecs XD
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
yeah you shouldnt use reflex for that thats even worse you'd have duplicated states
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
same with vide sources or charm atoms
PepeElToro41
PepeElToro415mo ago
nah, sources are for ui, atoms for outside
wAD
wAD5mo ago
isn't he just creating a big file with vide sources
PepeElToro41
PepeElToro415mo ago
if you mean the "proxy" that is used to connect your atom
wAD
wAD5mo ago
and updating em from his code for ui to react accordingly
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
ya but hes updating those source from the jecs code
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
might be some problem with ecs 🤔 I was under the impression that accessing entity states was easier
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
ya, and even if you query components, its probably gonna be every frame I actually dont think there are better solutions .-.
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
I see what you do this I apologize 🙏
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
no no, same I hope I wasnt rude I mean, that might be one thing its just more flexible
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
PepeElToro41
PepeElToro415mo ago
react is more strict
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
in your opinion guys
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
is using ecs in roblox comes down to preference, considering these problems
PepeElToro41
PepeElToro415mo ago
it is, because it becomes too opinionated
wAD
wAD5mo ago
i've never really used ecs before, i was considering looking into it just wondering if it's worth it
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
wAD
wAD5mo ago
ah, i see. i'll look into it one day 🤔 mb if i was a bit rude, guess it comes down to these ECS-related problems i don't really understand 😅
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?