Loading & Running Lua Scripts

C87f04d6d4017ed62e75487bc8c06335
0
Jan 101 Nov 13, 2005 at 13:47

Hi there

Just starting to use Lua. It’s really a nice language. However, in the documentation i seem not to be able to find answers to a few very basic questions:

  1. At startup i only want to LOAD a lua-script, not to execute it already. With lua_dofile i can load a script, but it gets executed immediatly. Is there a way to load and compile code, but not to run it immediately?

  2. Of course, after i have loaded a script, i would like to be able to run it. And maybe even run it several times. But again, i could only find lua_dofile/lua_dostring to run a complete script (that means the main-body of the script, of course i can simply call one function inside the script). But those functions also first load and compile the script, which i want to avoid. Any other function to execute the complete script and not only some function?

Thanks in advance,
Jan.

1 Reply

Please log in or register to post a reply.

065f0635a4c94d685583c20132a4559d
0
Ed_Mack 101 Nov 13, 2005 at 17:38

Look into lua_load and lua_pcall

http://www.lua.org/pil/24.1.html