[Bug] Running the same `action` line again adds another copy of the action, so it fires once per copy (different than Genie 4)
Maintainers usually reply within 5 days
Assessment
This issue has not been assessed yet.
Description
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
-
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 -
Start Genie (no connection needed) and run
.twice-a. -
Type
#parse test line.HITis 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.HandleActionends withinst.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 : SortedListinScript/Script.cs), and itsAddreplaces 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 withevalstill in front and its variables filled in. Genie 4'sRemovestrips theeval.
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
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from GenieClient/Genie5
-
bug
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
GenieClient/Genie5#496 ·
Maintainers usually reply within 5 days
-
enhancement g4-regression
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
GenieClient/Genie5#494 ·
Maintainers usually reply within 5 days
-
area:ui-dock enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
GenieClient/Genie5#462 ·
Maintainers usually reply within 5 days
-
area:mapper bug est:<1d P2
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
GenieClient/Genie5#449 · 1 comment ·
Maintainers usually reply within 5 days
-
[Bug] Maps ▸ Update from Official Repo / Repair Maps give no notification of success or failurePossibly taken A pull request linked to this issue is open or already merged. Openarea:mapper area:updater bug est:<1d P3
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
GenieClient/Genie5#423 · 1 assignee ·
Maintainers usually reply within 5 days
All issues in GenieClient/Genie5
Similar issues
-
documentation good first issue kind:task level:starter size:s
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Arggon/ArggonStores#66 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
[Tool] MockAPIOpenhas-image has-license has-readme new-tool ready-to-approve repo-verified
Difficulty 1/5 Under an hour Newbie friendliness 72/100
shanselman/TinyToolTown#956 ·
Maintainers usually reply within 2 days
-
bug frontend
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
[Bug]: Native build script prints a traceback when Git is missing from PATHPossibly taken @Jaisuryan-web claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
KnifeLemon/Filee#1953 ·
Maintainers usually reply within 1 day