Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


File Scoping Lua?


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   -  Reputation: 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?

Sponsor:

#2 rip-off   Moderators   -  Reputation: 8515

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   -  Reputation: 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   -  Reputation: 8515

Like
0Likes
Like

Posted 23 July 2012 - 10:34 AM

What kind of difficulties?

#5 PAndersson   Members   -  Reputation: 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.



PARTNERS