Hi,
1- I have a score variable in my main section of game that I need to alter based on actions of player. My question is what is the best way to give it’s access to other parts of game that need it without making it global.
What I’ve done, and I don’t like, is I made it a table and passed it to my objects so they can alter it if they want.
(The reason I made it a table is because values are passed by values in Lua and if I made it a variable, only it’s copy would be in hands of the other parts and their change will not get reflected on the original score variable)
In C# I would make it static so others would access it easily but I think this concept is void in Lua.
2- Is there anyway to pass a variable by reference to functions? I currently made my variable as table so it would be passed by reference but I think it’s bloated and I need a variable, not a table.
Thanks. [import]uid: 206803 topic_id: 35640 reply_id: 335640[/import]