Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-05-2010, 07:03 AM
nenelan
Hill Giant
 
Join Date: Feb 2008
Posts: 116
Default Accessing an Array stored in a Hash, having difficulties

I am having a beast of a time with this. Hopefully someone can help me.

I have an array of strings:
Code:
my @CategoryNames = (Armor, Augments, Weapons, Offslots, Misc);
I also have a Hash for each one of those Categories, along the following lines
Code:
	my %Weapons = 
	(
		alpha =>   [50524,50525,50526,50527,50527,50529,50530,50531,50532,50533,50534,50535],
		beta =>    [50524,50525,50526,50527,50527,50529,50530,50531,50532,50533,50534,50535],
		gamma =>   [50524,50525,50526,50527,50527,50529,50530,50531,50532,50533,50534,50535],
		delta =>   [50524,50525,50526,50527,50527,50529,50530,50531,50532,50533,50534,50535],
	)
(All values the same right now for testing purposes)

And finally I have a Hash for Levels:
Code:
	my %LevelList =
	(
		65 => delta,
		50 => gamma,
		30 => beta,
		 0 => alpha,
	);
I am trying to make a way to grab the player's level through LevelList, grab a random name from CategoryNames, and then grab a random item through $CategoryName{$LevelCategory}, with $LevelCategory being of alpha, beta, gamma, or delta.

I am able to grab a random element out of CategoryNames fine using:
Code:
$ItemType = $CategoryNames [rand @CategoryNames];
I am able to reference the player's level to get what Level they would fall under in LevelList fine.
Code:
	foreach $item (reverse sort keys %LevelList) {

		if ($MLevel >= $item) {
			$LevelCategory = $LevelList{$item};

		}

	}
(I know, there are easier, more efficient ways to do it, but I'm not worried on that just yet)

I am able to pull a single item out of any one of the arrays stored into Weapons fine using:
Code:
	$Weapons{$LevelCategory}[0];
However, I can not for the life of me use anything in any way similar to:
Code:
	my $Item = $ItemType{$LevelCategory} [rand @ItemType{$LevelCategory}];
I have a feeling it is something stupid and simple that I am missing, but, I can't for the life of me figure it out. I've tried various things and I'm ready to tear my hair out.

Thank you for the help, and please excuse my shoddy Perl coding, still new at this!
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 07:23 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3