Add on and this Toolshed Commands#1049
Open
ishkab wants to merge 2 commits into
Open
Conversation
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.
About the PR
This PR adds two Toolshed commands (8 total subcommands) for filtering entities based on map or grid predicates. All six subcommands of
onare invertible with the usualnotconstruction. These are mainly convenience functions for administration.on:grid <gridid>filters an IEnumerable to only those entities that are on the grid with the ID given.on:thisgridfilters an IEnumerable to only those entities that are on the same grid as the invoker.on:gridof <ent>filters an IEnumerable to only those entities that are on the same grid as the entity given.on:map <mapid>filters an IEnumerable to only those entities that are on the map with the ID given.on:thismapfilters an IEnumerable to only those entities that are on the same map as the invoker.on:mapof <ent>filters an IEnumerable to only those entities that are on the same map as the entity given.this:gridreturns the grid that the invoker is on.this:mapreturns the ID of the map that the invoker is on.Why / Balance
on:thisgrid, one can easily target only entities on-station, for instance.oncommand useful for removing stray grids created in error during the mapping process, as inentities on:thismap with MapGrid not with BecomesStation delete.Technical details
I originally implemented this way out of code style with the rest of the repo. I think the code is less readable now, but it conforms.
I added OnCommand and ThisCommand along with three Toolshed errors. The commands require DEBUG permission.
Requirements
Breaking changes
I tested this very briefly and found it to be in enough of a working order to PR. If bugs are discovered, they should be strictly contained to the execution of the commands - a situation which makes for easy avoidance until a patch can be issued.