Пример #1
0
// get_sky(self)
int ObjectRef::l_get_sky(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	RemotePlayer *player = getplayer(ref);
	if (player == NULL)
		return 0;
	video::SColor bgcolor(255, 255, 255, 255);
	std::string type;
	std::vector<std::string> params;
	bool clouds;

	player->getSky(&bgcolor, &type, &params, &clouds);
	type = type.empty() ? "regular" : type;

	push_ARGB8(L, bgcolor);
	lua_pushlstring(L, type.c_str(), type.size());
	lua_newtable(L);
	s16 i = 1;
	for (const std::string &param : params) {
		lua_pushlstring(L, param.c_str(), param.size());
		lua_rawseti(L, -2, i++);
	}
	lua_pushboolean(L, clouds);
	return 4;
}
Пример #2
0
// get_sky(self)
int ObjectRef::l_get_sky(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	RemotePlayer *player = getplayer(ref);
	if (player == NULL)
		return 0;
	video::SColor bgcolor(255, 255, 255, 255);
	std::string type;
	std::vector<std::string> params;
	bool clouds;

	player->getSky(&bgcolor, &type, &params, &clouds);
	type = type == "" ? "regular" : type;

	push_ARGB8(L, bgcolor);
	lua_pushlstring(L, type.c_str(), type.size());
	lua_newtable(L);
	s16 i = 1;
	for (std::vector<std::string>::iterator it = params.begin();
			it != params.end(); ++it) {
		lua_pushlstring(L, it->c_str(), it->size());
		lua_rawseti(L, -2, i);
		i++;
	}
	lua_pushboolean(L, clouds);
	return 3;
}