SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SH5 Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 01-31-17, 11:26 AM   #1
OldCoder
Soundman
 
Join Date: Mar 2016
Posts: 142
Downloads: 24
Uploads: 0
Default Timer/animation control?

Hi guys,

I need to figure out how to add a timer for a python script. Many of the scripts refer to TimerID_SomeTimeName with a decimal identifier.

It looks like timers (which seem to trigger animation callbacks) might be set up via one of the tools, eg Goblin Editor or something but I can't find it.

Can somebody help point the way please?
OldCoder is offline   Reply With Quote
Old 01-31-17, 05:27 PM   #2
THE_MASK
Ace of the deep .
 
THE_MASK's Avatar
 
Join Date: Jan 2006
Posts: 9,226
Downloads: 901
Uploads: 73


Default

I guess that its not people ignoring the question . Probably no one knows the answer .
THE_MASK is offline   Reply With Quote
Old 02-01-17, 10:01 AM   #3
OldCoder
Soundman
 
Join Date: Mar 2016
Posts: 142
Downloads: 24
Uploads: 0
Default

Thanks Sober.

Ok, so I think the question might be answered a different way; how do people animate items in the menus? eg, stuff moving up/down? That might help me if somebody knows how menu item animation is put together.
OldCoder is offline   Reply With Quote
Old 02-01-17, 02:49 PM   #4
THE_MASK
Ace of the deep .
 
THE_MASK's Avatar
 
Join Date: Jan 2006
Posts: 9,226
Downloads: 901
Uploads: 73


Default

Have you used the menu editor ?. I'm not saying I know how to move menu items up/down though .
THE_MASK is offline   Reply With Quote
Old 02-01-17, 03:52 PM   #5
OldCoder
Soundman
 
Join Date: Mar 2016
Posts: 142
Downloads: 24
Uploads: 0
Default

I have been into the menu editor but not being too familiar with it its difficult to know if I'm looking in the right places. I can't find anything in there that describes animation. But for example some of the buttons in the game are animated like the dive ones. It's driving me mad not finding what I'm looking for!!!
OldCoder is offline   Reply With Quote
Old 02-01-17, 04:55 PM   #6
SkyBaron
Lieutenant
 
Join Date: Mar 2010
Location: South Atlantic
Posts: 262
Downloads: 673
Uploads: 2
Default

When I was learning scripting for SH5 I came across two timer implementations, but have never used them.

There's a high precision timer provided by TDW called TDWHPT with methods like Start(), Stop(), Reset() etc. There's no documentation, you'll have to learn how it works from the scripts. Take a look at Page layout.py or Page Default Hud.py (TWOS mod.) This one is used all over the scripts.

Code:
clr.AddReference( "TDWHPT" )
from TheDarkWraith.SilentHunter5 import TDWHPT

# create the high precision game timer
	global Pagelayout_HPTimer
	Pagelayout_HPTimer = TDWHPT( Menu, Game, Pagelayout_GameTimerEvent )

There seems to be a "default" timer as well that uses StartAnimation(), StopAnimationsWithID() and TimerIDs, but I'm not sure how this one works.
__________________


SkyBaron is offline   Reply With Quote
Old 02-01-17, 06:40 PM   #7
OldCoder
Soundman
 
Join Date: Mar 2016
Posts: 142
Downloads: 24
Uploads: 0
Default

Hi SkyBaron,

Thanks for the pointer; TDWHPT seems to be the timer library (the dll) created by TDW.

Then we have all the different instances of timers (which are the TimerID_something) located around the python scripts; the scripts calling the TDWHPT API calls of etc StartAnimation(), StopAnimationsWithID() etc, to make them functional.

So... I need to figure out how to create a new instance of TimerID, and this is the problem. I've searched high and low across the forum and trying to figure out how to create a timer. So far, no progress. After Enigma, if you fancy a challenge, I'm sure it will benefit everybody in the long run if we can work it out (before i lose my marbles).
OldCoder is offline   Reply With Quote
Old 02-01-17, 07:47 PM   #8
OldCoder
Soundman
 
Join Date: Mar 2016
Posts: 142
Downloads: 24
Uploads: 0
Default

Progress!

I focused on the subtitles timer, since it's a very simple script, and went hunting.

See screenshot, animation array 0 id:




.... maps to the TimerID within the Python script:

TimerID_Update = 90797097

That's enough for tonight but it's only a matter of time now.
OldCoder is offline   Reply With Quote
Old 02-02-17, 05:44 AM   #9
OldCoder
Soundman
 
Join Date: Mar 2016
Posts: 142
Downloads: 24
Uploads: 0
Default

Spoke too soon; that's just showing me the currently loaded/running timer active on the subtitles page. Disappointing...
OldCoder is offline   Reply With Quote
Old 02-02-17, 06:22 AM   #10
OldCoder
Soundman
 
Join Date: Mar 2016
Posts: 142
Downloads: 24
Uploads: 0
Default

Ok I'm starting to think these timer id's are just arbitrary unique numbers, possibly created via a hash generator. Reason for that thought is I changed the existing timer id's directly in the Subtitles python file and the animation detail in the script editor showed the new id. Script didn't barf like mine did, so maybe I've been barking up the wrong tree and maybe just need to figure out what I did wrong in the script.

This thread reads like diary of a noob.
OldCoder is offline   Reply With Quote
Old 02-02-17, 09:29 AM   #11
OldCoder
Soundman
 
Join Date: Mar 2016
Posts: 142
Downloads: 24
Uploads: 0
Default

SO after many hours I have it working now, a script using the TimerID. I had been led down the wrong path by trying to start the animation from the initialisation function. After defining the TimerID value, wait until StartGame before trying to start the animation, otherwise the animation system doesn't recognise the id and throws an error.

Now I know this info I will probably write a tutorial about it all if anyone's interested in how to use timers in their scripts.
OldCoder is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 10:06 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 1995- 2024 Subsim®
"Subsim" is a registered trademark, all rights reserved.