Delta Time Plugin

Under Corona there was a plugin I have used previously … and is no longer recognized by Solar2d … I could not find it on Solar2d marketplace or anywhere

[“plugin.deltatime”] = {
publisherId = “com.julianvidal”,
},

is it out there somewhere, or an alternative plugin version of it anywhere?

Thanks
Bob

My Scrappy Time library has a delta() function if that is what you’re after - https://scrappyferret.com/portfolio/scrappy-time/

Thanks Graham!

I will give it a try… I used the deltaTime plugin in my slot game app, and called this function, to make the slot reel spin smoothly

local dtMulti = Deltatime.multiplier()
reelGroup:translate(0, reelSpeed * dtMulti)

I had to do that because (as I know you know) in an enterFrame event there are time fluctuations each frame cycle. I am not honestly sure what the ‘multiplier()’ call actually does, but it kept the reels moving smoothly, so I used it. But no more, since it apparently no longer is available.

I know there are other ways to do what that plugin does, it was just simple for me to call the .multiplier() and let it do whatever it does.

In any case, I will look at scrappy-time and try to get that to work for me.

Thanks much!
Bob

Google is your friend - https://github.com/ldurniat/delta-time

Thanks SGS!

Yes, I did actually find that on google already a while back. But, the plugin I had been using on that app from back in the corona sdk (was a bit different than what the link provides). I was hoping to find the original plugin, maybe now on solar2d plugins. looking for.

The plugin still works when I run the app in the simulator … it still does it’s magic. But, the simulator spits out a bunch of ‘warnings’ about not recognizing the plugin. I assume, when I go to build the app for release on the App Store(new solar2d build) it will not work, just based on the warnings the simulator pushed out.

I was hoping to find that plugin on the solar2d plugin sites, but could not.

Thanks for you help!

Bob

Delta time is so easy to calculate that you really do not need a plugin for it.

This explains it well - http://www.webdevils.com/corona-game-loop/

You are correct. Actually I do understand delta time…
Just this plugin worked with my 5 year old ‘convoluted and super hacked-up code’. But it worked. Now I need to redo the code and I wish it would be as simple as just use ‘delta time’. For a long winded reason, it is not that simple; and that is on me. I should have not hacked-together such convoluted spaghetti code as I did 5 years ago.

Sorry to take up the forum time on this matter. Thanks for your input.

This should be a simple search and replace

local lastTime = system.getTimer() 

function getDeltaTime()
   local temp = system.getTimer()           --Get current game time in ms
   local dt = (temp-lastTime) / (1000/60)   --60fps or 30fps as base
   lastTime = temp                          --Store game time
   return dt
end

Thanks.

Tried all that ‘before’ I even posted the original question. It does not work.

It should work, and it would work, if my code was not so ‘convoluted and hacked’ together. I truly do not want to waste your time or anyone on the forum trying to explain the un-explainable! I use that same getDeltaTime() call in 2 other apps I do, and it is great; been using that for many years. But this app I did something different that the plugin was able to ‘cover’ or adjust to.

I will now obviously (without that old plugin) have to get this getDelatTime() call to work… I know it should be about the same, do the same as the plugin in did… but it does not.

I was just trying to avoid having to redo more code then just a few lines; and avoid any changes to this 5 year old app. Clearly that ship has sailed.

Thanks for all your input and effort. I will get it done, just jumping between multiple projects presently.

Your help and input is greatly appreciated.

Thanks

Okay … maybe I will ask. Here is just a partial screen shot from the terminal window.
It shows the what plugin.multiply() outputs and a colon " : " and then what the standard getDeltaTime() outputs…

these are the values generated each enterFrame. For other part of the code, I cannot use the output the getDeltaTime() does, I need the output that the plugin does.

The plugin ‘multiplies’ likely the standard deltaTime value by ‘something’ to give the values it does. That math is beyond me, maybe you already know what needs to be multiplied to the standard deltaTime amount to get the results the plugin is pushing out.

dtMultiPlug … dtMultiDelta 1.97136 : 190.9011
dtMultiPlug … dtMultiDelta 1.97136 : 0.0040799999999581
dtMultiPlug … dtMultiDelta 1.97136 : 0.0014400000000751
dtMultiPlug … dtMultiDelta 1.97136 : 0.0013200000000506
dtMultiPlug … dtMultiDelta 1.97136 : 0.0012000000000262
dtMultiPlug … dtMultiDelta 1.9818599999999 : 1.9738800000001
dtMultiPlug … dtMultiDelta 1.9818599999999 : 0.0041999999999825
dtMultiPlug … dtMultiDelta 1.9818599999999 : 0.0023999999998341
dtMultiPlug … dtMultiDelta 1.9818599999999 : 0.0012000000000262
dtMultiPlug … dtMultiDelta 1.9818599999999 : 0.001140000000014
dtMultiPlug … dtMultiDelta 1.9752000000001 : 1.9662
dtMultiPlug … dtMultiDelta 1.9752000000001 : 0.0039599999999336
dtMultiPlug … dtMultiDelta 1.9752000000001 : 0.0015600000000995
dtMultiPlug … dtMultiDelta 1.9752000000001 : 0.0013200000000506
dtMultiPlug … dtMultiDelta 1.9752000000001 : 0.001140000000014
dtMultiPlug … dtMultiDelta 1.96512 : 1.9571999999999
dtMultiPlug … dtMultiDelta 1.96512 : 0.0039599999999336
dtMultiPlug … dtMultiDelta 1.96512 : 0.0014400000000751
dtMultiPlug … dtMultiDelta 1.96512 : 0.0013200000000506
dtMultiPlug … dtMultiDelta 1.96512 : 0.0011999999998079
dtMultiPlug … dtMultiDelta 1.9802399999998 : 1.9723200000002
dtMultiPlug … dtMultiDelta 1.9802399999998 : 0.0041399999999703
dtMultiPlug … dtMultiDelta 1.9802399999998 : 0.001499999999869
dtMultiPlug … dtMultiDelta 1.9802399999998 : 0.0013800000000629
dtMultiPlug … dtMultiDelta 1.9802399999998 : 0.0012600000000384
dtMultiPlug … dtMultiDelta 2.007 : 1.9987199999999
dtMultiPlug … dtMultiDelta 2.007 : 0.0042599999999948
dtMultiPlug … dtMultiDelta 2.007 : 0.0015600000000995
dtMultiPlug … dtMultiDelta 2.007 : 0.0013800000000629
dtMultiPlug … dtMultiDelta 2.007 : 0.0012600000000384
dtMultiPlug … dtMultiDelta 1.9932600000001 : 1.99392
dtMultiPlug … dtMultiDelta 1.9932600000001 : 0.0098399999998219
dtMultiPlug … dtMultiDelta 1.9932600000001 : 0.0088200000000506
dtMultiPlug … dtMultiDelta 1.9932600000001 : 0.0073199999999633
dtMultiPlug … dtMultiDelta 1.9932600000001 : 0.0072000000001572

This is the kind of math-stuff I likely should know, but don’t. So if you understand what the author of the plugin did to ‘multiply’ what to get such a result (compared to the deltatime)… it would be helpful to me to work around the original plugin.

Thanks

Both me and Graham gave you ways of doing this. We both know that this works as we both use it for our production games.

What you do with this knowledge is up to you.

Yes, thanks for responding back.

Thankfully, as I said, I have used the delta time successfully in the past - so I knew it worked. I just needed to dig thru my ‘old code’ and find why it do not work as I had it in my code back then, but the plugin did work.

Thanks again to Grahmn and yourself.