Particle not re-enabling

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
vieuxchat
Posts: 48
Joined: Wed Mar 02, 2016 3:14 pm

Particle not re-enabling

Post by vieuxchat »

Here is a custom object :

Code: Select all

defineObject{
	name = "particlesThatVanishes_vieuxchat",
	baseObject = "base_floor_decoration",
	components = {
		{
			class = "Particle",
			offset = vec(0.0, 1, 0.0),
			particleSystem = "essence_water",
			enabled = false,
		},
		{
			class = "Timer",
			enabled = false,
			currentLevelOnly = true,
			triggerOnStart = false,
			timerInterval = 4,
			disableSelf = true,
			onActivate = function(self)
				self.go:spawn("wizard_explosion")
				for e in self.go.map:entitiesAt(self.go.x, self.go.y) do
					if e.name == "spawner" then
						e.spawner:activate()
					end
				end
				self.go.timer:disable()
			end
		},
		{
			class = "Controller",
			onActivate = function(self)
				if not self.go.timer:isEnabled() then 
					self.go.particle:enable()
					self.go.particle:fadeOut(self.go.timer:getTimerInterval(0))
					self.go.timer:start() 
				end
			end,
		},
	},
	tags = { "custom_vieuxchat"},
}
The idea is that when activated, it enables the particle system (the water essence) and makes it fade out. When the fading finishes, every spawner on the tile will spawn.
It works... the first time. If i try to activate it again, the timer starts and the spawning is done when it should be done, but the particle system doesn't appear again and, so, don't fade out.

Why ?
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Particle not re-enabling

Post by AndakRainor »

Have you tried with ParticleComponent:restart() or ParticleComponent:fadeIn(time) or something like that? It seems your particles effect has been stoped the first time with fadeOut and never restarted. Enabling the component is not enough...
vieuxchat
Posts: 48
Joined: Wed Mar 02, 2016 3:14 pm

Re: Particle not re-enabling

Post by vieuxchat »

I tried with restart, but it didn't work. I didn't thought of fadeIn ! And that made the trick :D
Thank you very much :)

It seems the restart doesn't change the "alpha" channel of the particles. I guess the particles were enabled, but still at 0 in alpha.
Post Reply