openmod icon indicating copy to clipboard operation
openmod copied to clipboard

Run jobs on events

Open Trojaner opened this issue 5 years ago • 2 comments

Example autoexec.yaml:

  - name: Hardcore Mode
    schedule: '@event:PlayerDeath'
    task: openmod_command
    args:
      commands: 
      - 'ban {Event.Player.Id}'
    enabled: false

Would require that the event bus allows you to subscribe to IEvent directly - don't know if that's currently possible. Would also need an efficient way to match "PlayerDeath" string to "PlayerDeathEvent" class. Assuming event class names must be unique, it should cache the match and not look it up again on every event.

Trojaner avatar Jan 24 '21 23:01 Trojaner

This syntax would be better

  - name: Hardcore Mode
    schedule: event
    task: openmod_command
    args:
      event: PlayerDeath
      commands: 
      - 'ban {Event.Player.Id}'
    enabled: false

andriivitiv avatar Jan 24 '21 23:01 andriivitiv

I just refactored all other jobs to not use args for scheduling; e.g:

  - name: OpenMod Auto Update
    schedule: 'crontab'
    task: openmod_command
    args:
      period: '0 0 * * 0'
      commands:
      - openmod upgrade
      - openmod restart
    enabled: true

became

  - name: OpenMod Auto Update
    schedule: '0 0 * * 0'
    task: openmod_command
    args:
      commands:
      - openmod upgrade
      - openmod restart
    enabled: true

See latest autoexec.yaml file. So I think using @event:<name> would be more consistent.

Trojaner avatar Jan 24 '21 23:01 Trojaner