[Bug] Running the same `action` line again adds another copy of the action, so it fires once per copy (different than Genie 4)

Open
#473 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 5 days

@syntaki is already working on this.

Since Dec 1, 2026.

  • #474 by @syntaki — open

Assessment

This issue has not been assessed yet.

Description

g4-regression

What happened

Each time a script runs an action ... when ... line, Genie 5 adds a new action, even when the script already has one on that trigger. All the copies fire, so the command runs once per copy on every matching line.

Scripts written for Genie 4 run their action lines again whenever they pass through their setup code. On 5.0.1-beta.5 the list keeps growing for as long as the script runs, and every copy is tried against every game line.

What you expected

One action per trigger, as in Genie 4. Registering a trigger the script already has should replace that action.

Steps to reproduce

  1. Save this as twice-a.cmd:

    var n 0
    setup:
    action put #echo HIT when ^test line
    math n add 1
    if %n < 3 then goto setup
    put #echo SETUP DONE
    waitfor this never comes
    
  2. Start Genie (no connection needed) and run .twice-a.

  3. Type #parse test line. HIT is printed three times.

With the action line run once, HIT is printed once.

Two different commands on one trigger both run: after action put #echo FIRST when ^test line and action put #echo SECOND when ^test line, the same #parse prints FIRST and SECOND. Genie 4 keeps only the second.

Environment

  • OS + version: Ubuntu 26.04
  • Genie 5 version: 5.0.1-beta.5
  • Install type: AppImage
  • Connection mode: not connected (the steps need no connection)

Logs / session capture

[script] twice-a started (~/.local/share/Genie5/Scripts/twice-a.cmd)
SETUP DONE
HIT
HIT
HIT

Anything else

Cause, as far as I can read it:

  • ScriptEngine.HandleAction ends with inst.Actions.Add(new ScriptAction { … }) and never looks for the trigger first. Genie 4 keeps a script's actions in a list keyed by the trigger (ClassActionList : SortedList in Script/Script.cs), and its Add replaces an entry that is already there.
  • action remove eval <expr> removes nothing, so the usual remove-then-register does not help for evaluated actions. An evaluated action is stored as its bare expression with the variables left in; the remove line is compared with eval still in front and its variables filled in. Genie 4's Remove strips the eval .

The same is true of main as of d1373a5.

Workaround: put action remove <trigger> in front of each action line that can run again. It works for plain triggers, not for evaluated ones.

One thing my fix changes beyond the steps above: a script that registers two different commands on the same trigger gets only the last one, as in Genie 4. Today both run.

I have a fix with tests (registering a trigger the script already has replaces that action, and action remove eval removes the evaluated action), and a pull request follows.

Dominant language
C#
Stars
2
Forks
5
Avg merge
4d 3h
Merged PRs (30d)
22

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from GenieClient/Genie5

All issues in GenieClient/Genie5

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.