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
  #3  
Old 08-05-2010, 10:22 AM
Tabasco's Avatar
Tabasco
Discordant
 
Join Date: Sep 2009
Posts: 269
Default

References in perl get kind of tricky, and when you ask for a nested list object, you're getting a reference.

Try something like this:
(My examples are just command line demos so I can test outside of emu)
Code:
#!/usr/bin/perl

my @CategoryNames = (Armor, Augments, Weapons, Offslots, Misc);

%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],
);

my %LevelList = (
        65 => "delta",
        50 => "gamma",
        30 => "beta",
         0 => "alpha",
    );
#my $ItemType = $CategoryNames [rand @CategoryNames];
my $ItemType = $CategoryNames [2];
my $LevelCategory = "delta";

my $ItemHash = \%$ItemType;
my $Item = ${$ItemHash}{$LevelCategory} [rand @{ ${$ItemHash}{$LevelCategory} }];

print "$Item\n";
Or you could do this:

Code:
#!/usr/bin/perl

my @CategoryNames = (Armor, Augments, Weapons, Offslots, Misc);

my %Categories = (
    "Armor" => {
        "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],
    },
    "Augments" => {
        "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],
    },
    "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],
    },
    "Offslots" => {
        "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],
    },
    "Misc" => {
        "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],
    }
);

my %LevelList = (
        65 => "delta",
        50 => "gamma",
        30 => "beta",
         0 => "alpha",
    );

my $LevelCategory = "delta";

my $ItemPool = $Categories{$CategoryNames[rand @CategoryNames]}{$LevelCategory};
my $Item = ${$ItemPool} [rand @{$ItemPool}];
print "$Item\n";
Note ${$reference} or @{$reference} syntax.
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 08:01 PM.


 

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