lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Do this work correct eg my loading script shows:

function init( ... )
    myFunc()
end

function myFunc( ... )
end

In this case the call in the init should be globally myload.myscript.myFunc(), so the
scoping of the loaded script must be corrected after inserting into the global variable.
For more information:

I have got Lua scripts with similar structure, for each script I call the "init" function many times
and get the result of the init with the C API, after each init is called n_i times, I call the "iterate"
function in the script with the data, but the different scripts should used one Lua state eg:

lua_state* L;
for i in scripts
    load i in L

l_data = {}
for i in init_calls
    run init function i in L
    push return data in l_data
   
for each i in l_data
    call script i with l_data[i] 
    data[i] = get return data

Phil




Am 29.12.2012 um 20:21 schrieb Luiz Henrique de Figueiredo:

>> How can I read the Lua script and push the Lua functions into a nested table? 
> 
> Try this:
> 
> 	function myload(s)
> 		_G[s]={}
> 		return assert(loadfile(s..".lua","bt",_G[s]))()
> 	end
> 
> Use as follows:
> 
> 	myload"script1"
> 	myload"script2"
>