Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6538475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:44:25+00:00 2026-05-25T10:44:25+00:00

I have a lot of lua-script with the same name used for function name

  • 0

I have a lot of lua-script with the same name used for function name (intended for “entry point”) and I want to run them. But I want to make it as fast as possible.

After some browsing/googling/thinking I’ve got two solution.

1., I have a main lua_State. I load the all necessary given and my own libs/functions “into” it. Next I lua_dump() the current lua-script’s lua_State’s function (with using linked list for chunck container), then I lua_load() it to the main lua_State and then lua_call() the main lua_State. With this solution I don’t have to load all the libs for all the scripts. So the main lua_State is an “environment”. 🙂

2., I simply do the libs loading for all lua_State. And then lua_call() them.

The question would be that: Is even the first one logical correct? And if yes, which one would you use? Is there a better solution?

Thanks ahead and sorry for my English.

(And if the first one is really correct, are there some oblivious optimization possibility?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:44:26+00:00Added an answer on May 25, 2026 at 10:44 am

    As you put it, I don’t see why you’d want more than 1 Lua state. If you have only one Lua state all overhead you’ll have is loading the libs (once) and then loading the functions from the scripts you run (once, unless you need to ‘refresh’ them from the file). So simply have 1 state, and dofile the scripts.

    If you really need those multiple lua_States, you could only load the libraries you need, as explained
    in the Lua Reference Manual, in the paragraph just above 5.1

    There’s also a nice freely available chapter on optimization of Lua code in Lua Gems Book.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a lot of unit tests but they aren't run every night. I
I have several Lua scripts that run experiences and output a lot of information,
I have a lot of constants that are somehow related, at some point I
I have a lot of spare intel linux servers laying around (hundreds) and want
I have lot of thumbnail and I want to show check box on images
I have a lot of elements, the id attributes of them are something like
I'm have a lot of time using hibernate (JPA) in java, but i recently
I have lot of junits that depend upon the same jvm system props. Currently,
I have searched lot for this answer but there is no near answer for
We have a lot of open discussions with potential clients, and they ask frequently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.