Jump to content

How To Turn Lights On From Papyrus


DocClox

Recommended Posts

I have a complex furniture nif that has a couple of attached lights. What I'd like to do is have the lights turn on when the furniture is in use and turn off again when not. It's not as simple as just toggling power to the lights: I want them off if the device is powered but empty.

 

I can catch the events with OnActivate and OnExitFurniture, but I can't work out how to change the light state. Looking at the nif, I thought I might be able to send playidle("On") or playidle("TurningOn") or even playidle("UnpoweredOn") ... but I've had no luck.

 

Last time I did this, I frigged it with separate addon meshes for on and off, and attaching light objects to provide the glow. I'll do that again if I have to, but it seems like a lot of fuss when there's a vanilla object with the functionality built-in. If only I can find the "on" switch.

Link to comment
Share on other sites

Try PlayGamebryoAnimation("<name>", true)

 

You can see the anim names in preview window.

I keep forgetting about the preview window. And I've only tried from the console, so "PlayGamebryoAnimation" could well be what I'm missing.

 

Thanks. I'll give that a shot.

 

[edit]

 

Good call about the preview window. Looks like I had the right event names from the nif, so my problem must have been that I was using "playidle" from the console rather than PlayGamebryoAnimation

Edited by DocClox
Link to comment
Share on other sites

It's still not co-operating.

objectreference function add_spot(string node)
        int count = 10
        objectreference ref = placeatnode(node, DLC06VltLightCeiling, abForcePersist=true, abAttach=true)
        while ! ref.Is3dLoaded() && count > 10
                count -= 10
                utility.wait(0.1)
        endwhile
        ref.setscale(0.7)
        utility.wait(0.1)
        ref.playGamebryoAnimation("On", true)
        return ref
endfunction

I think the event is being processed by the graph, since subsequent attempts to turn the light on yield an error in the logs. But the light does not glow or emit.

 

I tried setting up a generator and pylon ahead of time, but that doesn't seem to help.

 

I did wonder if it was because I placed them from papyrus rather than the workshop, but the only thin I could think of to do in that case would be to point the light at the local workshop, and that property appears to be read only.

Apart from that, I'm out of ideas.

Link to comment
Share on other sites

For that light, at least the texture should change when you play the On/Off animations. Does it?

Also it has a p-AttachLight connection point. Maybe the actual light source is added by OMOD or something. I'm not familiar with this method, so I can't be more specific.

Link to comment
Share on other sites

For that light, at least the texture should change when you play the On/Off animations. Does it?

Not a sausage. I'm wondering if I need to set a linked ref to the workshop. There's a lot I don't understand about script-pacing workshop items.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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