Jump to content

Constant checking on activation


Xilante

Recommended Posts

Hello everyone! =)

I have a problem with a script which I'd like to check constantly a variable once activated.

 

So far I tried this:

 

 

Event OnActivate(ObjectReference akActionRef)

if akActionRef == Game.GetPlayer()

if Weather.GetCurrentWeather().GetClassification() == 0

Debug.MessageBox("It's sunny, I will deactivate rain!")

Test.disable()

else

if Weather.GetCurrentWeather().GetClassification() == 1

Debug.MessageBox("It's cloudy so I will deactivate rain!")

Test.disable()

Endif

Endif

Endif

EndEvent

 

 

It does compile but most likely I'm using the wrong event and can't seem to find the one I'm looking for.

 

To better understand what I'm looking for, here's the situation:

 

Initially the marker is disabled, so it should do nothing, then...

I will enter a trigger and once I'm inside it will enable the marker (with the script I need), when I entered that trigger it was still raining or snowing, so at first the marker's script will do nothing but will keep checking constantly, once a pleasant or cloudy weather pops up the marker's script will "react" and display either of those messages.

 

If you are wondering, "test" is the marker which is going to deactivate itself once the message is displayed (I don't know if there's a better command to have a script disable itself and not by another one, if there's any please tell! =) ).

 

While if you're wondering why the message is telling me that the rain has been deactivated while it's checking if a sunny or cloudy weather popped up then it's because the "rain" is actually an external effect which is not part of the weather, and they're linked to the marker, so once the marker is disabled the rain effect should also dissapear and that's because I need this script, otherwise the rain effect would still keep going on even while the sunny/cloudy weather is on.

 

Any help is welcome!

Thanks in advance! =)

Link to comment
Share on other sites

I kept trying a bunch of different things but with no success =S

 

I didn't know how to make the script disable itself, so to make things easier and simpler, I made another marker to do it.

So again, What I'm trying to do is having my character get in a trigger and if it's rainy it will activate two markers: A marker activating a rain effect and a marker which script is what I'm about to ask help for.

 

This second marker, once activated, should be checking constantly the weather and when it's sunny (or cloudy) it will disable the other marker (Making the rain effect go away), so far I tried a bunch of different things which seemed to make sense to me and also compilated fine but did not work, I don't know how close I went to accomplish what I need but I hope you guys will be able to help me with this =), Here I go:

 

Event OnInit()
   If Weather.GetCurrentWeather().GetClassification() <= 1
       PSG.Disable()
   Else
       GoToState("RainOn")
   EndIf
EndEvent

State RainOff
   Event OnBeginState()
       If Weather.GetCurrentWeather().GetClassification() <= 1
           PSG.Disable()
       Else
           GoToState("RainOn")
       Endif
   EndEvent
EndState

State RainOn
   Event OnBeginState()
       If Weather.GetCurrentWeather().GetClassification() <= 1
           PSG.Disable()
       Else
           GoToState("RainOff")
       Endif
   EndEvent
EndState

 

In this script I thought that the first part would run when the script is initialized, if the weather when initialized would have been 1 (cloudy) or less (0, pleasant/sunny) would have disabled the other marker right away or else it would go on another state which again would check for the weather, whatever it's sunny or cloudy and if not, it would send "it" to the other state which would do the same and then back again (Generating a continous loop), while it compiled fine and seemed like a good idea, In-game it didn't work at all (I also tried putting == 1 and do another line of code for == 0 but the result was the same).

[PSG is the marker I'm trying to disable]

 

Then...

 

Function Checktime()                
 registerForUpdate(5) ; Check for sunny or cloudy weather every 5 seconds.
EndFunction


Event OnInit()
   If Weather.GetCurrentWeather().GetClassification() == 0
       PSG.Disable()
   Else
       GoToState("RainOff")
   EndIf
EndEvent

State RainOff
   Event OnUpdate()
       If Weather.GetCurrentWeather().GetClassification() == 1
           PSG.Disable()
       Elseif Weather.GetCurrentWeather().GetClassification() == 0
           PSG.Disable()
       Endif
   EndEvent
EndState

 

I did a similar thing but using OnUpdate event instead but again it didn't work, it did compile but in game it was as if it didn't exist at all so I continued with something else (which was the first attempt mixed with the rest):

 

Function Checktime()                
 registerForUpdate(5) ; Check for sunny or cloudy weather every 5 seconds.
EndFunction

Event OnActivate(ObjectReference akActionRef)
    if akActionRef == Game.GetPlayer()
        if Weather.GetCurrentWeather().GetClassification() == 0
            PSG.Disable()
        else
            if Weather.GetCurrentWeather().GetClassification() == 1
                PSG.Disable()
                else
                    GoToState("RainOff")
            Endif
        Endif
    Endif
EndEvent

State RainOff
   Event OnUpdate()
       If Weather.GetCurrentWeather().GetClassification() == 1
           PSG.Disable()
           UnregisterForUpdate() 
       Elseif Weather.GetCurrentWeather().GetClassification() == 0
           PSG.Disable()
           UnregisterForUpdate() 
       Endif
   EndEvent
EndState

 

And again, it compiled, it seemed pretty much logic and sure it would work but it didn't at all, just like my previous attempts.

 

I don't know what else to try...

Perhaps I'm doing a small mistake that I'm not noticing or maybe I'm not even close to the right "script" that handles that kind of stuff.

Anyway, Any help is highly appreciated =) Thank you!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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