Plugin help

All resolved question will be found here. It is recommended that you browse / search through this section first and see if your question has been answered before

Moderators: Moderators, Documentation Writers

Message
Author
setsunaseiei
Human
Human
Posts: 38
Joined: 17 May 2011, 07:09
Noob?: No

Plugin help

#1 Post by setsunaseiei »

I am having error with this plugin I made. I have read the wiki and some src files of Kore.
Loading the plugin, kore goes...

Code: Select all

Loading all plugins...
Loading plugin plugins/cartsell.pl...
This plugin cannot be loaded because of a problem in the plugin. Please notify
the plugin's author about this problem, or remove the plugin so OpenKore can
start.

The error message is:

Press ENTER to exit this program.
A blank error message, after removing common errors, left me clueless.
Here's my source code:

Code: Select all

package CartSell;

use strict;
use Globals;
use Log qw(message error);
use Utils;
use Network::Send;
use Misc;
use AI;
use AI::Corelogic;
use Translation;

Plugins::register('autocartsell', 'Sell items from cart', \&unload);
#my $hooks = Plugins::addHooks(['AI_pre', \&AI_hook]);
my $commandsID = Commands::register(["autocartsell", "Sell items from cart", \&cmdCartSell]);

my $cartSearch;

sub unload {
	#Plugins::delHooks($hooks);
	Commands::unregister($commandsID);
}

sub cmdCartSell {
	my @getItems;
	my @sellItems;
	my $args = AI::args;
	
		$args->{cartNextItem} = 0 unless $args->{cartNextItem};
		for (my $i = $args->{cartNextItem}; $i < @{$cart{inventory}}; $i++) {
			my $item = $cart{inventory}[$i];
			next unless ($item && %{$item});
			my $control = items_control($item->{name});
			if ($control->{'sell'} && $item->{'amount'} > $control->{keep}) {
			
				if ($args->{cartLastIndex} == $item->{index} &&
				    timeOut($timeout{'ai_sellAuto_giveup'})) {
					return;
				} elsif ($args->{cartLastIndex} != $item->{index}) {
					$timeout{ai_sellAuto_giveup}{time} = time;
				}
				
			undef $args->{done};
			$args->{cartLastIndex} = $item->{index};
			my %cartObj;
			$cartObj{index} = $i;
			my $amount = $item->{amount} - $control->{keep};
			$cartObj{amount} = $amount;
			push @getItems, \%cartObj;
			cartGet(\@getItems);
			$timeout{ai_sellAuto}{time} = time;
			$args->{cartNextItem} = $i + 1;
			
				if ($char->{weight} > 89) {
					processAutoSell();
					$i = $i - 1;
				}
			}
		}
}

	
Did I use any unnecessary packages?
Idea is that Kore should get items from cart until he goes overweight 90%, then Kore would do go autosell.
What's wrong with it or is it wrong as a whole. I removed $hooks though.
オペンコレ!

EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: Plugin help

#2 Post by EternalHarvest »

Can't locate AI/Corelogic.pm in @INC
It's CoreLogic, and you don't need to include it.

Locked