Page 2 of 2

Re: Scripting time in real-time seconds

Posted: Fri Oct 31, 2014 11:59 am
by antti
Passing parameters are unfortunately not supported. In this case I would modify the script so that the for-loop would be in the lightOn-function.

Re: Scripting time in real-time seconds

Posted: Fri Oct 31, 2014 12:02 pm
by gambit37
OK, great, thanks for the quick reply :-)

EDIT: Ah, that doesn't work because it resets the loop every time it re-enters the function, so all the lights come on at the same time.

Re: Scripting time in real-time seconds

Posted: Fri Oct 31, 2014 12:37 pm
by Komag
gambit37 wrote:Can parameters be passed to functions in a delayedCall?
Maybe try it like this:

Code: Select all

function lightsOn()
	for e = 1, #lanterns_levEntrance do
		delayedCall(self.go.id, e/5, "lightOn()")
		e = e + 1
	end
end
f = 1
function lightOn()
	lanterns_levEntrance[e].light:enable()
	lanterns_levEntrance[e].particle:enable()
	f = f + 1
end

Re: Scripting time in real-time seconds

Posted: Fri Oct 31, 2014 1:21 pm
by cromcrom
I checked, it stays consistent over different levels.

Re: Scripting time in real-time seconds

Posted: Fri Oct 31, 2014 1:40 pm
by MrChoke
gambit37 wrote:Can parameters be passed to functions in a delayedCall?

For example, if I use delayedCall in a loop and pass a parameter based on the value of the loop, I receive an error: "Warning! invalid message: script_entity_5.lightOn(lanterns_levEntrance([e]))"

My code is a loop to turn on all lanterns on the level sequentially with a small delay between each one. "lanterns_levEntrance" is a table already created which contains entity references for all the lanterns on the level. The code works fine if I enable the lights/particles directly (the lines commented out below), but fails with the delayed call.

Code: Select all

function lightsOn()
	for e = 1, #lanterns_levEntrance do
		--lanterns_levEntrance[e].light:enable()
		--lanterns_levEntrance[e].particle:enable()
		delayedCall(self.go.id, 0.2, "lightOn(lanterns_levEntrance[e])")
	end
end

function lightOn(lightID)
	lightID.light:enable()
	lightID.particle:enable()
end

Try to reference using "go" in the function. Like this:

function lightOn(lightID)
lightID.go.light:enable()
lightID.go.particle:enable()
end

I am not sure but I think it may be the answer.

Re: Scripting time in real-time seconds

Posted: Fri Oct 31, 2014 2:32 pm
by DrKojak
i am scripting some lights to activate at a point in the bossfight, i just put lights where i wanted them and made them unclickable and lights off etc, then made a spawner that triggers when i want them too that just spawns the light normally... there arent any clipping or weird textures etc which is nice too, so that's easy.

Re: Scripting time in real-time seconds

Posted: Fri Oct 31, 2014 4:36 pm
by Doridion
DrKojak ? Could I propose the old good solution ? :D

Step by step script ? ( controlled by timer or just the boss life of course )

Got example in the skugg's tuto part 6 ( Boss tuto )

Re: Scripting time in real-time seconds

Posted: Sat Nov 01, 2014 2:33 pm
by DrKojak
Doridion wrote:DrKojak ? Could I propose the old good solution ? :D

Step by step script ? ( controlled by timer or just the boss life of course )

Got example in the skugg's tuto part 6 ( Boss tuto )
well it is scripted to the time, so far ive scripted about 70 seconds of events of traps and spawners, aswell at spawning more light when the boss teleports in. i may also, at a certain point in the battle's song, spawn some pitfalls if they will work being spawned in or created during-game