예제 #1
0
String luacon_geterror()
{
	luaL_tostring(luacon_ci->l, -1);
	String err = ByteString(luaL_optstring(luacon_ci->l, -1, "failed to execute")).FromUtf8();
	lua_pop(luacon_ci->l, 1);
	return err;
}
예제 #2
0
String LuaEvents::luacon_geterror(LuaScriptInterface * luacon_ci)
{
	luaL_tostring(luacon_ci->l, -1);
	String err = ByteString(luaL_optstring(luacon_ci->l, -1, "failed to execute")).FromUtf8();
	lua_pop(luacon_ci->l, 1);
	return err;
}
예제 #3
0
const char *luacon_geterror()
{
	luaL_tostring(luacon_ci->l, -1);
	const char* err = luaL_optstring(luacon_ci->l, -1, "failed to execute");
	lua_pop(luacon_ci->l, 1);
	return err;
}
예제 #4
0
void *thread(void *n)
{
	int p = lua_gettop(l);
	if(lua_pcall(l, 0, LUA_MULTRET, 0))
	{
		luaL_tostring(l, -1);
		printf("runtime error: %s\n", lua_tostring(l, -1));
		lua_pop(l, 1);
	}
	else
	{
		int c = lua_gettop(l);
		for(;c >= p;p++)
		{
			luaL_tostring(l, p);
			printf("%s\n", lua_tostring(l, -1));
			lua_pop(l, 1);
		}
	}
	exit(0);
}
예제 #5
0
LuaTask::LuaTask(const char* bootFile,int handle):TaskBase(handle),_callBackIndex(0)
{
	_L = luaL_newstate();
	luaL_openlibs(_L);

	int r = luaL_loadfile(_L,bootFile);
	if (r != LUA_OK) {
		LOG_ERROR("error load file:%s,error:%s",bootFile,luaL_tostring(_L,-1));
	}
	lua_newtable(_L);

	lua_pushlightuserdata(_L,this);
	lua_pushcclosure(_L,LuaTask::SetCallBack,1);
	lua_setfield(_L,-2,"SetCallBack");

	lua_pushlightuserdata(_L,this);
	lua_pushcclosure(_L,LuaTask::Log,1);
	lua_setfield(_L,-2,"Log");

	lua_pushcfunction(_L,LuaTask::Pack);
	lua_setfield(_L,-2,"Pack");

	lua_pushcfunction(_L,LuaTask::UnPack);
	lua_setfield(_L,-2,"UnPack");

	lua_pushlightuserdata(_L,this);
	lua_pushcclosure(_L,LuaTask::Send,1);
	lua_setfield(_L,-2,"Send");

	lua_setglobal(_L,"Finish");


	r = lua_pcall(_L,0,0,0);
	if (r != LUA_OK) {
		LOG_ERROR("error load file:%s,error:%s",bootFile,luaL_tostring(_L,-1));
	}
}
예제 #6
0
int luatpt_log(lua_State* l)
{
	int args = lua_gettop(l);
	String text = "";
	for(int i = 1; i <= args; i++)
	{
		luaL_tostring(l, -1);
		if(text.length())
			text=ByteString(luaL_optstring(l, -1, "")).FromUtf8() + ", " + text;
		else
			text=ByteString(luaL_optstring(l, -1, "")).FromUtf8();
		lua_pop(l, 2);
	}
	if((*luacon_currentCommand))
	{
		if(luacon_lastError->length())
			*luacon_lastError += "; ";
		*luacon_lastError += text;
	}
	else
		luacon_ci->Log(CommandInterface::LogNotice, text.c_str());
	return 0;
}