karimsqualli96 Posted August 26, 2014 Share Posted August 26, 2014 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
Anubhav Posted August 26, 2014 Share Posted August 26, 2014 function exportThisFunction() return variablleName or tableName end Link to comment
Atton Posted August 27, 2014 Share Posted August 27, 2014 This can be done using exports. viewtopic.php?f=148&t=61058 Link to comment
ixjf Posted August 27, 2014 Share Posted August 27, 2014 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
karimsqualli96 Posted August 27, 2014 Author Share Posted August 27, 2014 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 Link to comment
myonlake Posted August 27, 2014 Share Posted August 27, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now