Thread: Array Problems
View Single Post
  #1  
Old 02-06-2013, 12:24 AM
Randymarsh9
Dragon
 
Join Date: Dec 2007
Posts: 658
Default Array Problems

I am hoping to be able to do some sort of system where I can have an array of quest rewards for each class. This is a very simple example of what I am trying to do.

Code:
sub EVENT_SAY
{
	@Shadowknight = (1001,1002,1003);
	@itemArray = "@$class";
	my $summon = quest::saylink("summon");
	if ($text =~/hail/i)
	{
		quest::say("Do you want me to $summon you something?");
	}
	elsif ($text =~/summon/i)
	{
		quest::say("$class");
		quest::say("@itemArray");
		quest::summonitem($itemArray[1]);
	}
}
Ideally, if someone completes the quest, I could just have it choose their reward from their class's array. The problem I have already seen though, is that getting any array element other than the one at the 0 location returns a 0. So in the script I copied above, it will correctly state the character's class, then (since I am a Shadowknight) it will list all of the elements in the shadowknight array. The problem comes with retrieving individual elements. When I do summonitem($itemArray[0]), it summons an item; however, if I do quest::summonitem($itemArray[1]), it says there is no item with ID = 0. Does anyone know why perl is only recognizing the first element of the array?
Reply With Quote