Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the purpose of PostCommandCalled #87

Merged

Conversation

brandonsturgeon
Copy link
Contributor

@brandonsturgeon brandonsturgeon commented Sep 1, 2022

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

  • ❌ Removes the ULibPostCommandCalled hook
  • ✅ Adds a fourth parameter to the ULibPostCommandTranslated hook (the callResult 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.

@zpetty33 zpetty33 merged commit fe5aedc into TeamUlysses:Experimental Sep 14, 2022
@brandonsturgeon brandonsturgeon deleted the fix/simplify-postcommandcalled branch September 19, 2022 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants