Refactor code dealing with squad index #177
Merged
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.
Create separation between how the game refers to squads by index, and how the mod loader refers to squads by index.
Note: This PR intentionally does nothing with the file
modUi/achievements_squad.lua
, but expects #174 to be updated to deal with it, using the constants and functions provided here.Squad Choice
For the game a squad
choice
is the index for the chosen squad.Squad Choice is:
Squad Index
For the mod loader a squad
index
is the index for the squad in mod loader tables.Squad Index is:
New functions
number modApi:squadIndex2Choice(number) - Returns the squad choice corresponding to the specified squad index. Returns -1 for indexes that cannot be mapped to a squad choice.
number modApi:squadChoice2Index(choice) - Returns the squad index corresponding to the specified squad choice. Returns -1 for choices that cannot be mapped to a squad index.
table modApi:getSquadForChoice(number) - Returns the list of a squad currently mapped to the specified squad choice.
Where content of the return table is as follows: