Skip to content

Feature - Ambient Scripts #436

Closed
Closed

Description

@MiranDMC

Have an new kind of scripts that are:

  • loaded and started once as soon as the game starts, even before game session starts (new game/save load)
  • running even when the game is paused (main menu is visible)
  • keeps running, not reloaded when game session is restarted (new game/save load)

It most likely should be implemented as new, separate script queue/list.

It is not decided yet how Ambient Script files would be differentiated from regular Cleo Scripts. It feels natural to use *.as extension, but it probably make current ModLoader not recognize them.

Challenging part will be updating all already existing auto-cleanup mechanisms, like allocated memory blocks, opened file handles, fire search handles, audio streams etc. to not erase entities created by Ambient Scripts when game session ends.

Activity

  1. assigned and unassigned on Sep 3, 2025
  2. x87 commented on Sep 25, 2025

    @x87

    Have a separate queue for background scripts that run immediately as CLEO loads them and continue running regardless of user pause.

    Ensure that items that currently are cleared on game session end (allocated memory blocks, opened file handles, fire search handles, audio streams etc.), are not cleared if created from ambient scripts.

    It's unclear from this description whether they restart after new game/load game, or not.

  3. MiranDMC commented on Sep 26, 2025

    @MiranDMC
    CollaboratorAuthor

    Have a separate queue for background scripts that run immediately as CLEO loads them and continue running regardless of user pause.
    Ensure that items that currently are cleared on game session end (allocated memory blocks, opened file handles, fire search handles, audio streams etc.), are not cleared if created from ambient scripts.

    It's unclear from this description whether they restart after new game/load game, or not.

    Updated.

  4. x87 commented on Sep 26, 2025

    @x87

    Thanks. If they never restart, then they also should never capture any in-game entities (e.g. player car), as it can become invalid after any wait 0 instruction.

  5. MiranDMC commented on Sep 26, 2025

    @MiranDMC
    CollaboratorAuthor

    Thanks. If they never restart, then they also should never capture any in-game entities (e.g. player car), as it can become invalid after any wait 0 instruction.

    How to even force that? I feel like we should not. After all handle is just an number. Making AS unable to access any game entities would be huge handicap for them.
    I think there should be additional commands returning for example game session id, so it will be possible to tell if game
    started at all or it was restarted.

  6. x87 commented on Sep 26, 2025

    @x87

    Not saying to force it, just have a general recommendation for users (documentation, perhaps).

  7. x87 commented on Sep 26, 2025

    @x87

    what could be good use cases for AS?

    • early memory patches
    • menu scripts (e.g. play background music). can we render anything additional in menu, like text or sprites?
    • persistent logs

    what else?

  8. MiranDMC commented on Sep 26, 2025

    @MiranDMC
    CollaboratorAuthor

    I think script draws should work, maybe needs to add some extra trigger call.
    I already had some scripts that rendered over main menu, when menu was force displayed during game session.
    Ability to create early patches, like extending pool sizes with script is really tempting.

    AS can be also way to avoid whole nonsense that happens during game save/reload where scripts are reloaded, executed once then state is loaded.

  9. added
    type:feature
    on Nov 19, 2025
  10. added
    discussion
    on Jan 5, 2026
  11. locked and limited conversation to collaborators on Mar 7, 2026
  12. converted this issue into a discussion #542 on Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionpriority:p3type:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions