In lua baselib.c,it give us a lot of base function,such as:
static const struct luaL_reg iolib[] = {
{LUA_ERRORMESSAGE, errorfb},
{"clock", io_clock},
{"date", io_date},
{"debug", io_debug},
{"execute", io_execute},
{"exit", io_exit},
{"getenv", io_getenv},
{"remove", io_remove},
{"rename", io_rename},
{"setlocale", setloc},
{"tmpname", io_tmpname}
};
static const struct luaL_reg iolibtag[] = {
{"appendto", io_appendto},
{"closefile", io_close},
{"flush", io_flush},
{"openfile", io_open},
{"read", io_read},
{"readfrom", io_readfrom},
{"seek", io_seek},
{"write", io_write},
{"writeto", io_writeto}
};
and in my project,I definded a lot of function of myself.and register to
lua.
in Lua script,I can use this function:
test.lua
function main()
print("hello wolrd");
end function
main();
-----------------------------
I use the function by its funciton name:"print",How can I call print
function,not by its function name,but use the index of the function in the
array?