Freeeaky / GTALua

Scripting engine for GTA V in Lua
GNU General Public License v2.0
60 stars 25 forks source link

Load addons in their own namespace #72

Closed vincentducorps closed 9 years ago

vincentducorps commented 9 years ago

Hi,

If I use a global variable in my script, it affects all other scripts!

Perhaps using Lua module functions ?

Freeeaky commented 9 years ago

This has been discussed before, please put your variables in your ScriptThread table.

vincentducorps commented 9 years ago

Sorry to re-open this discussion but I don't understand why and how... :S

For example, I have the classic main.lua and I want to include a second config.lua file that contains a variable. If it's "local", I could'nt use it in my file main.lua This requires that I put in the "global" but then it pollutes space

Freeeaky commented 9 years ago

Just store the variables in your thread table. thread_table = ScriptThread("thread_table")

vincentducorps commented 9 years ago

So I would have to use ScriptThread table every time for each variable / function? And use 'self' to access

Why not use lua modules, as this is done to avoid this?

Too much work?

Freeeaky commented 9 years ago

Yes.

And it was a personal design choice :) It's not about the work.