Simplify the purpose of PostCommandCalled #87
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.
Context
In my original PR, I implemented a whole new hook (
ULibPostCommandCalled
) that was supposed to only be called if a command successfully ran.My original PR was bad - it simply didn't work correctly.
This PR aims to rectify that mistake with a simpler and more targeted approach.
Description
ULibPostCommandCalled
hookULibPostCommandTranslated
hook (thecallResult
of the command function)This PR adds a fourth parameter to the
ULibPostCommandTranslated
hook. This parameter is just the result of calling the base command function.This will allow command functions to, for example,
return false
if they failed for some reason. This was my primary focus - I wanted to know if a ULX command actually successfully performed the action. However, this also opens to door to any kind of pre -> post command interaction.Maybe some developers would like to return a table with additional information about what happened in the command.
It's a very flexible change, and the more creative uses of this change probably exceed the limits of my imagination at present :)
More Info
I've also created a Draft PR to the ULX project that demonstrates how this could be used.
With that ULX change, developers could check for the fourth parameter to
ULibPostTranslatedCommand
hook to see if the function actually ran successfully. This is the bare-minimum functionality this PR could provide.