[Bug] #goto sends a map exit's $variable to the game literally; script put/send does not expand $variables (Genie4 does)

Open
#437 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 5 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp, shell
Domain
cli

Research direction

Start with the script put/send case in src/Genie.Core/Scripting/ScriptEngine.cs (around L1949-2076), where each segment goes to _sendCommand, and compare it with CommandEngine.ProcessInput in src/Genie.Core/Commanding/CommandEngine.cs (L196), which calls _host.ExpandVariables. Reproduce with #var shard.pw anything and a script that sends '$shard.pw. Done means the script's sent text expands $variables before reaching the game, and the mapper hand-off works, which needs a maintainer decision on scope.

Written by the indexing model from the issue text.

Description

area:scripting bug P2

What happened

With automapper.cmd installed (automapperscript on, the default), #goto through a map exit whose move contains a Genie variable sends the variable's name to the game instead of its value.

The community Shard map has this exit into the Thieves' Guild:

<arc exit="go" move="room knock door;'$shard.pw;go door" ... />

I had shard.pw defined. My character said $shard.pw out loud and walked into the closed door. When I typed the same three commands by hand with the real password, the door opened, and automapper.cmd, which was still running, finished the walk.

What you expected

I expected $shard.pw to be replaced by its value before the line is sent. Genie 4 does that: the same map and the same automapper.cmd get through this door there.

Steps to reproduce

  1. Define the variable: #var shard.pw anything.
  2. Have automapper.cmd in the Scripts folder and #config automapperscript on.
  3. #goto a room on the far side of an exit whose move contains $name. The current maps have seven: Map67_Shard.xml (one, $shard.pw) and Map30_Riverhaven.xml (six, $haven.pw, e.g. room sear;-3knock concealed door;-whisp door $haven.pw).
  4. At that exit the script sends '$shard.pw unexpanded.

Environment

  • OS + version: Ubuntu 26.04.1 LTS
  • Genie 5 version: 5.0.0 (04-Linux-Genie5.AppImage)
  • Install type: AppImage
  • Connection mode: Direct SGE
  • automapper.cmd: autoversion 8.2026-07-09

Logs / session capture

Next move: room knock door;'$shard.pw;go door
[Shard, Dark Hallway]
Obvious exits: north.
knock door
'$shard.pw
You knock on the door.
A moment later, a slit opens in the door at eye level.  The eyes seem to study you for a moment, then a voice whispers to you through the slit, "You look familiar, but I need to be sure.  What is the password?"
go door
You say, "$shard.pw."
BONK!  You smash your nose on the door.
From behind the doorway you hear a faint chuckle.

Anything else

I don't know whether this is a regression. The first time I used this exit in Genie 5 was on 5.0.0. I searched the open and closed issues for shard.pw, haven.pw and automapper variable problems and found nothing.

I read the source at v5.0.0 (ee4480c) to see why. This is what I think happens:

  • MapperViewModel.TryHandOffToAutomapperScript (src/Genie.App/ViewModels/MapperViewModel.cs L2582-2600) passes the FindPath moves to Scripts.TryStart("automapper", moves) as they are, so the script receives $shard.pw as text. Genie 4 does not expand at launch either.
  • automapper.cmd sends the move with put %movement. ReplaceSigils (src/Genie.Core/Scripting/ScriptEngine.cs L3546-3560) leaves a $ inside a substituted value alone, and its comment says Genie 4 does the same ("a resolved value that itself contains % or $ stays literal (also Genie 4)").
  • The script put / send case (ScriptEngine.cs L1949-2076) then hands each segment that goes to the game to _sendCommand(outbound). The text never goes through CommandEngine.ProcessInput, where _host.ExpandVariables(input) (src/Genie.Core/Commanding/CommandEngine.cs L196) expands $variables for typed input, trigger actions and # commands. GenieCore.cs L754-763 says scripts do not pass through SendToGame.
  • Genie 4 (main, 2753d25) does expand at that point. Script.SendText raises EventSendText, FormMain.Script_EventSendText (Forms/FormMain.cs L6503) calls Command.ParseCommand(Text, bSendText, false, Script), and the plain-text branch there runs oGlobals.ParseGlobalVars(sRow) before SendTextToGame (Core/Command.cs L2566-2567). The queued send branch of Script_EventSendText calls ParseGlobalVars(Text) as well.

So Genie 4 expands $variables in every line a script sends to the game, after the script's own substitution, and Genie 5 does not. I think that is why '$shard.pw is sent unchanged.

A possible fix is to run ExpandGlobalVars over each segment in the script put / send path that goes to the game (queued sends and action sends included), after the ; split, as Genie 4 does. Expanding the moves in the mapper hand-off would fix the map exits but not other scripts.

Workaround: type the exit's commands in the command bar yourself. For this door:

knock door;'$shard.pw;go door

Typed input does get its $variables expanded, so the variable works there. automapper.cmd carries on with the rest of the walk once you are through.

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.