Advertisement

call LUa from string rather than file

Started by July 27, 2004 03:44 PM
0 comments, last by Monder 20 years, 2 months ago
say u have a string a="add(1,2)" how would u call that to a LUA . rather than a txt file in a txt file it wa lua_dofile(name); hwo do u do this for a string vaiable?
A quick flick through lauxlib.h showed up this:

LUALIB_API int   lua_dostring (lua_State *L, const char *str);


That's probably what you want.

[edit]And if you want a value returned from lua, you'll probably have to pop it off the stack, or plonk it in a global variable and then grab it out of the global environment table, lua_dostring will not return it directly[/edit]

This topic is closed to new replies.

Advertisement