-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Event macro slot system #2781
base: master
Are you sure you want to change the base?
Event macro slot system #2781
Conversation
what is the difference between options "priority" and "slot"? |
@ya4ept Priority hasn`t changed at all. Slots separate macros and automacros into different "instances", as is all macros and automacros using slot 1 will be totally independent from those using slot 2 or 3 or etc. While a macro is running at slot 1, in slot 2 there can be a few automacros checking for conditions, and another macro running at the same time in slot 7 This makes it possible to run multiple macros at the same time and to also run automacro checking during macro runtime. |
automacro alpha {
BaseLevel > 0
exclusive 1
slot 1
call {
$i = 0
while ($i < 10) {
pause 2
$i++
log alpha automacro running on slot 1 for &eval(2*$i) seconds
}
}
}
automacro beta {
BaseLevel > 0
exclusive 1
slot 2
timeout 3
call {
log beta automacro running on slot 2
}
} |
great update! |
@@ -132,6 +132,9 @@ sub set_parameters { | |||
if (!defined $self->{parameters}{'repeat'}) { | |||
$self->{parameters}{'repeat'} = 1; | |||
} | |||
if (!defined $self->{parameters}{'slot'}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a 1-based counting system (ie, there's no slot zero), you could do:
$self->{parameters}{'slot'} ||= 1;
@@ -67,6 +67,12 @@ sub new { | |||
$self->repeat(1); | |||
} | |||
|
|||
if (defined $slot && $slot =~ /^\d+$/) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should slot 0
be allowed?
# Adds the current macro to the already existent eventMacro sequence in AI queue | ||
sub register_add { | ||
my ($self, $macro_args) = @_; | ||
debug "[eventMacro] Macro '".$self->{name}."' is now adding itself to the eventMacro sequente in AI queue.\n", "eventMacro", 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sequente
=> sequence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this message match the phrasing in register_new
? Same for unregister
and register_remove
.
plugins/eventMacro/eventMacro.pl
Outdated
"eventMacro check force_start: forces the start of automacros checking\n". | ||
"eventMacro check resume: return automacros checking to the normal state\n"; | ||
return; | ||
if (!defined $params[0] || (defined $params[0] && $params[0] ne 'force_stop' && $params[0] ne 'force_start' && $params[0] ne 'resume')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tabs vs spaces.
plugins/eventMacro/eventMacro.pl
Outdated
my $slot = $params[1]; | ||
|
||
if ($slot !~ /^\d+$/) { | ||
message "[eventMacro] '".$slot."' is not a valid option\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we allow people to target macros by the name of the running routine? So slot could be foo
if the running macro's name is foo
. Targeting by slots could be hard, since slots are allocated automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slots are not allocated automatically, they are defined in the automacro or in the plugin command.
bug report: sometimes eventMacro is not removing itself from AI queue, making bot simply doing anything. Despite that, all automacros triggers normally. The only solution i've found is to run |
Adding a way for eventMacro to run multiple macros at the same time has always been something I wanted but I never made. Today I decided to come up with a simple system to make it work, this is still very much a work is progress (as the many "TODO" messages may indicate).
There are some design decisions I have want/need help with.
How should we handle the AI queue while we have 1 or more macros running? What if one is overrideAI 1 and the others are not? What if they all are overrideAI 0 or 1?
How should the commands be changed to accompany these changes?
The code as it is now only supports multiple macros if they are all "overrideAI 1".
Example:
@edit:
Well, I guess the code is now working nicely, I fixed all the bugs I could find, fixed the command and the overrideAI problem.