Ulysses

Ulysses Stuff => General Chat & Help and Support => Topic started by: BlueNova on September 01, 2016, 06:19:24 PM

Title: Reverse a Command
Post by: BlueNova on September 01, 2016, 06:19:24 PM
Hi, I've got a question. How do you, if at all possible, reverse a function or command? Such as have an action that reverses a command. I've tried using setOpposite and unless I'm doing it wrong it does nothing.

I've searched the forums and haven't found anything on this.

Thanks.
Title: Re: Reverse a Command
Post by: Bytewave on September 01, 2016, 06:40:20 PM
Take a look at an example in the ULX codebase: ulx gimp (https://github.com/TeamUlysses/ulx/blob/0db8007ceb4a49e22c2bb191d1e16d423851f21e/lua/ulx/modules/sh/chat.lua#L163)
This should give you the basic syntax for setting a command's opposite. Basically, you need a hidden Boolean argument, and you need to check if you need to reverse the logic in your command's function.

edit: It would be nice, though, if you provided us a sample of your code and explained your use case better (see below).
Title: Re: Reverse a Command
Post by: Undercover Orange on September 01, 2016, 07:52:08 PM
Take a look at an example in the ULX codebase: ulx gimp (https://github.com/TeamUlysses/ulx/blob/0db8007ceb4a49e22c2bb191d1e16d423851f21e/lua/ulx/modules/sh/chat.lua#L163)
This should give you the basic syntax for setting a command's opposite. Basically, you need a hidden Boolean argument, and you need to check if you need to reverse the logic in your command's function.

I wonder if he means like a "ULX Undo" where it undoes the last ULX command executed. if so that would be cool if someone could get running smoothly.
Title: Re: Reverse a Command
Post by: iViscosity on September 01, 2016, 09:11:01 PM
I wonder if he means like a "ULX Undo" where it undoes the last ULX command executed. if so that would be cool if someone could get running smoothly.
I've tried using setOpposite and unless I'm doing it wrong it does nothing.