Replace all C++ sector numbering with Lua API in scripts/api#2872
Open
oznogon wants to merge 1 commit into
Open
Replace all C++ sector numbering with Lua API in scripts/api#2872oznogon wants to merge 1 commit into
oznogon wants to merge 1 commit into
Conversation
Move sector naming from C++ to the Lua scripting API, allowing scenarios to customize the functions. Move the global functions getSectorName(x,y) and sectorToXY(name) to a `Sector.` pseudonamespace to retain entity functions with the same names, and add global wrappers at the old function names for backward scenario compatibility. All radars should now show sector names as defined in the Lua API. This allows each scenario to define custom sector naming behaviors by overriding Sector.getSectorName() and Sector.sectorToXY(). This also allows redefining the default behavior by overriding or replacing the API functions. Tested against the Edge-of-Space scenario, which had already switched from hardcoded sector names in comms scripts to global functions, and set overriding sector naming functions in the scenario. The scenario seamlessly used the overrides.
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.
Move sector naming from C++ to the Lua scripting API, allowing scenarios to customize the functions. Move the global functions getSectorName(x,y) and sectorToXY(name) to a
Sector.pseudonamespace to retain entity functions with the same names, and add global wrappers at the old function names for backward scenario compatibility.All radars should now show sector names as defined in the Lua API. This allows each scenario to define custom sector naming behaviors by overriding Sector.getSectorName() and Sector.sectorToXY(). This also allows redefining the default behavior by overriding or replacing the API functions.
This should not change any default behaviors. The Lua API implementation attempts to reproduce EE's existing C++ implementation, quirks and all.
Override example
Tested against the Edge-of-Space scenario, which had already switched from hardcoded sector names in comms scripts to global functions, and set overriding sector naming functions in the scenario. The scenario seamlessly used the overrides.
At origin coords 0,0:
Scenario code:
Comms reporting sector names in stock scenario_06_edgeofspace.lua, with the only change being to add the above custom sector naming functions to the scenario: