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)
Solution:Jump to solution
so, using
jecs.component() is for preregistration, and world:component() for normal component creation15 Replies
my
src/shared/components.ts
src/server/systems/player-added.ts
src/server/main.server.ts
src/shared/world.ts
src/shared/scheduler.ts
code criticism is also welcome, tryna learn this new paradigm and i need to learn new best practicesyeah I probably wouldnt do this and that's probably why the problem
Solution
so, using
jecs.component() is for preregistration, and world:component() for normal component creationpreregistration comes with a problem and its that you should require your world after you preregistered all your components
so having a world singleton in a module and also a components folder will cause a lot of bugs
so I would either, not have a world module if you wanna use preregistration
or dont use preregistration and create your components with
world:component()if i had to create components thru world.component, how would i access them from other systems?
same way I mean you have a
"./world"
so just import that instead when creating your components
or the other one is not having a world module and passing your world in your systems
like you did here
but for everything
like fusion scopes
lmaowhich one would u recommend
the first one seems easier to do
I personally use world:component()
its easier
and preregistration has no benefit for me
trade offs?
I dont know honestly
maybe for testing, you can create multiple worlds
but I personally just import the same world module in tests too
honestly i think this preregistration code was from a time where i didnt have a world module and needed the components quick
yeah for testing preregistration would be useful
because you can create a lot of worlds and all of them would have all of your components already
because they are preregistered
yeah and i think i kept getting cyclic dependencies cuz i could not wrap my head around organizing ecs code which is why i had to do that
good to know
what does this mean tho? https://discord.com/channels/476080952636997633/476080952636997635/1427032911953006715 and why would it cause that
the error happens when the component has no row for data
that mostly happens when you use tags with world:set
but I would imagine it happened to you because all your component ids got mixed up
alright thanks it works now