[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Passing parameters into a script
- From: Eike Decker <eike@...>
- Date: Fri, 15 Feb 2008 20:09:02 +0100
Hi
I don't know about the C API documentation but I guess it's in the manual,
however if you have a file that starts like this:
-- script.lua
local arg1,arg2,arg3 = ...
print(arg1,arg2,arg3)
and execute it with "dofile('script.lua','hello','world','!')" you will pass
these arguments to the file as arguments.
Eike
> Greetings all,
>
> I have a lua script file, which contains code and several functions; i'm
> executing this script from C using essentially luaL_dofile.
>
> what I would like to be able to do is pass in some parameters that have
> local scope (as if I had declared them as locals)
> but I don't want to wrap the code inside of a function.
>
> I don't want to use a global, because functions called within this script
> could cause other scripts to be executed, which would change this global
> variable, and on return it would no longer be the same.
>
> My actual example is needing to be able to set a local parameter 'this' to
> some number, so that the script has context about what object is making it
> run.
>
> any help would be great, thanks :)
>
> -Raymond Jacobs
>