From 6a406505ea1c12e8bce7836b245042abb83c3f8c Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 26 Oct 2016 15:30:27 +0200 Subject: add smoke to steam engine feature may behave strange or not work at all until latest git version! --- wagons.lua | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/wagons.lua b/wagons.lua index e543d0c..1966ebe 100644 --- a/wagons.lua +++ b/wagons.lua @@ -89,6 +89,10 @@ function wagon:on_activate(staticdata, dtime_s) end advtrains.update_trainpart_properties(self.train_id) minetest.after(1, function() self:reattach_all() end) + + if self.custom_on_activate then + self:custom_on_activate(staticdata_table, dtime_s) + end end function wagon:get_staticdata() @@ -203,7 +207,7 @@ function wagon:on_step(dtime) --custom on_step function if self.custom_on_step then - self.custom_on_step(self, dtime) + self:custom_on_step(self, dtime) end --driver control @@ -526,6 +530,34 @@ advtrains.register_wagon("newlocomotive", "steam",{ --self.old_anim_velocity=advtrains.abs_ceil(velocity) --end end, + custom_on_activate = function(self, staticdata_table, dtime_s) + minetest.add_particlespawner({ + amount = 10, + time = 0, + -- ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base + minpos = {x=0, y=2, z=1.2}, + maxpos = {x=0, y=2, z=1.2}, + minvel = {x=0, y=1.8, z=0}, + maxvel = {x=0, y=2, z=0}, + minacc = {x=0, y=-0.1, z=0}, + maxacc = {x=0, y=-0.3, z=0}, + minexptime = 2, + maxexptime = 4, + minsize = 1, + maxsize = 5, + -- ^ The particle's properties are random values in between the bounds: + -- ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration), + -- ^ minsize/maxsize, minexptime/maxexptime (expirationtime) + collisiondetection = true, + -- ^ collisiondetection: if true uses collision detection + vertical = false, + -- ^ vertical: if true faces player using y axis only + texture = "smoke_puff.png", + -- ^ Uses texture (string) + attached = self.object, + }) + minetest.chat_send_all("added ParticleSpawner") + end, drops={"default:steelblock 4"}, }, "Steam Engine", "advtrains_newlocomotive_inv.png") advtrains.register_wagon("wagon_default", "steam",{ -- cgit v1.2.3