nenelan
08-05-2010, 07:03 AM
I am having a beast of a time with this. Hopefully someone can help me.
I have an array of strings:
my @CategoryNames = (Armor, Augments, Weapons, Offslots, Misc);
I also have a Hash for each one of those Categories, along the following lines
my %Weapons =
(
alpha => [50524,50525,50526,50527,50527,50529,50530,50531,50 532,50533,50534,50535],
beta => [50524,50525,50526,50527,50527,50529,50530,50531,50 532,50533,50534,50535],
gamma => [50524,50525,50526,50527,50527,50529,50530,50531,50 532,50533,50534,50535],
delta => [50524,50525,50526,50527,50527,50529,50530,50531,50 532,50533,50534,50535],
)
(All values the same right now for testing purposes)
And finally I have a Hash for Levels:
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:
$ItemType = $CategoryNames [rand @CategoryNames];
I am able to reference the player's level to get what Level they would fall under in LevelList fine.
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:
$Weapons{$LevelCategory}[0];
However, I can not for the life of me use anything in any way similar to:
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! :)
I have an array of strings:
my @CategoryNames = (Armor, Augments, Weapons, Offslots, Misc);
I also have a Hash for each one of those Categories, along the following lines
my %Weapons =
(
alpha => [50524,50525,50526,50527,50527,50529,50530,50531,50 532,50533,50534,50535],
beta => [50524,50525,50526,50527,50527,50529,50530,50531,50 532,50533,50534,50535],
gamma => [50524,50525,50526,50527,50527,50529,50530,50531,50 532,50533,50534,50535],
delta => [50524,50525,50526,50527,50527,50529,50530,50531,50 532,50533,50534,50535],
)
(All values the same right now for testing purposes)
And finally I have a Hash for Levels:
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:
$ItemType = $CategoryNames [rand @CategoryNames];
I am able to reference the player's level to get what Level they would fall under in LevelList fine.
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:
$Weapons{$LevelCategory}[0];
However, I can not for the life of me use anything in any way similar to:
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! :)