Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version of timer.Simple(0, fn) that runs as soon as possible #2382

Open
mgetJane opened this issue May 7, 2024 · 3 comments
Open

version of timer.Simple(0, fn) that runs as soon as possible #2382

mgetJane opened this issue May 7, 2024 · 3 comments

Comments

@mgetJane
Copy link

mgetJane commented May 7, 2024

basically should just run at the end of the current tick/frame instead of at the start of the next tick (specifically right before GM:Tick) like timer.Simple(0, function() end) does

could be called something like Defer(function() end)

the main difference is that it would execute the function before any further simulation happens and without the 1-tick delay in real time

also, using a zero-second timer.Simple is such a common pattern in gmod coding and its uses only very occasionally actually require a 1-tick delay, it would be better if we had a more intentioned function instead of practically jury-rigging with timers for this purpose

@robotboy655
Copy link
Contributor

This sounds like a duplicate of #894

@mgetJane
Copy link
Author

mgetJane commented May 7, 2024

one of my use cases is accumulating shotgun pellet hits so i can send them all in one go for clientside hitreg

using timer.Simple would add a relatively considerable delay to this for my purposes so i had to resort to doing this mess:

hook.Add("SetupMove", "CLHR_SendToServer", s2s)
hook.Add("StartCommand", "CLHR_SendToServer", s2s)
hook.Add("CreateMove", "CLHR_SendToServer", s2s)
hook.Add("PreRender", "CLHR_SendToServer", s2s)
hook.Add("Think", "CLHR_SendToServer", s2s)

(clientside, whichever one of these will get executed first is just random)

@mgetJane
Copy link
Author

mgetJane commented May 8, 2024

This sounds like a duplicate of #894

that one is only serverside and seems to be tied to physics
(though still might be a good place to execute stuff at the end of a tick?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants