void ScriptProp::initEnumItems()
	{
		LuaTable enumTable(-1);
		enumTable.beginRead();
		for (int i = 0; i < enumTable.getLength(); i++) {
			LuaTable enumItem = enumTable.get(i);
			enumItem.beginRead();
			if (enumItem.getLength() >= 2) {
				String key = enumItem.get(0).toString();
				int val = enumItem.get(1).toInt();
				m_enumItems.push_back(std::make_pair(key, val));
			}
			enumItem.endRead();
		}
		enumTable.endRead();
#if 1
		for (lua_pushnil(L); lua_next(L,-2); lua_pop(L, 1)) {
			if (lua_type(L,-2) != LUA_TSTRING)
				continue;

			const char* name = lua_tostring(L, -2);

			if (name[0] == '_') {
				continue;
			}
			
			if (lua_isnumber(L,-1)) {
				m_enumItems.push_back(std::make_pair<String,int>(name, lua_tonumber(L,-1)));
			}
		}
#endif
	}
Beispiel #2
0
	void GameSound::loadSound( const Variant& v )
	{
		clear();

		if (v.type != Variant::kTable) {
			return;
		}

		LuaTable table = v;

		table.beginRead();
		String name = table.get("sound");
		m_minDist = table.get("minDist");
		m_maxDist = table.get("maxDist");
		m_looping = table.get("looping");
		m_interval = table.get("interval");
		table.endRead();

		if (name.empty())
			return;

		m_sfx << g_soundSystem->createSfx(name);
	}