Robinsage Posted February 13, 2013 Share Posted February 13, 2013 I'm working on a script to make an area cloudy when the player enters a trigger box, but only if it's not already cloudy. The TB script works and changes the weather to cloudy upon entry, but my attempts to make it detect current weather and run only if it's not cloudy have failed. I have the weather property names valued to cloudy weather and tied to the TB, and tried using If statements and weather functions with them with no luck. Here is the working script, I just need to add the condition to run only if it detects one of the weather properties listed. -----------------------------------------------------------------------------Scriptname GetCloudyTBScript extends ObjectReference Actor Property PlayerREF AutoWeather Property stormcloud AutoWeather Property skies1 AutoWeather Property skies2 AutoWeather Property skies3 AutoWeather Property skies4 AutoWeather Property skies5 Auto Event OnTriggerEnter(ObjectReference Somebody) String EnteredArea = "the skies darken" Actor Player = PlayerREF If Somebody == Player Debug.Notification(EnteredArea) EndIf stormcloud.ForceActive(true)EndEventEvent OnTriggerLeave(ObjectReference Somebody) String LeftArea = "the skies return to normal" Actor Player = PlayerREF If Somebody == Player Debug.Notification(LeftArea) weather.ReleaseOverride()EndEvent----------------------------------------------------------------------------- Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
kromey Posted February 13, 2013 Share Posted February 13, 2013 How about a simpler conditional? With just the one stormcloud property: If Weather.GetCurrentWeather() != stormcloud stormcloud.ForceActive(True) EndIf Now you're even compatible with mods that might add new Weathers! :) If that doesn't work (I've never played with weather at all in the CK or in Papyrus, I'm mostly just making semi-educated guesses based on what I've found on the CK wiki), try this conditional: If Weather.GetCurrentWeather().GetClassification() != 1 ;True for any weather not classed as "cloudy" Link to comment Share on other sites More sharing options...
Robinsage Posted February 13, 2013 Author Share Posted February 13, 2013 You are such a great help, again Kromey. I'll try the second example, but I can't get my head around If Weather.GetCurrentWeather() != stormcloud stormcloud.ForceActive(True)EndIf Does that check for stormcloud weather (as defined) and if it is not it forces it active?That one condition would replace all the individual cloudy weather types I propertied out? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 13, 2013 Share Posted February 13, 2013 @Robinsage If Weather.GetCurrentWeather() != stormcloud stormcloud.ForceActive(True) EndIf It gets the current weather and compares it to the defined weather type in the variable stormcloud. If the current weather does not match what is defined for stormcloud then the stormcloud weather is forced active.If that is what you were thinking, then you are correct. I'm not sure if you want to use it tho because the above would be valid for any sky not matching the defined value of stormcloud. If I read your initial post correctly, you only want the stormcloud weather to happen when the skies are not already cloudy. The second option that kromy posted will trigger for any sky not already considered cloudy and may be exactly what you need. Then again, you may decide that even on cloudy but non-stormy skies you wish to change it anyway... Link to comment Share on other sites More sharing options...
cscottydont Posted February 13, 2013 Share Posted February 13, 2013 (edited) According to the wiki ForceActive should do exactly what it sounds, though SetActive might be something you want to look at as well. Also when using operators in scripts: if x == ytests equality and will run if x and y are the same if x != y tests inequality and will run if x and y are different The wiki also has an Operator Reference for all the operators you can use in scripts. Edited February 13, 2013 by cscottydont Link to comment Share on other sites More sharing options...
steve40 Posted February 13, 2013 Share Posted February 13, 2013 (edited) If Weather.GetCurrentWeather().GetClassification() != 1 ;True for any weather not classed as "cloudy"If Weather.GetCurrentWeather().GetClassification() < 1 ;True for any weather not classed as "cloudy" including rain and snow. Edited February 13, 2013 by steve40 Link to comment Share on other sites More sharing options...
Robinsage Posted February 13, 2013 Author Share Posted February 13, 2013 Thanks everyone. When using 'weather.ReleaseOverride()' will the sky revert back to the weather before TB entry or will it reset to a default weather type? I'm thinking it goes back to whatever weather type it was because the stormcloud overrode the current weather and releasing that will put the weather back to normal (i.e. rainy on entering, rainy on leaving; pleasant on entering, pleasant on leaving, etc.). Link to comment Share on other sites More sharing options...
kromey Posted February 13, 2013 Share Posted February 13, 2013 (edited) Keeping in mind again that I've not messed with weather, I think what will happen with ReleaseOverride() is that the override you started with ForceActive() will be released, and the weather will change to whatever the game thinks should be the current weather -- which most often will probably be whatever you overrode initially, but if the game engine decided the weather should change during the time the ForceActive() override was active, I believe you'll see this new weather.Either way, now that you've got a script it should be easy to test. Edited February 13, 2013 by kromey Link to comment Share on other sites More sharing options...
Recommended Posts