Jump to content

shared variable between all resources


Recommended Posts

hi, in order to create an account system, i want to share a variable over all ressources, i'm not sure but it is possible to do it with using a table that contain all players data and make an external function that return that table, there will be no memory access error?? cause i read that each ressource run on it own space

Link to comment
hi, in order to create an account system, i want to share a variable over all ressources, i'm not sure but it is possible to do it with using a table that contain all players data and make an external function that return that table, there will be no memory access error?? cause i read that each ressource run on it own space

You can't export functions and coroutines (and most likely userdata too, unless it is recreated in the new Lua state pointing to the same memory address). Other types like number, string and table, however, can be copied.

Link to comment
Ok, thanks i understand, but why making sharing variable between ressource not supported directly ?? i must make a function to return the address of the table, adding the overhead of function call

Each resource has their own Lua virtual machine. They don't talk with each other unless forced to. Currently exports are the only and good way to do that. It is like the same thing with modern browsers where each page tab is their own process. Improves safety and many other things.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...