FX:setlight weirdness

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Lmaoboat
Posts: 359
Joined: Wed Apr 11, 2012 8:55 pm

FX:setlight weirdness

Post by Lmaoboat »

I was wondering why even low brightness levels were causing lights to get ridiculously bright until I figured out that, not only do lights time over time according to their duration, but a negative will cause it to keep to increase in brightness. I had thought setting it to -1 would just make the light stay on constant , but I'm just guessing that makes it increase by the brightness number every second. Is there any way to have a light stay besides setting the duration to a million?
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: FX:setlight weirdness

Post by Isaac »

I'd just like to see a functioning use of the FX object... I have yet to call it and get any visual results. :(

** The Script reference mentions fx:translate(x,y,z); but whenever I call that (with coordinates), I get a 'nil value' error... so I must be somehow calling it before it's initialized/created?.
Lmaoboat
Posts: 359
Joined: Wed Apr 11, 2012 8:55 pm

Re: FX:setlight weirdness

Post by Lmaoboat »

Isaac wrote:I'd just like to see a functioning use of the FX object... I have yet to call it and get any visual results. :(

** The Script reference mentions fx:translate(x,y,z); but whenever I call that (with coordinates), I get a 'nil value' error... so I must be somehow calling it before it's initialized/created?.
Yeah, that's a problem I've been having. FX entities inside functions don't seem to think they exist unless they're already actively doing something. Just spawning one outside a function work fine.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: FX:setlight weirdness

Post by Komag »

The X, Y, Z seem to be mixed up

I placed an FX that I named fxlight. I just put it in the middle of a room
Then I made a script nearby, set to run at mapstart:

Code: Select all

fxlight:setLight(0, 1, 0, 10, 20, 100, true)
fxlight:translate(0, 1, 0)
That is what works to get it off the ground, but I would have thought it would need to be (0, 0, 1). The documentation says:
FX:translate(x, y, z)
Translates (i.e. moves) the FX by x,y,z in world space. This function is typically used to lift particle system off the ground.
but I have to adjust the Y to make it go up off the ground. I think the X, Y should be consistent with setSubtileOffset, where X controls east-west placement, and Y controls north-south placement.
So either the documentation is wrong, or there is a bug in the program mixing up the coordinates, or I'm just reading/thinking of it wrong

(and I'm also curious what to set the duration to make it last forever, other than just using a really big number)
Finished Dungeons - complete mods to play
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: FX:setlight weirdness

Post by petri »

The engine uses a left-handed world coordinate system where Y points up. translate() operates on 3D world coordinates, subtile offset in 2D tile coordinates. So it works correctly.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: FX:setlight weirdness

Post by Komag »

Okay, I can accept that. So, in 3D space, looking north:
X: left-right
Y: up-down
Z: forward-back
Finished Dungeons - complete mods to play
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: FX:setlight weirdness

Post by petri »

Yep, that's right.
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: FX:setlight weirdness

Post by Isaac »

petri wrote:Yep, that's right.
I have a button that is supposed run a script to spawn an FX light (perhaps the star effect seen with the teleporter); but I cannot get any visual result from it. My intention is that you press the button and the effect appears.

How would I do this in the script; (spawn a particle effect at a given location)?

I'm missing something fundamental... I tried swapping out the fxlight code above, but I get no visual result. :(
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: FX:setlight weirdness

Post by petri »

Isaac wrote: I have a button that is supposed run a script to spawn an FX light (perhaps the star effect seen with the teleporter); but I cannot get any visual result from it. My intention is that you press the button and the effect appears.

How would I do this in the script; (spawn a particle effect at a given location)?

I'm missing something fundamental... I tried swapping out the fxlight code above, but I get no visual result. :(
When in doubt, Scripting Reference is your friend. :) The idea is to spawn the fx entity dynamically. See documentation of spawn() function.
Lmaoboat
Posts: 359
Joined: Wed Apr 11, 2012 8:55 pm

Re: FX:setlight weirdness

Post by Lmaoboat »

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