- lua_getfield(L, 1, "minpos");
- if (lua_istable(L, -1))
- p.minpos = check_v3f(L, -1);
- lua_pop(L, 1);
-
- lua_getfield(L, 1, "maxpos");
- if (lua_istable(L, -1))
- p.maxpos = check_v3f(L, -1);
- lua_pop(L, 1);
-
- lua_getfield(L, 1, "minvel");
- if (lua_istable(L, -1))
- p.minvel = check_v3f(L, -1);
- lua_pop(L, 1);
-
- lua_getfield(L, 1, "maxvel");
- if (lua_istable(L, -1))
- p.maxvel = check_v3f(L, -1);
- lua_pop(L, 1);
-
- lua_getfield(L, 1, "minacc");
- if (lua_istable(L, -1))
- p.minacc = check_v3f(L, -1);
- lua_pop(L, 1);
-
- lua_getfield(L, 1, "maxacc");
- if (lua_istable(L, -1))
- p.maxacc = check_v3f(L, -1);
- lua_pop(L, 1);
+ // set default values
+ p.exptime = 1;
+ p.size = 1;
+
+ // read spawner parameters from the table
+ LuaParticleParams::readTweenTable(L, "pos", p.pos);
+ LuaParticleParams::readTweenTable(L, "vel", p.vel);
+ LuaParticleParams::readTweenTable(L, "acc", p.acc);
+ LuaParticleParams::readTweenTable(L, "size", p.size);
+ LuaParticleParams::readTweenTable(L, "exptime", p.exptime);
+ LuaParticleParams::readTweenTable(L, "drag", p.drag);
+ LuaParticleParams::readTweenTable(L, "jitter", p.jitter);
+ LuaParticleParams::readTweenTable(L, "bounce", p.bounce);
+ lua_getfield(L, 1, "attract");
+ if (!lua_isnil(L, -1)) {
+ luaL_checktype(L, -1, LUA_TTABLE);
+ lua_getfield(L, -1, "kind");
+ LuaParticleParams::readLuaValue(L, p.attractor_kind);
+ lua_pop(L,1);
+
+ lua_getfield(L, -1, "die_on_contact");
+ if (!lua_isnil(L, -1))
+ p.attractor_kill = readParam<bool>(L, -1);
+ lua_pop(L,1);
+
+ if (p.attractor_kind != AttractorKind::none) {
+ LuaParticleParams::readTweenTable(L, "strength", p.attract);
+ LuaParticleParams::readTweenTable(L, "origin", p.attractor_origin);
+ p.attractor_attachment = LuaParticleParams::readAttachmentID(L, "origin_attached");
+ if (p.attractor_kind != AttractorKind::point) {
+ LuaParticleParams::readTweenTable(L, "direction", p.attractor_direction);
+ p.attractor_direction_attachment = LuaParticleParams::readAttachmentID(L, "direction_attached");
+ }
+ }
+ } else {
+ p.attractor_kind = AttractorKind::none;
+ }
+ lua_pop(L,1);
+ LuaParticleParams::readTweenTable(L, "radius", p.radius);