| 301 | |
| 302 | |
| 303 | int WorldScript::AddDynamicColor(lua_State* L) { |
| 304 | const std::string name = luaL_checkstring(L, 1); |
| 305 | std::auto_ptr<DynamicColor> dyncol(new DynamicColor); |
| 306 | |
| 307 | LuaTable table(L, 2); |
| 308 | if (table.IsValid()) { |
| 309 | bool b; |
| 310 | float f; |
| 311 | fvec4 f4; |
| 312 | std::string s; |
| 313 | |
| 314 | if (table.GetFloat("delay", f)) { dyncol->setDelay(f); } |
| 315 | |
| 316 | if (table.GetString("varName", s)) { dyncol->setVariableName(s); } |
| 317 | if (table.GetFloat("varTime", f)) { dyncol->setVariableTiming(f); } |
| 318 | if (table.GetBool("varNoAlpha", b)) { dyncol->setVariableNoAlpha(b); } |
| 319 | |
| 320 | if (table.GetString("teamMask", s)) { dyncol->setTeamMask(s); } |
| 321 | |
| 322 | LuaTable st = table.SubTable("states"); |
| 323 | if (st.IsValid()) { |
| 324 | for (int i = 1; true; i++) { |
| 325 | LuaTable entry = st.SubTable(i); |
| 326 | if (!entry.IsValid() || |
| 327 | !entry.GetFloat("time", f) || |
| 328 | !entry.GetColor("color", f4)) { |
| 329 | break; |
| 330 | } |
| 331 | dyncol->addState(f, f4); |
| 332 | } |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | dyncol->setName(name); |
| 337 | dyncol->finalize(); |
| 338 | |
| 339 | dyncol->print(std::cout, name + ": "); // FIXME |
| 340 | |
| 341 | DYNCOLORMGR.addColor(dyncol.release()); |
| 342 | return 0; |
| 343 | } |
| 344 | |
| 345 | //============================================================================// |
| 346 |
nothing calls this directly
no test coverage detected