Repeats and Delays based on ticks

Discuss API design here.
User avatar
InvisibleSoldiers
Senior Member
Posts: 104
Joined: Fri Mar 15, 2019 6:08 am

Repeats and Delays based on ticks

Postby InvisibleSoldiers » Wed Apr 29, 2020 1:26 pm

At the moment repeats and delays are counted by real time which is a bit strange because we have to consider the time of the game itself.
For example server has host_timescale 0.5 and some delay will be executed in 5 seconds, for now the delay will be really executed in 5 seconds despite host_timescale and only if we count by tick, we will do it in combination with the game and everything will seem right (it will be executed in 10 seconds)
User avatar
L'In20Cible
Project Leader
Posts: 1302
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Repeats and Delays based on ticks

Postby L'In20Cible » Wed Apr 29, 2020 1:47 pm

Implementing a subclass of Delay (perhaps named TickDelay) that handle delays based on frame count rather than time could be an option. Feel free to make a PR that we can base a discussion on. :smile:
User avatar
InvisibleSoldiers
Senior Member
Posts: 104
Joined: Fri Mar 15, 2019 6:08 am

Re: Repeats and Delays based on ticks

Postby InvisibleSoldiers » Thu Apr 30, 2020 2:45 pm

I suggest simply replace current Delay to tick based Delay. In general nothing will change and it will get better in some cases, the game has its own time and we need respect that. Even now all happens in @OnTick listener which is executed every tick_interval and delay time can be only t * tick_interval, in other words there is absolutely no point in the current implementation
User avatar
Ayuto
Project Leader
Posts: 2070
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Repeats and Delays based on ticks

Postby Ayuto » Thu Apr 30, 2020 7:05 pm

Don't you think saying "there is absolutely no point in the current implementation" is a little bit exaggerated? What if someone really wants to execute something after x real seconds? Think of something that communicates with something else outside of the game. I don't think that's far-fetched.

Nevertheless, it's something I would like to discuss. I would also tend to have it tick based, but having both options (TickDelay and Delay - or simply an optional parameter in the Delay class like tick_based=True) would be great.
User avatar
InvisibleSoldiers
Senior Member
Posts: 104
Joined: Fri Mar 15, 2019 6:08 am

Re: Repeats and Delays based on ticks

Postby InvisibleSoldiers » Thu Apr 30, 2020 7:38 pm

Ayuto wrote:

It is really very rare that you need to pass host_timescale and usually it is always 1 so there is no diffrence always will be the same time (except server lags, host_timescale), that is, I think such a rare case does not deserve attention. Time in game usally has higher priority than real time.
Imagine a server has spawnprotection for 5 seconds, and the server freezes for unknown reasons for 5 seconds, with current Delay when server unfreezes, spawn protection already will be disabled. I mean Delay and Repeat frequently used for in game actions and ingame sync(preferably) and not real time dependent.
All I need when writing plugins is just tick based because it more accurate and synced with game. Ok, let's not argue. TickDelay is great.
User avatar
Ayuto
Project Leader
Posts: 2070
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Repeats and Delays based on ticks

Postby Ayuto » Thu Apr 30, 2020 7:58 pm

Don't get me wrong. You brought up some valid points and I'm completly with you. Is this something you want to work on or do you want to leave this up to us?
User avatar
InvisibleSoldiers
Senior Member
Posts: 104
Joined: Fri Mar 15, 2019 6:08 am

Re: Repeats and Delays based on ticks

Postby InvisibleSoldiers » Thu Apr 30, 2020 8:12 pm

Ayuto wrote:Don't get me wrong. You brought up some valid points and I'm completly with you. Is this something you want to work on or do you want to leave this up to us?

You mean replace current Delay to tick based only? I can do it myself, no problem.
User avatar
Ayuto
Project Leader
Posts: 2070
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Repeats and Delays based on ticks

Postby Ayuto » Thu Apr 30, 2020 8:34 pm

Yes, please create a PR we can further discuss, thanks!

Return to “API Design”

Who is online

Users browsing this forum: No registered users and 3 guests