Aggregate reference expected

DaMaster0

Member
I keep getting this error!

Code:
> call scripts/tiny plastic/tiny_plastic_series1 v2.ash

Aggregate reference expected (tiny_plastic_series1 v2.ash, line 64)

line 64:

Code:
totalprice = totalprice + mall_price(need_it[j]);

Does anyone know what the problem is? I can't figure out what it means and my random attempts to fix it have all failed.
 
here's your problem (on line 63)

Code:
foreach i in need_it[j]
The problem is that need it is a map of items, but need_it[j] is a single item. So you're trying to iterate over an item. And it's saying that it expects a map and not an item

you can remove the file now, if you don't want it out yet ;)
 

DaMaster0

Member
Still doesn't work. I took the j out of it (is that what i'm supposed to do?) so it's now:

Code:
foreach i in need_it[]
And I get this new error:

Index for 'need_it' expected (tiny_Plastic_series1 v2.ash, line 63)

What am i supposed to do?
 

Grotfang

Developer
As an example, this is my current script for preparing to take down Mother Slime for an eyeball:

Code:
[B]effect [int] item_effect;[/B]
item_effect [0] = $effect[Slippery Oiliness];
item_effect [1] = $effect[Pronounced Potency];
item_effect [2] = $effect[Engorged Weapon];
item_effect [3] = $effect[Deadly Flashing Blade];
item_effect [4] = $effect[Chalky Hand];
item_effect [5] = $effect[Gr8tness];
item_effect [6] = $effect[Phorcefullness];
item_effect [7] = $effect[Puissant Pressure];
item_effect [8] = $effect[Tomato Power];
item_effect [9] = $effect[Incredibly Hulking];
item_effect [10] = $effect[Flamingly Floral];
item_effect [11] = $effect[Chauve-Souris Merde Fou];
item_effect [12] = $effect[Bloody Bloody Bloody!];
item_effect [13] = $effect[Permafrosty];
item_effect [14] = $effect[Cuts Like a Buttered Knife];


item [int] item_to_use;
item_to_use [0] = $item[oil of slipperiness];
item_to_use [1] = $item[potion of potency];
item_to_use [2] = $item[meleegra pills];
item_to_use [3] = $item[adder bladder];
item_to_use [4] = $item[handful of hand chalk];
item_to_use [5] = $item[potion of temporary gr8tness];
item_to_use [6] = $item[philter of phorce];
item_to_use [7] = $item[pressurized potion of puissance];
item_to_use [8] = $item[tomato juice of powerful power];
item_to_use [9] = $item[ferrigno's elixir of power];
item_to_use [10] = $item[fire flower];
item_to_use [11] = $item[eau de guaneau];
item_to_use [12] = $item[fake blood];
item_to_use [13] = $item[freezerburned ice cube];
item_to_use [14] = $item[bag of lard];


void main()
{
	outfit( "eyeball" );
	cli_execute( "unequip weapon" );

	if(current_mcd( )!=0)
	{
		change_mcd(0);
	}

	if( have_effect( $effect[Ur-Kel's Aria of Annoyance] ) > 0 )
	{
		cli_execute("uneffect Ur-Kel's Aria of Annoyance");
	}

	use_familiar( $familiar[baby gravy fairy] );
	if( familiar_equipped_equipment( $familiar[baby gravy fairy] ) != $item[eye-pod] )
	{
		equip( $item[eye-pod] );
	}

	[B]foreach i in item_effect[/B]
	{
		print( "Checking for " + item_effect[i] + " ..." , "green" );
		if( have_effect( item_effect[i] ) == 0 )
		{
			print( "You do not have " + item_effect[i] + "." , "red" );
			print( "Checking if you have " + item_to_use[i] , "green" );
			if( item_amount( item_to_use[i] ) == 0 )
			{
				print( "You do not have " + item_to_use[i] , "red" );
				buy( 1 , item_to_use[i] );
			}
			else
			{
				print( "You have " + item_to_use[i] , "blue" );
			}
			use( 1 , item_to_use[i] );
		}
		else
		{
			print( "You have the effect " + item_effect[i] , "blue" );
		}
	}

	cli_execute( "restore HP" );

	print( "Expected Damage: " + numeric_modifier( "Weapon Damage" ) );
	print( "Hot Damage: " + numeric_modifier( "Hot Damage" ) );
	print( "Cold Damage: " + numeric_modifier( "Cold Damage" ) );
	print( "Sleaze Damage: " + numeric_modifier( "Sleaze Damage" ) );
	print( "Spooky Damage: " + numeric_modifier( "Spooky Damage" ) );
	print( "Stench Damage: " + numeric_modifier( "Stench Damage" ) );

	print( "Finished preparing for Mother Slime. Time to kick some ass!" , "blue" );
}

I have put in bold the parts relevant to your query. Although Bale and the_great_cow_guru have said exactly the same thing...
 
tried that, but for some reason it just goes back to the aggregate reference expected line.

really? that's surprising... are you sure the error is still coming from that line and not another place where you did something similar? if you post the script again i'll take a look
 

Spiny

Member
I downloaded a copy of the file you had posted before and I've been pondering over it. In purchase_phase, you have int[item]need_it and in main you have item[int]need_it. Why you'd define it one way and pass it as a parameter another way, I'm not certain. I'm also not sure that you need j=0. Assuming that is superfluous and you're actually trying to loop thru an array of items defined by item name, which I think you are, then the below may be what you're trying to achieve for that particular blip. I've tested nothing, but I'm sure you can use Grotfang's example above as a basis to help you out.

Code:
	foreach i in need_it
		totalprice = totalprice + mall_price(i);

-Spiny
 

DaMaster0

Member
I downloaded a copy of the file you had posted before and I've been pondering over it. In purchase_phase, you have int[item]need_it and in main you have item[int]need_it.

Ya, I know, that caused me problems later on.

I never could fix it, so I ended up just switching to a while loop with the var i that increases by 1 each time it goes through.
 
Top