lua-users home
lua-l archive

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


I'm wildly guessing you're executing luaL_loadfile, but never
executing the resultant chunk.

A chunk is a function. That's all it is. Commonly, it's a function
which happens to set a lot of global variables, but that's more a
convention than anything else. The point is, all luaL_loadfile does is
push a function onto the stack. If you don't execute it, it does
nothing.

Of course, it's possible your problem lies elsewhere entirely. If so,
post your code... it makes it much easier to troubleshoot.

Ben

On Fri, 20 Aug 2004 01:33:23 -0700, Michael Newberry
<mnewberry@axres.com> wrote:
> Sorry about the problems of clarity and the typos in my previous message. It
> is 1:30 in the morning and I have been wrestling with this problem all
> evening.
> 
> Michael
> 
> 
> 
> ----- Original Message -----
> From: "Michael Newberry" <mnewberry@axres.com>
> To: "Lua list" <lua@bazar2.conectiva.com.br>
> Sent: Friday, August 20, 2004 1:29 AM
> Subject: cannot index a table loaded as a chunk
> 
> > I am using lus 5.0 and I have a strange problem with tables being used as
> > classes. I define the class as a table. It has one variable inside.The
> > scripthas a command that calls a Cfunction named Include(filename) which
> > itself uses luaL_loadfile() to load a class definition named Img. When the
> > main chunk gets to Img:new()  [as on page 138 of the lua book], it fails
> > with this message from lua:
> >
> >     "... : attempt to index global `Img' (a nil value)"
> >
> > In other words, the table Img defined in a separate file is considered not
> > yet defined. it is almost as if each chuck is having its own set of
> "static"
> > globals rather than merging them into a single pool.
> >
> > Ideas?
> >
> > Michael
> >
> >
> >
> 
>