Page 1 of 2
FX:setlight weirdness
Posted: Sun Sep 16, 2012 7:42 pm
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?
Re: FX:setlight weirdness
Posted: Sun Sep 16, 2012 10:53 pm
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?.
Re: FX:setlight weirdness
Posted: Sun Sep 16, 2012 11:01 pm
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.
Re: FX:setlight weirdness
Posted: Mon Sep 17, 2012 12:54 pm
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)
Re: FX:setlight weirdness
Posted: Mon Sep 17, 2012 12:59 pm
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.
Re: FX:setlight weirdness
Posted: Mon Sep 17, 2012 1:05 pm
by Komag
Okay, I can accept that. So, in 3D space, looking north:
X: left-right
Y: up-down
Z: forward-back
Re: FX:setlight weirdness
Posted: Mon Sep 17, 2012 3:24 pm
by petri
Yep, that's right.
Re: FX:setlight weirdness
Posted: Mon Sep 17, 2012 7:37 pm
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.

Re: FX:setlight weirdness
Posted: Mon Sep 17, 2012 8:14 pm
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.
Re: FX:setlight weirdness
Posted: Mon Sep 17, 2012 8:29 pm
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.