Page 1 of 1

Help to FX

Posted: Sun Dec 30, 2012 11:02 pm
by stochastic
I was planning to get some new red light in my dungeon, however... I cannot really get that "FX" to work...

I have tried:

function test11111()
if testp1:isDown() == true
fxtest:setLight(1, 0, 0, 10, 3, 200, true)
else

end
end

with a pressure_plate and a FX

(The script doesn't work) :(

Re: Help to FX

Posted: Sun Dec 30, 2012 11:37 pm
by Hariolor
Probably easier to clone a light source and spawn or toggle it as you desire.

Add something like this to your mod_assets/scripts/objects.lua file

Code: Select all

cloneObject{
   name = "red_ceiling_light",
   baseObject = "temple_ceiling_lamp",
   particleSystem = false,
   lightColor = vec(0.75,0,0), -- sets light to red. edit the three numbers to any r,g,b values between 0 and 1 to change the color
}
then reload your dungeon in the editor and you'll have a new object called "red_ceiling_light" that you can use like any other object.

Try something like

Code: Select all

function redlighton()
  if testp1:isDown() == true
    then
    spawn("red_ceiling_light",level,x,y,facing,"myredlight")
  end
end

(tip: you don't need to put the "else" unless you want to do something else when the if statement returns false)

if you want the light to only be on while the plate is held down, you'd need a different approach. The ham-handed way is to have two functions:

Code: Select all

function lighton()
  spawn("red_ceiling_light",level,x,y,facing,"myredlight")
end

function lightoff()
  myredlight:destroy()
end

make your plate trigger "lighton" when activated and trigger "lightoff" when deactivated...I'm sure there's a more elegant solution but I think this gets the job done at least.

Re: Help to FX

Posted: Tue Jan 01, 2013 11:02 pm
by Komag
yes definitely use a lightsource and not fx for something like this