FX:setlight weirdness

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: FX:setlight weirdness

Post by Isaac »

Lmaoboat wrote:...
Thanks, this worked for me. :)
Lmaoboat
Posts: 359
Joined: Wed Apr 11, 2012 8:55 pm

Re: FX:setlight weirdness

Post by Lmaoboat »

Isaac wrote:
Lmaoboat wrote:...
Thanks, this worked for me. :)
Here's a much better one:

Code: Select all


function turnon()
	spawn("fx", 1, 3, 10, 3, "light1")
	light1:setLight(1,1,1,10,6, 360000, true)
end

function turnoff()
   	light1:setLight(1,1,1,10,6, 0.1, true)
end
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

Re: FX:setlight weirdness

Post by Blichew »

I still don't get those FXs,
this is the error I'm getting when I try to setLight from a function:

Image

needless to say there's a FX item nearby with an ID skFxRoom. I've also tried using findEntity("skFxRoom"):setLight(...)

any help would be appreciated :)
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: FX:setlight weirdness

Post by Isaac »

Blichew wrote:I still don't get those FXs,
this is the error I'm getting when I try to setLight from a function:

Image

needless to say there's a FX item nearby with an ID skFxRoom. I've also tried using findEntity("skFxRoom"):setLight(...)

any help would be appreciated :)
Study the code above (the post above yours). Use the Spawn function in your code; spawn the Fx where (and when) you want it, don't place it there by hand in the editor.

** spawn(object, level, x, y, facing, [id])
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

Re: FX:setlight weirdness

Post by Blichew »

Thanks, will go that direction.
So it seems that static FXs are for static lights only that spawn at dungeon load. My above line works well if I take it out from the function block.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: FX:setlight weirdness

Post by Komag »

Lmaoboat wrote:setLight seems to just add upon itself every time it's use instead replace the last setting, so to turn a light off, you need to give it the opposite value:

Code: Select all

spawn("fx", 1, 3, 10, 3, "light1")
light1:setLight(0,0,0,10,6, 360000, true)

function turnon()
	light1:setLight(1,1,1,10,6, 360000, true)
end

function turnoff()
	light1:setLight(-1,-1,-1,10,6, 360000, true)
end
I wouldn't use this too much though, turning it off and on a lot seems to cause fps drop.
I realize this is a bit old, but I wanted to add a note about something I discovered:
"setLight" is actually creating a NEW ADDITIONAL light every time, so if you "turn it off and on" 5 times you have actually created 10 lights (all cancelling each other out in color), killing your performance in the area.

That's why the next version you gave is better, because turning if off by setting the time to 0.1 does in fact kill the light entity out of existence, maintaining performance.
Finished Dungeons - complete mods to play
Post Reply