[ASK] Macro push item to array

All about the macro plugin can be found in this forum. This forum is intended for the macro plugin only.

Moderator: Moderators

Message
Author
romanz
Noob
Noob
Posts: 5
Joined: 23 May 2013, 11:01
Noob?: Yes

[ASK] Macro push item to array

#1 Post by romanz »

Hello everyone, i want to ask what's wrong with my code
This is my automacro for push the Item to array

Code: Select all

automacro pushItem {
	console /^Item added to inventory: (.*) \((\d+)\) x (\d+)/i
	call {
		$itemID = @inventory($.lastMatch1)
		$arrItem = @eval (return $::char->inventory->size());
		while ($itemID != $arrItem) as loop
			$arrItem--
		end loop
		do eval my $_item = $arrItem; Settings::add($_item);	
	}
}

This code for view or get Item from array that I added it to Settings.pm

Code: Select all

our @itemArray;
our $_item;
sub add {
	$_item = @_;
	push (@itemArray, $_item);
}

sub retrieve {
	pop @itemArray;
}
Anyone can solve my problem and how to get itemID from sub retrieve ?

Thanks :)
Last edited by romanz on 03 Dec 2014, 05:51, edited 2 times in total.

c4c1n6kr3m1
The Way Of Human
The Way Of Human
Posts: 150
Joined: 24 Mar 2012, 04:13
Noob?: Yes

Re: [ASK] Macro push item to array

#2 Post by c4c1n6kr3m1 »

what is $x

romanz
Noob
Noob
Posts: 5
Joined: 23 May 2013, 11:01
Noob?: Yes

Re: [ASK] Macro push item to array

#3 Post by romanz »

c4c1n6kr3m1 wrote:what is $x
oops sorry, that's not $x but $arrItem

thanks for your correction but still failed, i'm noob of perl programming :D

User avatar
SkylorD
Moderators
Moderators
Posts: 1166
Joined: 16 Dec 2011, 02:53
Noob?: No
Location: Brazil
Contact:

Re: [ASK] Macro push item to array

#4 Post by SkylorD »

@inventory (<item>)
Returns inventory item index of <item>. If <item> doesn't exist, it returns -1.

?

$itemindex = @inventory($.lastMatch1)
Learn rules

c4c1n6kr3m1
The Way Of Human
The Way Of Human
Posts: 150
Joined: 24 Mar 2012, 04:13
Noob?: Yes

Re: [ASK] Macro push item to array

#5 Post by c4c1n6kr3m1 »

i don't understand what are u trying to do
but

Code: Select all

 do eval my $_item = $arrItem; Settings::add($_item); 
should be some thing like this

Code: Select all

do eval my $_item = $::Macro::Data::varStack{arrItem}; Settings::add($_item); 
while using eval , use $:: not $
and every macro variable ,actually, is not a variable
but store inside hash %varStack

romanz
Noob
Noob
Posts: 5
Joined: 23 May 2013, 11:01
Noob?: Yes

Re: [ASK] Macro push item to array

#6 Post by romanz »

ok thanks c4c1n6kr3m1 it works, though still return total index of my array

this macro maybe useful for me when my bot get an item in inventory and all of that items i get before transferred to my other char.

Once again, thanks

c4c1n6kr3m1
The Way Of Human
The Way Of Human
Posts: 150
Joined: 24 Mar 2012, 04:13
Noob?: Yes

Re: [ASK] Macro push item to array

#7 Post by c4c1n6kr3m1 »

are you trying to store items name ? or what ?
what is this for ?

Code: Select all

$arrItem = @eval (return $::char->inventory->size());

Post Reply