summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_particles.cpp
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2015-07-25 11:56:24 +0200
committerLoic Blot <loic.blot@unix-experience.fr>2015-07-25 12:24:28 +0200
commit4e6971e59358b40956bb4c25f8f85e4cc018dbec (patch)
tree7facabe72a6473a55817725333c586563b215627 /src/script/lua_api/l_particles.cpp
parenta8c5841140c23f246adbc58f7c73195c01253697 (diff)
downloadminetest-4e6971e59358b40956bb4c25f8f85e4cc018dbec.tar.gz
minetest-4e6971e59358b40956bb4c25f8f85e4cc018dbec.tar.bz2
minetest-4e6971e59358b40956bb4c25f8f85e4cc018dbec.zip
Cleanup server addparticle(spawner) by merge two identical functions.
Diffstat (limited to 'src/script/lua_api/l_particles.cpp')
-rw-r--r--src/script/lua_api/l_particles.cpp58
1 files changed, 18 insertions, 40 deletions
diff --git a/src/script/lua_api/l_particles.cpp b/src/script/lua_api/l_particles.cpp
index d99d8f6a9..2532b2b08 100644
--- a/src/script/lua_api/l_particles.cpp
+++ b/src/script/lua_api/l_particles.cpp
@@ -96,14 +96,8 @@ int ModApiParticles::l_add_particle(lua_State *L)
texture = getstringfield_default(L, 1, "texture", "");
playername = getstringfield_default(L, 1, "playername", "");
}
- if (playername == "") { // spawn for all players
- getServer(L)->spawnParticleAll(pos, vel, acc,
+ getServer(L)->spawnParticle(playername, pos, vel, acc,
expirationtime, size, collisiondetection, vertical, texture);
- } else {
- getServer(L)->spawnParticle(playername.c_str(),
- pos, vel, acc, expirationtime,
- size, collisiondetection, vertical, texture);
- }
return 1;
}
@@ -195,30 +189,18 @@ int ModApiParticles::l_add_particlespawner(lua_State *L)
texture = getstringfield_default(L, 1, "texture", "");
playername = getstringfield_default(L, 1, "playername", "");
}
- if (playername == "") { //spawn for all players
- u32 id = getServer(L)->addParticleSpawnerAll( amount, time,
- minpos, maxpos,
- minvel, maxvel,
- minacc, maxacc,
- minexptime, maxexptime,
- minsize, maxsize,
- collisiondetection,
- vertical,
- texture);
- lua_pushnumber(L, id);
- } else {
- u32 id = getServer(L)->addParticleSpawner(playername.c_str(),
- amount, time,
- minpos, maxpos,
- minvel, maxvel,
- minacc, maxacc,
- minexptime, maxexptime,
- minsize, maxsize,
- collisiondetection,
- vertical,
- texture);
- lua_pushnumber(L, id);
- }
+
+ u32 id = getServer(L)->addParticleSpawner(amount, time,
+ minpos, maxpos,
+ minvel, maxvel,
+ minacc, maxacc,
+ minexptime, maxexptime,
+ minsize, maxsize,
+ collisiondetection,
+ vertical,
+ texture, playername);
+ lua_pushnumber(L, id);
+
return 1;
}
@@ -228,16 +210,12 @@ int ModApiParticles::l_delete_particlespawner(lua_State *L)
{
// Get parameters
u32 id = luaL_checknumber(L, 1);
-
- if (lua_gettop(L) == 2) // only delete for one player
- {
- const char *playername = luaL_checkstring(L, 2);
- getServer(L)->deleteParticleSpawner(playername, id);
- }
- else // delete for all players
- {
- getServer(L)->deleteParticleSpawnerAll(id);
+ std::string playername = "";
+ if (lua_gettop(L) == 2) {
+ playername = luaL_checkstring(L, 2);
}
+
+ getServer(L)->deleteParticleSpawner(playername, id);
return 1;
}