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: 2972
Joined: 05 Aug 2009, 20:42

Delay of code execution to next frame during pause

Post by gajop » 21 Aug 2017, 04:32

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?
0 x

Kloot
Spring Developer
Posts: 1842
Joined: 08 Oct 2006, 16:58

Re: Delay of code execution to next frame during pause

Post by Kloot » 21 Aug 2017, 15:44

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.
0 x

sprunk
Posts: 79
Joined: 29 Jun 2015, 07:36

Re: Delay of code execution to next frame during pause

Post by sprunk » 21 Aug 2017, 16:34

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).
0 x

gajop
Moderator
Posts: 2972
Joined: 05 Aug 2009, 20:42

Re: Delay of code execution to next frame during pause

Post by gajop » 21 Aug 2017, 17:17

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)
0 x

sprunk
Posts: 79
Joined: 29 Jun 2015, 07:36

Re: Delay of code execution to next frame during pause

Post by sprunk » 21 Aug 2017, 17:40

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.
0 x

Post Reply

Return to “SpringBoard”