Skip to content

Conversation

@sarahsturgeon
Copy link
Contributor

@sarahsturgeon sarahsturgeon 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
@sarahsturgeon sarahsturgeon deleted the fix/simplify-postcommandcalled branch September 19, 2022 22:33
zpetty33 added a commit that referenced this pull request Aug 24, 2025
* Migrate UCL user store from flat file to SQLite. (#74)

* feat: add db creation and user saving

* fix: change protected term (group) to usergroup

* fix: sqlstr only escapes single quotes

* feat: load the users.

* chore: thonk?

* fix: when adding a user, only save once.

* feat: make userInfo opt

* feat: function to delete a stored user.

* feat: save for the remainder of operations

* fix: only try loading from the db if we've not just created it.

* fix: switch to json for an odd sqlite saving error

* feat: properly migrate.

* fix: we should be using the same noMount setting for both read and existance?

* fix(comment): Minor fix for the comment.

* fix: make that local, since we're not calling it for testing now.

* fix: remove the old file write, no longer required.

* feat: add function to delete all stored db users.

* feat: allow db data to be checked on load.

* Merge Master branch updates into Experimental Branch (#84)

* Update CHANGELOG.md

* Fix Weapon SetClipErrors (#76)

* fix: result isn't used in this context.

* fix: the docs say ply, we use ply.

* perf: we don't need to call that twice.

* fix: printname isn't a name, it's class. localise class.

* fix: fix weapon error if not given.

replace printname with class.
only call getweapon if we can't get it through give.

* fix: Make sure SetClip1 and SetClip2 actually exist before we call them.

* WTF (#63)

* Update CHANGELOG.md

* Update ulib.build

* Update addon.txt

* Update defines.lua

Co-authored-by: Joshua Piper <32164094+JoshPiper@users.noreply.github.com>
Co-authored-by: Deyvan <51455765+Deyvan@users.noreply.github.com>

* Add ULibPostCommandCalled (#80)

* Add hook for post command called

* Document the hide param

* Change tenses in defines

* Update versions

* Fix version numbers

* Simplify the purpose of PostCommandCalled (#87)

---------

Co-authored-by: Joshua Piper <32164094+JoshPiper@users.noreply.github.com>
Co-authored-by: Deyvan <51455765+Deyvan@users.noreply.github.com>
Co-authored-by: Brandon Sturgeon <brandon@brandonsturgeon.com>
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