int cbsdlua_loadcmd(int argc, char **argv) { int error; // lua_State *L = luaL_newstate(); // luaL_openlibs(L); if (argc!=2) { out1fmt("Use: cbsdlua_load <path>\n"); return 1; } lua_loadscript(L,argv[1]); // lua_close(L); return 0; }
int lua_inslua(void *sender, int cargc, char **cargv) { nick *np = (nick *)sender; char *script = cargv[0]; if(cargc < 1) { controlreply(np, "Usage: inslua <script>"); return CMD_ERROR; } if(lua_scriptloaded(script)) { controlreply(np, "Script %s already loaded, or name not valid.", script); return CMD_ERROR; } if(lua_loadscript(script)) { controlreply(np, "Script %s loaded.", script); return CMD_OK; } else { controlreply(np, "Unable to load script %s.", script); return CMD_ERROR; } }
void __fini() { #else void _fini() { #endif if(loaded) { if(startsched) deleteschedule(startsched, &lua_startup, NULL); while(lua_head) lua_unloadscript(lua_head); lua_destroybot(); lua_destroycontrol(); } freesstring(cpath); freesstring(suffix); freesstring(dummy.name); lua_freedebugsocket(); nscheckfreeall(POOL_LUA); } void lua_loadscripts(void) { array *ls; ls = getconfigitems("lua", "script"); if(!ls) { Error("lua", ERR_INFO, "No scripts loaded."); } else { sstring **scripts = (sstring **)(ls->content); int i; for(i=0;i<ls->cursi;i++) lua_loadscript(scripts[i]->content); } }