myWeather.SetActive - Help change weather by equipping armor

Post » Tue Mar 01, 2016 11:57 pm

I want to change the weather when the player equips a piece of armor but I am getting a compiling error. I am very to new to scripting so I am sure that I am using ".SetActive" wrong so if somebody could explain why I am getting this error I would appreciate it very much.



Script:



Scriptname mmmStormLordScript extends ObjectReference
Spell property LightningCloak auto
Actor property playerRef auto
ObjectReference property SkyrimStormRain auto

Event OnEquipped(Actor akActor)
if akActor == playerRef
Debug.MessageBox("Storm Lord's Cuirass equipped by the player.")
LightningCloak.cast(self, playerRef)
Debug.MessageBox("Lightning Cloak was cast on the player.")
SkyrimStormRain.SetActive(true, true)
Debug.MessageBox("Weather is looking stormy.")
endif
EndEvent

Event OnUnequipped(Actor akActor)
if akActor == playerRef
Debug.MessageBox("Player has unequipped Storm Lord's Cuirass.")
playerRef.DispelSpell(LightningCloak)
Debug.MessageBox("Lightning Cloak has been removed.")
endif
EndEvent

Compiler Error:


mmmStormLordScript.psc(11,24): SetActive is not a function or does not exist
User avatar
Lauren Dale
 
Posts: 3491
Joined: Tue Jul 04, 2006 8:57 am

Post » Wed Mar 02, 2016 2:51 am

Weather isn't an objectreference. It's type is Weather. So simply change this:



ObjectReference property SkyrimStormRain auto


To this:



Weather property SkyrimStormRain auto
User avatar
Darrell Fawcett
 
Posts: 3336
Joined: Tue May 22, 2007 12:16 am

Post » Wed Mar 02, 2016 3:48 pm

Thank you Terra Nova the script works great.



Here's the completed functional script for anyone's future reference:



Spoiler


Scriptname mmmStormLordScript extends ObjectReference
Spell property LightningCloak auto
Actor property playerRef auto
Weather property SkyrimStormRain auto

Event OnEquipped(Actor akActor)
;wait for the player to exit menu mode
while (Utility.IsInMenuMode())
Utility.Wait(1)
endwhile
;is the player equipping the armor?
if akActor == playerRef
;cast Lightning Cloak on the player
LightningCloak.cast(playerRef, playerRef)
;change the weather to be stormy
SkyrimStormRain.SetActive(true)
endif

EndEvent

Event OnUnequipped(Actor akActor)
;wait for the player to exit menu mode
while (Utility.IsInMenuMode())
Utility.Wait(1)
endwhile
;is the player unequipping the armor?
if akActor == playerRef
;dispel Lightning Cloak from the player
playerRef.DispelSpell(LightningCloak)
;release the stormy weather
Weather.ReleaseOverride()
endif

EndEvent


User avatar
Stu Clarke
 
Posts: 3326
Joined: Fri Jun 22, 2007 1:45 pm


Return to V - Skyrim