How to create a counter timer in papyrus?

Post » Sun May 18, 2014 10:08 am

basically just the simpleest loop but i need it to count in seconds is there a way to do this ?

int x = 0

While ( x < 45 )

loopMessage.Show() ; countdown message

x += 1

end while

How to i make the loop run once a second?

Or should I use floats and like GetCurrentRealTime() ?

User avatar
Rob Davidson
 
Posts: 3422
Joined: Thu Aug 02, 2007 2:52 am

Post » Sat May 17, 2014 11:49 pm

Int x = 45   While (x >= 1)      Debug.Notification(x + "seconds")      Utility.Wait(1.0)      x -= 1   EndWhileDebug.Notification("Out of time")
I think that'll work

- Hypno
User avatar
Zach Hunter
 
Posts: 3444
Joined: Wed Aug 08, 2007 3:26 pm

Post » Sat May 17, 2014 9:39 pm

This^

User avatar
Devils Cheek
 
Posts: 3561
Joined: Sun Aug 13, 2006 10:24 pm

Post » Sun May 18, 2014 9:16 am

Ok I'll try this out thank you :)

User avatar
Sophie Payne
 
Posts: 3377
Joined: Thu Dec 07, 2006 6:49 am

Post » Sat May 17, 2014 11:40 pm

Hey It worked great but for some reason, it second takes like 2 seconds? lol

User avatar
Lizbeth Ruiz
 
Posts: 3358
Joined: Fri Aug 24, 2007 1:35 pm

Post » Sun May 18, 2014 3:32 am

Did you forget the Utility.Wait(1.0)?

Alternatively you could do something like this...

Scriptname _test_testscript extends ActiveMagicEffectfloat fStartFunction StartTimer()    fStart = Utility.GetCurrentRealTime()    RegisterForSingleUpdate(45.0)endFunctionFunction EndTimer()    UnregisterForUpdate()    float fTime = 45.0 - (Utility.GetCurrentRealTime() - fStart)    Debug.Notification("Timer has "+fTime+" seconds left")endFunctionEvent OnUpdate()    Debug.Notification("Time is up!")endEvent
User avatar
Isabell Hoffmann
 
Posts: 3463
Joined: Wed Apr 18, 2007 11:34 pm

Post » Sun May 18, 2014 3:57 am


I thought that might happen. Notification messages display for a few seconds, only three can be displayed, and the rest will get backed up in a que of sorts. Perhaps you might be better off with what mojo suggested

- Hypno
User avatar
yessenia hermosillo
 
Posts: 3545
Joined: Sat Aug 18, 2007 1:31 pm

Post » Sun May 18, 2014 10:53 am

UnRegisterForSingleUpdate() doesn't exist. UnRegisterForUpdate() will clear single update registrations.

User avatar
Agnieszka Bak
 
Posts: 3540
Joined: Fri Jun 16, 2006 4:15 pm

Post » Sun May 18, 2014 8:23 am

Oops yeah my bad - typo :P

User avatar
Trey Johnson
 
Posts: 3295
Joined: Thu Oct 11, 2007 7:00 pm


Return to V - Skyrim