MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / AddDynamicColor

Method AddDynamicColor

src/world/WorldScript.cpp:303–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301
302
303int 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

Callers

nothing calls this directly

Calls 15

setDelayMethod · 0.80
setVariableNameMethod · 0.80
setVariableTimingMethod · 0.80
setVariableNoAlphaMethod · 0.80
setTeamMaskMethod · 0.80
SubTableMethod · 0.80
GetColorMethod · 0.80
addStateMethod · 0.80
addColorMethod · 0.80
IsValidMethod · 0.45
GetFloatMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected