feat(scripting): expose Genie 4 reserved variables to scripts (#45)#50
Merged
Merged
Conversation
…lient#45) Fills gaps in the reserved-variable vocabulary that scripts read as $name, so community scripts ported from Genie 4 resolve them instead of aborting on an undefined $var. - Computed clock vars in ScriptEngine.TryResolveVar: $date, $time, $time24, $datetime, $datetime24, $militarytime, $dayofmonth, $dayofyear, $unixtime. Formats copied verbatim from Genie 4 (Lists/Globals.cs), including the $time24 "tt" quirk, for parity. Resolved as a final fallback so a user var of the same name can shadow. - $scriptlist: '|'-separated running script names, or "none" (G4 parity), computed on read from the live instance list. - Session statics seeded in ScriptGlobalsSync: $account, $client ("Genie Client 5"), $version (host version string). - $lastcommand: set on every line sent to the game (ICommandHost.SendToGame). Verified via a throwaway harness driving the real ScriptEngine: all 11 variables round-trip through the substitution path (clock vars, scriptlist showing the running script, lastcommand, and the statics). Follow-ups (dependency-heavy, left on the issue): $zoneid/$zonename and $roomnote (mapper state), $monstercount/$monsterlist (creature parsing), $gamehost/$gameport (resolved connection plumbing), spell-timer vars.
1 task
monil2233
added a commit
that referenced
this pull request
Jun 6, 2026
) Follow-up to #50. $gametime is the server's clock (Unix seconds) carried on each <prompt time='...'> tag — distinct from $unixtime (local wall clock). The parser already captures it as PromptEvent.ServerTime; this surfaces it to the script globals. Routes PromptEvent through a new OnPrompt handler that sets $gametime from ServerTime.ToUnixTimeSeconds(), guarded by > UnixEpoch so a prompt without a time attribute never publishes a bogus negative epoch. Seeded to "0" in SeedInitial for scripts that read it before the first prompt.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Summary
Fills gaps in the reserved-variable vocabulary that scripts read as $name, so community scripts ported from Genie 4 resolve them instead of aborting on an undefined $var.
Describe what this pull request changes.
Type of Change
Related Issue
Doesn't close, but addresses some of #45
Testing
Verified via a throwaway harness driving the real ScriptEngine: all 11 variables round-trip through the substitution path (clock vars, scriptlist showing the running script, lastcommand, and the statics).
Checklist
Follow-up
Follow-ups (dependency-heavy, left on the issue): $zoneid/$zonename and $roomnote (mapper state), $monstercount/$monsterlist (creature parsing), $gamehost/$gameport (resolved connection plumbing), spell-timer vars.