lua-users home
lua-l archive

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


> -----Original Message-----
> From: RLake@oxfam.org.uk [mailto:RLake@oxfam.org.uk]
> Sent: 07 February 2002 15:11
> To: cpercival@interaxis.co.uk
> Subject: 
> 
> 
> 
> > My next question is, i have this code:
> 
> > static int MyTag;
> > static int MyVal = 3;
> 
> > static int MyFunc(lua_State *L)
> >    {
> >    lua_settop(L,1);
>   -- I don't see the point of this. MyFunc doesn't use its argument.

Oh fair enough..

> >    lua_pushusertag(L, &n, MyTag);
>   -- just out of curiosity, where does n come from? No matter, though.

Sorry, n should be MyVal.

> >    return 1;
> >    }
> 
> > ... snip
> 
> > To make this code work I would write in the script:
> 
> > MyFunc(x)
> 
> Surely that should be x = MyFunc(), no?

Yes, sorry my mistake again.

> 
> > Which would effectively map x in the script to MyVal in C.  Now my
> question
> > is, how do I do the above, but all in C, add x to the variables in the
> > script, but add the functionality that happens when I call MyFunc,
> without
> > actually having to call MyFunc?
> 
>      lua_pushusertag(L, &n, MyTag);
>      lua_setglobal("x");
> 

Ah thats wonderfull.  Yes that looks logical, now I see it..

Thanks,

Chris Percival
Software Engineer
Interaxis Computing Ltd.
DDI:  +44 (0)1249 700072
http://www.interaxis.co.uk/