Jump to content
We are aware aware of an issue with authentication on the site. See our status page for details. ×

How To Turn Lights On From Papyrus


DocClox

Recommended Posts

A linked ref is not required to play gamebryo anims.

Perhaps edit the nif in nifskope and rip out the havok behavior graph under extra data.

 

I was thinking "power state". If it can't get at the workshop, it can't determine if it's powered or not, and that might change the graph.

 

I'll have a look at removing the havok data. That could simplify things a lot.

 

 

If it's a powered light, you can do this:

Ref.PlayAnimation("Powered")
Ref.Activate(Game.GetPlayer()) ;player activates light, turning it on.
I do something similar in my Solar Street Lights mod.

 

Nope, no joy there, either :sad: Going to try linking to the workshop, and then niston's suggestion about deleting havok data.

Link to comment
Share on other sites

I have just today been working with LightOilLampOnOffSwitch and nailed together a script-ette that may contain some pointers:

 

 

 

 

Keyword 	Property pSKK_RRLightLink		Auto Const Mandatory
Light 		Property pDefaultLightFire01NSFlicker 	Auto Const Mandatory

;SetDressing\LightFixtures\LightOilLampOnOffSwitch.nif = Stage1 OFF, Stage2 Switching, Stage3 ON

;****************************************************************************************************************

Event OnActivate(ObjectReference akActivator)

Self.BlockActivation(abBlocked = True, abHideActivateText = true) ;stop keybounce queue

If (Self.GetOpenState() == 1) ;OFF
	SwitchON()
ElseIf (Self.GetOpenState() == 3) ;ON
	SwitchOFF()
Else
  ;Swear lots
EndIf

Utility.WaitMenuMode(1.0) ; for anims to complete 

Self.BlockActivation(abBlocked = False, abHideActivateText = False)

EndEvent

;****************************************************************************************************************

Function SwitchON()

Bool bReturn 
;bReturn = Self.PlayGamebryoAnimation(asAnimation = "Stage2") ;Switching
;Utility.Wait(1.0)
bReturn = Self.PlayGamebryoAnimation(asAnimation = "Stage3") ;ON
ObjectReference MyLight = Self.GetLinkedRef(pSKK_RRLightLink)
If (MyLight == None) ;Dont create duplicates on some crazy exception path.
	MyLight = Self.PlaceAtNode("SKK_ATTACHLIGHT", pDefaultLightFire01NSFlicker, aiCount = 1, abForcePersist = false, abInitiallyDisabled = false, abDeleteWhenAble = true, abAttach = true)
	Self.SetLinkedRef(MyLight, pSKK_RRLightLink) ; Dont trust NONE keyword linkedrefs.
EndIf

EndFunction

;****************************************************************************************************************

Function SwitchOFF()

Bool bReturn 
;bReturn = Self.PlayGamebryoAnimation(asAnimation = "Stage2") ;Switching
;Utility.Wait(1.0)
bReturn = Self.PlayGamebryoAnimation(asAnimation = "Stage1") ;OFF
RemoveLight()

EndFunction 

;****************************************************************************************************************

Event OnWorkshopObjectDestroyed(ObjectReference akActionRef)

Debug.Trace("SKK_RROilLampSwitchScript.OnWorkshopObjectDestroyed " + Self)
RemoveLight()

EndEvent

;****************************************************************************************************************

Function RemoveLight()

ObjectReference MyLight = Self.GetLinkedRef(pSKK_RRLightLink)
If (MyLight != None)
	Self.SetLinkedRef(None, pSKK_RRLightLink)
	MyLight.Disable()
	MyLight.Delete()
EndIf

EndFunction

;****************************************************************************************************************

 

 

 

The nif has 3 states and provides its own weak internal illumination, this adds a stronger source.

 

Note the p-AttachLight connect point shown in Preview Window is not findable/attachable so I had to add my own.

Link to comment
Share on other sites

Else
  ;Swear lots
EndIf

Hehehe. That sounds familiar :D

 

Seriously, thanks for that. That looks interesting. I know the light I'm trying to use has a TurningOn animation, but I'd been hoping I didn't need to do the two in order. Maybe that was wishful thinking on my part.

Link to comment
Share on other sites

I actually had these all lit earlier. I set up a generator and pylon and nothing happened. So I set up a shack wall and ceiling and tried putting a placing light there with the workshop - and it still wouldn't light.

 

Then the game crashed, but when I reloaded the lights were all lit. I'm definitely missing something. Maybe I'll have more luck with a different light.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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