Delay of code execution to next frame during pause

Delay of code execution to next frame during pause

gajop's in-engine scenario and map editor

Moderators: Moderators, Content Developer

Post Reply
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Delay of code execution to next frame during pause

Post 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?
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Delay of code execution to next frame during pause

Post 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.
sprunk
Posts: 100
Joined: 29 Jun 2015, 07:36

Re: Delay of code execution to next frame during pause

Post 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).
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Delay of code execution to next frame during pause

Post 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)
sprunk
Posts: 100
Joined: 29 Jun 2015, 07:36

Re: Delay of code execution to next frame during pause

Post 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.
Post Reply

Return to “SpringBoard”