Jump to content

Turning a Light on/off with item placment... I knew it couldn't be that simple...


nhguy03276

Recommended Posts

I'm working on a "Art Gallery" mod, where the player can collect, buy, or steal artworks from across Tamreil and display them in their own private Gallery. By Making the painting shields, I can use Shield racks to allow players to re-arrange the paintings at will. Tired of that Van Gogh over the fireplace, switch it out with something else, even that shield you like. This has been working out quite well so far. Now onto the next step, lighting.

 

Since this is a gallery, I want to use highlight lighting like most galleries do, to really make the painting pop, but I really don't want the lighting on if there isn't a item in that location. So I attached two simple scripts, one to the trigger, the other to the activator. So when you place a shield on the rack, the light turns on, and when you take it, the light turns off. A couple screen shots of it in action can be found here http://imgur.com/a/zxejI This works great, until you leave the cell. Upon returning to the cell, all lights are off, even the racks that have items in them.

 

The light on script Attached to the "White Box" of the shield rack

Scriptname PaintingLight extends ObjectReference  
ObjectReference Property PLight Auto

 Event OnActivate(ObjectReference akActorRef)
    Plight.enable()
 EndEvent

The light off script attached to the "dot" of the shield rack

Scriptname PaintingLightsOff extends ObjectReference  
ObjectReference Property PLight Auto

 Event  OnTriggerLeave(objectReference triggerRef)
    Plight.disable()
 EndEvent

I knew it couldn't be that simple, and I'm clearly missing something to check whether the item is in the slot or not, when the cell loads... However, I'm also wondering if it would simply be better to put a separate trigger box, not referenced to the rack, over the area where the shield will be and attach a single light toggle script to that instead. I'm just concerned with two triggers on a single item. Any thoughts?

Link to comment
Share on other sites

That's because technically when you OnCellAttach() into the cell, all weapon and shield racks reset and reattach their objects, so it's tripping your OnTriggerLeave() event on the shield node.

 

You could try something like this:

 

 

Scriptname PaintingLightsOff extends ObjectReference 
ObjectReference Property PLight Auto

Event OnTriggerLeave(objectReference triggerRef)
if Self.GetDistance(Game.GetPlayer()) <= 100
     Plight.disable()
Endif
EndEvent

 

That would condition the light off function to only trigger when the player is within 100 units of it (presumably only close enough to remove it themselves)

Link to comment
Share on other sites

That's because technically when you OnCellAttach() into the cell, all weapon and shield racks reset and reattach their objects, so it's tripping your OnTriggerLeave() event on the shield node.

 

You could try something like this:

Scriptname PaintingLightsOff extends ObjectReference 
ObjectReference Property PLight Auto

Event OnTriggerLeave(objectReference triggerRef)
if Self.GetDistance(Game.GetPlayer()) <= 100
     Plight.disable()
Endif
EndEvent

That would condition the light off function to only trigger when the player is within 100 units of it (presumably only close enough to remove it themselves)

Thanks for that... I had a feeling it was something like that, but still learning the way things work here in skyrim..

 

However, now it is decision time... Initially I liked the thought of the lights being automatic... but for test purposes, after not getting it to work properly, I separated the light trigger from the painting trigger, so you have to manually turn the lights on and off.. This works well, and the more I think about it, the more I think I may end up going that route as simply there may be times when the Highlight light might make things look worse and you'll want to turn them off... ( right now, the main lights and Ambient lights are turned off to make it easier to see the highlights, but I could see over saturation issues could occur when they are back on.... Downfall, two triggers in a area instead of one... guess this is just something I'll need to decide....

Link to comment
Share on other sites

Nice ... I'd change the Activate "Shield Rank" to Activate Painting - or something like that ...

Thanks, I do plan on using the text override and changing it to "Hang Painting" eventually, but I haven't gotten that far yet.

Edited by nhguy03276
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...