Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

File Scoping Lua?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1 PAndersson   Members   

394
Like
0Likes
Like

Posted 22 July 2012 - 01:05 PM

I'm failry new to using Lua in genral, but have looked into embedding. One issue I have encountered is that neither the luabind nor the lua api itself has the ability to call a function in a specific file, one can call a function by name but that has issues if two or more files has a function with the same name. That is something I would like to support however, so is it possible to file-scope lua? I was thinking giving each script file their own luaState in the game itself, am I right in assuming that that would work? Is there any other standard way of doing this?

#2 rip-off   Moderators   

10897
Like
0Likes
Like

Posted 22 July 2012 - 01:32 PM

Executing the contents of a file in a non-global environment might allow you to do this.

Caveat: It has been a while since I used Lua, and environments were handled differently in the older versions, so research the implications fully, don't take my word for it.

#3 PAndersson   Members   

394
Like
0Likes
Like

Posted 23 July 2012 - 10:00 AM

Executing the contents of a file in a non-global environment might allow you to do this.

Caveat: It has been a while since I used Lua, and environments were handled differently in the older versions, so research the implications fully, don't take my word for it.


Thank you, I seem to have difficulties changing the current enviroment though.

#4 rip-off   Moderators   

10897
Like
0Likes
Like

Posted 23 July 2012 - 10:34 AM

What kind of difficulties?

#5 PAndersson   Members   

394
Like
0Likes
Like

Posted 23 July 2012 - 10:44 AM

What kind of difficulties?


I might have midunderstood how this is done (as I said, inexperienced in Lua), buf if I assign a new table to _ENV, _ENV maintins the same table reference id as before.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.