Something broke..

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
Emera Nova
Posts: 146
Joined: Wed Jun 11, 2014 1:31 am

Something broke..

Post by Emera Nova »

So I have this code

Code: Select all

step = 1
function tick()
	local seq = {1,2,3,4}
	findEntity ("bic_"..seq[step]).controller:start()
	step = step%#seq+1
end
set up to allow for a flashing light I have set up to work.

I also have

Code: Select all

step = 1
function tick()
   local seq = { 1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2 }
   findEntity("firespawner_"..seq[step]).controller:activate() 
   step = step%#seq+1
end

this one as well that has fire balls get launched out.. I think the firespawner one is breaking the other step counters in the dungeon but not sure why. If it isn't that then I have no idea whats causing it to break..

I have a total of 4 different scripts that run off that same build of code.. My guess is the local seq is what is fucking shit up even tho its set to different timers and different Entitys..
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Something broke..

Post by minmay »

The local variable seq isn't doing anything. The script-global variable step is probably your problem; if both of those snippets are in the same ScriptComponent then only one "step" variable exists and both functions are setting it.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Emera Nova
Posts: 146
Joined: Wed Jun 11, 2014 1:31 am

Re: Something broke..

Post by Emera Nova »

Each of those are housed in their own ScriptComponent. The only thing they share is they are on the same level. I have 4 different scripts that all call on a tick to be used to keep timing of spawning objects and the destruction of them. Timers alone are accurate enough for that type of thing and often end up catching up to each other over time.
Post Reply