Scripting time in real-time seconds

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!
User avatar
antti
Posts: 688
Joined: Thu Feb 23, 2012 1:43 pm
Location: Espoo, Finland
Contact:

Re: Scripting time in real-time seconds

Post 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.
Steven Seagal of gaming industry
User avatar
gambit37
Posts: 218
Joined: Fri Mar 02, 2012 3:40 pm

Re: Scripting time in real-time seconds

Post 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.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Scripting time in real-time seconds

Post 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
Finished Dungeons - complete mods to play
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: Scripting time in real-time seconds

Post by cromcrom »

I checked, it stays consistent over different levels.
A trip of a thousand leagues starts with a step.
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Re: Scripting time in real-time seconds

Post 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.
DrKojak
Posts: 23
Joined: Fri Oct 24, 2014 11:19 am

Re: Scripting time in real-time seconds

Post 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.
User avatar
Doridion
Posts: 256
Joined: Tue Jun 10, 2014 9:23 pm

Re: Scripting time in real-time seconds

Post 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 )
DrKojak
Posts: 23
Joined: Fri Oct 24, 2014 11:19 am

Re: Scripting time in real-time seconds

Post 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
Post Reply