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.