3 void luaRun::registerScripts() {
4 registerScript("helloworld.lua");
7 void luaRun::registerScript(const std::string
&name
) {
9 scripts
.push_back(novo
);
12 lua_State
* newState() {
13 lua_State
* l
= lua_open();
18 void doLuaFile(lua_State
* l
,std::string file
) {
19 if (luaL_dofile(l
, file
.c_str())) {
20 printf("%s\n", lua_tostring(l
, -1));
24 void registerFunction(lua_State
* l
, std::string name
, lua_CFunction function
) {
25 lua_pushcfunction(l
, function
);
26 lua_setglobal(l
, name
.c_str());
29 void luaRun::loadScripts() {
30 std::vector
<Script
>::iterator it
;
31 for (it
= scripts
.begin();it
!= scripts
.end(); it
++) {
32 if (it
->L
!= NULL
) lua_close(it
->L
);
34 doLuaFile(it
->L
,it
->name
);