How does DynamicValueInterpolator work?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
dastrukar
Posts: 45
Joined: Thu Sep 20, 2018 11:38 pm

How does DynamicValueInterpolator work?

Post by dastrukar »

I'm currently in the process of making a ZScript HUD, however, I can't understand how DynamicValueInterpolator works at all.
Any help would be appreciated.
D2JK
Posts: 543
Joined: Sat Aug 30, 2014 8:21 am

Re: How does DynamicValueInterpolator work?

Post by D2JK »

First declare an object of it as a member variable:

Code: Select all

Class MyStatusBar : BaseStatusBar
{
	DynamicValueInterpolator DVIa;
	DynamicValueInterpolator DVIb;
	...
}
Then it must be initialized:

Code: Select all

Override void Init()
{
	Super.Init();
	DVIa = DynamicValueInterpolator.Create(0, .25, 1, 8);     // Parameters: starting value, change factor, min change per update, max change per update
	...
}
Then, its value needs to be constantly updated:

Code: Select all

Override void Tick()
{
	Super.Tick();
	DVIa.Update(CPlayer.health);	// Player health variable inside brackets, as an example
}
Finally, you can now make use of it in your code:

Code: Select all

protected void DrawFullScreenStuff(double TicFrac)
{
	...
	DrawBar("HBARA0", "HBARY0", DVIa.GetValue(), 100, (15,1021), 0, 0);    // Note the GetValue() call
}
User avatar
dastrukar
Posts: 45
Joined: Thu Sep 20, 2018 11:38 pm

Re: How does DynamicValueInterpolator work?

Post by dastrukar »

Wow, this actually helped out a lot!
Thanks for your help, it is much appreciated.
Post Reply

Return to “Scripting”