Mat
Mat

Reputation: 336

Best way to use Lua

I have a game / app engine that I am currently integrating Lua into. An app is divided into scenes which contain actors. I want to allow the user to assign a Lua script per scene as well as per actor. What would be the best way to handle this? Should I create and manage a Lua state for each scene and then one for each actor? Or for performance would I be better off having one Lua state per scene and loading all of the scripts for each instantiated actor into the scenes Lua state. I'm mostly interested in performance. Is using multiple Lua VM's a bad idea?

Upvotes: 2

Views: 370

Answers (2)

SatheeshJM
SatheeshJM

Reputation: 3643

The First Rule of Program Optimization: Don't do it.
The Second Rule of Program Optimization (for experts only!): Don't do it yet.

So do not worry about performance unless you hit a major issue.

You can follow minor performance tricks which are good practices anyway. http://trac.caspring.org/wiki/LuaPerformance

Some other Useful links

Upvotes: 3

Alex
Alex

Reputation: 15343

Don't worry about performance until you've demonstrated that it's an issue.

Do whatever is easiest and makes the most sense for you game. I've never had to use more than one lua_State. Having multiple seems like it would be a pain to manage with little benefit

Upvotes: 6

Related Questions