daemitus / SomethingNeedDoing

88 stars 64 forks source link

Conditional logic #38

Closed BeetleLord closed 2 years ago

BeetleLord commented 2 years ago

I would love to see the addition of some basic form of conditional logic. I often start my macros with something like:

/waitaddon RecipeNote /click Synthesize /waitaddon Synthesis

However, there is no flawless way to do this currently. If I am already on the Synthesis menu, I will have to edit the macro to allow it to move forward. If I move the first two lines to the end of the macro, then it will begin synthesizing again even on the last loop. The ability to perform just a bit of conditional logic would solve the problem. As far as the proposed syntax goes, it would probably be best to keep it very simple. Something like...

/if param1 param2 /ifnot param1 param2 (Or not could be a parameter)

And each if would terminate with an /endif statement, which means nesting would be possible. If a macro ends with any unterminated if statements, they will be assumed to be appended to the end of the macro.

Practical example:

/ifnot addon Synthesis /waitaddon RecipeNote /click Synthesize /waitaddon Synthesis /endif

In this example, it would skip the inner 3 lines if the Synthesis menu is already active. Other if parameters could be added over time. Or perhaps you're able to come up with a more clever syntax altogether.

Alternatively, the ability to skip lines in the currently executing macro would at least allow me to bypass this issue.

Rukkulko commented 2 years ago

This would help immensily with keeping well fed and/or pots too.

daemitus commented 2 years ago

The way it currently works is relatively state-less. each step knows nothing about the previous one. Theres already some hacks in place to handle looping.

Conditional logic likely isn't going to happen in the current layout. I've got dreams of adding some sort of prebuilt scripting engine as an "advanced" macro type of thing. I want to do it, just havent found the time yet.

On Thu, May 5, 2022 at 1:14 PM Rukkulko @.***> wrote:

This would help immensily with keeping well fed and/or pots too.

— Reply to this email directly, view it on GitHub https://github.com/daemitus/SomethingNeedDoing/issues/38#issuecomment-1118849051, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFMTBFR2UN5PP5LWJR6ZWLVIP6WPANCNFSM5MMI2ERA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

BeetleLord commented 2 years ago

If I may make a recommendation, LUA is the perfect language for this sort of thing.

Rukkulko commented 2 years ago

Extending on the food part, I haven't really checked the code. So I'm not sure whats possible or not. But there is already a well fed check, as well as a condition check. Would it be possible to do /send KEY_0 (food) <condition.!wellfed>?

fhn101 commented 2 years ago

If I could add on to this suggestion, would it be possible to implement some sort of variable system (even if scoped to just the current macro)?

An example of how it could be implemented:

You could have a /setvariable <name> <value> command that can be inserted into the current loop.

Then, during your loop you can do /requirevariable <name> <value> in order to run certain actions.

daemitus commented 2 years ago

you can make lua scripts now (provided it doesnt break)