ulib icon indicating copy to clipboard operation
ulib copied to clipboard

Simplify the purpose of PostCommandCalled

Open sarahsturgeon opened this issue 3 years ago • 0 comments

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.

sarahsturgeon avatar Sep 01 '22 01:09 sarahsturgeon