Page 1 of 1

Delay of code execution to next frame during pause

Posted: 21 Aug 2017, 04:32
by gajop
In SpringBoard, it is often necessary to delay execution of code to the next frame.
At the same time, during editing, I would like for the game to be paused.
As there are no continuous callins when paused, it cannot be used when it is necessary to delay calls.
Currently I am emulating pause by paralyzing all units, but game mechanics can still happen based on game frames, which is unwanted.

I would like to have a new PausedGameFrame callin in both synced and unsynced (LuaUI, LuaRules), that would allow me to delay execution while still being paused. Is this possible?

Re: Delay of code execution to next frame during pause

Posted: 21 Aug 2017, 15:44
by Kloot
No, simulation time either advances (when the server says so) or it doesn't.

If game mechanics get in the way during editing, then games should support an editor mode to disable them.

NB: as the host player you can also issue singlestep actions (e.g. from the unsynced Update callin) while paused to advance the simulation by one frame.

Re: Delay of code execution to next frame during pause

Posted: 21 Aug 2017, 16:34
by sprunk
In SpringBoard, it is often necessary to delay execution of code to the next frame.
It's not limited to SpringBoard. Many callins disallow recursion (eg no CreateUnit in UnitCreated, no GiveOrder in CommandFallback, etc) so you are forced delay the call. I think it would be good to allow recursion but the last time I asked it was said to be there on purpose (so that clueless devs dont hurt themselves).

Re: Delay of code execution to next frame during pause

Posted: 21 Aug 2017, 17:17
by gajop
Games having to support editor mode explicitly isn't ideal (although it's what I'm doing now), as then every game developer needs to spend extra time to configure their game for SB.

And it's not just those things sprunk mentioned. Emulating pause by stunning units is lame, as it doesn't allow me to edit scenarios where some units are stunned and some aren't (unless we introduce more game-specific workarounds which is bad).

I also don't see how I would edit projectiles now or decals in the future.

I would really like to edit while paused (or while in a new editor-specific mode that would be added to the engine)

Re: Delay of code execution to next frame during pause

Posted: 21 Aug 2017, 17:40
by sprunk
I think the way to handle projectiles would be to add a toggle that prevents collision to the engine, and then do that + freeze them with SetProjectileMoveControl.

Making decals not linger after you delete a building (since they normally need time to decay) would also ideally be achieved if there was `Spring.GetDecal(unitID)` so you could just remove it on parent unit's death.

Edit: just realized that for singleplayer editing, you can do what Kloot says except instead of `/singlestep`, do `/luarules PausedGameFrame` and make your gadget handler interpret this. This way you have the callin based on the passage of time but the simulation won't actually run.