Esempio n. 1
0
int TextLabel::lua_AllocateText(lua_State *L) {
	Ref w = GetRef<TextLabel>(L, "TextLabel", 1, true);

	if (lua_type(L, 2) == LUA_TTABLE) {

		typedef stackify<zone_vector<const char*, ZUIT>::type, 64> StringPtrVec;
		StringPtrVec v;

		for (int i = 0; ; ++i) {
			lua_pushinteger(L, i+1);
			lua_gettable(L, 2);
			if (lua_isnil(L, -1)) {
				lua_pop(L, 1);
				break;
			}
			v->push_back(luaL_checkstring(L, -1));
			lua_pop(L, 1);
		}

		if (!v->empty())
			w->AllocateText(&v[0], (int)v->size());

	} else {
		const char *sz = luaL_checkstring(L, 2);
		w->AllocateText(&sz, 1);
	}

	return 0;
}