Jump to content

How does utility wait really works?


Recommended Posts

Posted

Hi! I wonder how utility wait command actually works. If I use it inside a function, to wait for say a long period of time, will it just a pause the end of that function and go on running other commands, or will it stop all the script run altogether for that time?

 

I want to make a cooldown function, and using registerforsingleupdate() doesn't really work for me. Thank you for your help!

Posted

it pauses that thread at that exact spot until the time expires. other scripts in other threads will continue as normal.

Got it! Thank you! So say if have utility.wait implemented inside a function and i put in a very long time, say an hour. Would a frequent periodical call for this function, cause overload on papyrus?

 

I also wonder if you know if onupdate event is configured to essentially just call utility wait command inside it?

Posted

the timer method would be the proper way to do it to avoid stacking entire threads. if its not working then you probably just need to rethink how you are doing or getting caught by something you don't know yet. like if its a spell magic effect on an npc you're going to have a bad time no matter which way you do it after crossing a load door.

Posted

the timer method would be the proper way to do it to avoid stacking entire threads. if its not working then you probably just need to rethink how you are doing or getting caught by something you don't know yet. like if its a spell magic effect on an npc you're going to have a bad time no matter which way you do it after crossing a load door.

I understand, thanks!

Didn't know about the timer, very useful. Unfortunately can't use it either in my case. I need something that I could pass an object to. Like if there was a timer with an additional variable to pass an object to, an actor in my case. I wonder if it's possible to create custom timers to take more variables.

Posted

in the very least you could try to lock a potentially smaller dedicated thread. knowing nothing about what you are doing or how you are doing it...

ScriptName SomeGlobalScript extends Quest

Function InOneHourDoWhatevs(Form Something)
    self.RegisterForModEvent("MyTriggerEvent","MyTriggerHandler")

    Int EventID = ModEvent.Create("MyTriggerEvent")
    ModEvent.PushForm(EventID,Something)
    ModEvent.Send(EventID)

    Return
EndFunction

Function MyTriggerHandler(Form Something)
    Utility.Wait(3600)

    ;; whatevs.
    If(Something as Actor != None)
        (Something as Actor).Kill()
    EndIf

    Return
EndFunction

elsewhere

ScriptName SomeEffectScript extends ActiveMagicEffect

SomeGlobalScript Property Main Auto

Event OnEffectStart(Actor Target, Actor Caster)
    Main.InOneHourDoWhatevs(Target as Form)
    Return
EndEvent

Posted

 

in the very least you could try to lock a potentially smaller dedicated thread. knowing nothing about what you are doing or how you are doing it...

ScriptName SomeGlobalScript extends Quest

Function InOneHourDoWhatevs(Form Something)
    self.RegisterForModEvent("MyTriggerEvent","MyTriggerHandler")

    Int EventID = ModEvent.Create("MyTriggerEvent")
    ModEvent.PushForm(EventID,Something)
    ModEvent.Send(EventID)

    Return
EndFunction

Function MyTriggerHandler(Form Something)
    Utility.Wait(3600)

    ;; whatevs.
    If(Something as Actor != None)
        (Something as Actor).Kill()
    EndIf

    Return
EndFunction

elsewhere

ScriptName SomeEffectScript extends ActiveMagicEffect

SomeGlobalScript Property Main Auto

Event OnEffectStart(Actor Target, Actor Caster)
    Main.InOneHourDoWhatevs(Target as Form)
    Return
EndEvent

Thank you, mate! Really useful stuff. I think I'll try to implement a workaround with timer, if it doesn't work I'll give this a try. Really appreciate your help! 

 

Edit: I wonder how setting many timers would effect the papyrus. 

Edit 2: just tried to compile my script, it complains it can't find startTimer function for some reason...

Edit 3: wait a second...are timers only available for fallout 4 and it's creation kit? well i'm coding for skyrim

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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