Hey guys, love your bot! use it on multiple accounts lol.
I'm just curious.. Is it possible to use a wildcard within the "pickupitems" control text document in the control folder to loot all of a certain type of item?
example: * Card 2
would loot all cards that drop without hesitation.
wildcard on looting control?
Moderator: Moderators
-
- Noob
- Posts: 7
- Joined: 01 Nov 2013, 17:47
- Noob?: No
Re: wildcard on looting control?
No, the current check does a literal compare.
But, if you change the file src/Misc.pm:
it will support regular expressions, e.g.
But, if you change the file src/Misc.pm:
Code: Select all
sub items_control {
my $name = lc shift;
return $items_control{$name} if exists $items_control{$name};
my $result = $items_control{all} || {};
foreach my $key (keys %$items_control) {
next unless $key =~ m!^/(.*)/$!;
my $regex = $1;
if ($name =~ /$regex/) {
$result = $items_control{$key};
}
}
return $items_control{$name} = $result;
}
Code: Select all
/.* Card/ 2
-
- Noob
- Posts: 4
- Joined: 09 Nov 2013, 03:44
- Noob?: Yes
Re: wildcard on looting control?
Awesome! so if i modify it to look like that, it will work? why the /./?
-
- Noob
- Posts: 4
- Joined: 09 Nov 2013, 03:44
- Noob?: Yes
Re: wildcard on looting control?
So.. I tried your method (both for items_control and for pickupitems. Pickupitems is the one that I wanted to change)
Then I get this error when trying to start it.
What's going on??

(edit) here is what the codes look like
Pickupitems
Items_control
Then I get this error when trying to start it.
What's going on??

(edit) here is what the codes look like
Pickupitems
Code: Select all
sub pickupitems {
my $name = lc shift;
return $pickupitems{$name} if exists $pickupitems{$name};
my $result = $pickupitems{all} || {};
foreach my $key (keys %$pickupitems) {
next unless $key =~ m!^/(.*)/$!;
my $regex = $1;
if ($name =~ /$regex/) {
$result = $pickupitems{$key};
}
}
return $pickupitems{$name} = $result;
}
Code: Select all
sub items_control {
my $name = lc shift;
return $items_control{$name} if exists $items_control{$name};
my $result = $items_control{all} || {};
foreach my $key (keys %$items_control) {
next unless $key =~ m!^/(.*)/$!;
my $regex = $1;
if ($name =~ /$regex/) {
$result = $items_control{$key};
}
}
-
- Noob
- Posts: 7
- Joined: 01 Nov 2013, 17:47
- Noob?: No
Re: wildcard on looting control?
Oops, I was tricked by changing code that was done by someone who uses a different style than me. (Technical: Perl has Hashes and References of Hashes. As you can always use a reference instead of a hash, but not the other way around, I only use references. Openkore uses hashes here, but I used the syntax for hash references...)
The line
foreach my $key (keys %$items_control) {
must be
foreach my $key (keys %items_control) {
Also, check your {} pairs, you seem to be short a } or two.
Edit:
Oops, forgot to explain the regexes:
There are plenty of tutorials on regular expression on the net, so here just the bare basics:
'/' are just the default delimiters used for regular expressions. My code uses them to decide if a entry in items_control is a regex or just plain text.
'.' means "any character", just like the "?" would be in command line wildcards.
'*' means "0 or more of the thing before". So "a*" would match "", "a", "aa", "aaa", "aaaa", and so on. In combination with "." this gives us a match on "anything, even nothing".
'+' means "1 or more of the thing before". So "a+" would match "a", "aa", "aaa", "aaaa", and so on. In combination with "." this gives us a match on "anything, but at least something".
'^' means "beginning of string". So "^Card" would match "Card Monster" but not "Monster Card".
'$' means "end of string". So "Card$" would match "Monster Card" but not "Card Monster".
Note: My code does NOT automatically anchor the regex from the config file with ^$. So actually "/card/" would be enough, as it matches "Card Monster", "Monster Card" and even "Ricardo". Use "/^.* Card$/" if you want to be thorough to the extreme
The line
foreach my $key (keys %$items_control) {
must be
foreach my $key (keys %items_control) {
Also, check your {} pairs, you seem to be short a } or two.
Edit:
Oops, forgot to explain the regexes:
There are plenty of tutorials on regular expression on the net, so here just the bare basics:
'/' are just the default delimiters used for regular expressions. My code uses them to decide if a entry in items_control is a regex or just plain text.
'.' means "any character", just like the "?" would be in command line wildcards.
'*' means "0 or more of the thing before". So "a*" would match "", "a", "aa", "aaa", "aaaa", and so on. In combination with "." this gives us a match on "anything, even nothing".
'+' means "1 or more of the thing before". So "a+" would match "a", "aa", "aaa", "aaaa", and so on. In combination with "." this gives us a match on "anything, but at least something".
'^' means "beginning of string". So "^Card" would match "Card Monster" but not "Monster Card".
'$' means "end of string". So "Card$" would match "Monster Card" but not "Card Monster".
Note: My code does NOT automatically anchor the regex from the config file with ^$. So actually "/card/" would be enough, as it matches "Card Monster", "Monster Card" and even "Ricardo". Use "/^.* Card$/" if you want to be thorough to the extreme

-
- Noob
- Posts: 7
- Joined: 01 Nov 2013, 17:47
- Noob?: No
Re: wildcard on looting control?
BTW: Good work on adapting the code for pickupitems. Just one correction:
pickupitems uses a different check to see if there is an entry for an item. I don't know if it actually makes a difference, but better safe than sorry. Maybe even
Otherwise we could compare a non-existing value with a string. Not an error, but Perl would spit out a warning. Although the current code does not spit out warning, so this may not be needed...
Code: Select all
return $pickupitems{$name} if $pickupitems{$name} ne '';
Code: Select all
return $pickupitems{$name} if exists $pickupitems{$name} and $pickupitems{$name} ne '';
-
- Noob
- Posts: 4
- Joined: 09 Nov 2013, 03:44
- Noob?: Yes
Re: wildcard on looting control?
this makes a HUGE amount of sense!
thanks for your help man!
I will test this out to see if it works and will give results
Also FYI not sure if it matters or not, but I'm using start.exe. Not the PERL one.
thanks for your help man!
I will test this out to see if it works and will give results

Also FYI not sure if it matters or not, but I'm using start.exe. Not the PERL one.