Thers 3 bluks of code / 2 files of .pm should be change:
In src/InventoryList.pm, should add a "sumByName" sub at the bottom of src/InventoryList.pm.
Code: Select all
// total amount of the same name items
sub sumByName {
my ($self, $name) = @_;
assert(defined $name) if DEBUG;
my $sum = 0;
foreach my $item (@{$self->getItems()}) {
if ($item->{name} eq $name) {
$sum = $sum + $item->{amount};
}
}
return $sum;
}
1. check the "minAmount" of "getAuto" of inventory item for auto-storaging.
Original Code
Code: Select all
.....
my $item = $char->inventory->getByName($config{"getAuto_$i"});
if ($config{"getAuto_${i}_minAmount"} ne "" &&
$config{"getAuto_${i}_maxAmount"} ne "" &&
!$config{"getAuto_${i}_passive"} &&
(!$item ||
($item->{amount} <= $config{"getAuto_${i}_minAmount"} &&
$item->{amount} < $config{"getAuto_${i}_maxAmount"})
)
) {
.....
Code: Select all
.....
my $item = $char->inventory->getByName($config{"getAuto_$i"});
my $amount = $char->inventory->sumByName($config{"getAuto_$i"}); // total amount of the same name items
if ($config{"getAuto_${i}_minAmount"} ne "" &&
$config{"getAuto_${i}_maxAmount"} ne "" &&
!$config{"getAuto_${i}_passive"} &&
(!$item ||
($amount <= $config{"getAuto_${i}_minAmount"} &&
$amount < $config{"getAuto_${i}_maxAmount"})
)
) {
.....
Original Code
Code: Select all
.....
my $invItem = $char->inventory->getByName($itemName);
$item{name} = $itemName;
$item{inventory}{index} = $invItem ? $invItem->{invIndex} : undef;
$item{inventory}{amount} = $invItem ? $invItem->{amount} : 0;
.....
Code: Select all
.....
my $invItem = $char->inventory->getByName($itemName);
my $amount = $char->inventory->sumByName($itemName); // total amount of the same name items
$item{name} = $itemName;
$item{inventory}{index} = $invItem ? $invItem->{invIndex} : undef;
$item{inventory}{amount} = $invItem ? $amount : 0;
.....