View Single Post
  #1  
Old 06-14-2019, 10:46 AM
chrsschb's Avatar
chrsschb
Dragon
 
Join Date: Nov 2008
Location: GA
Posts: 905
Default Is it possible to filter on a hash/array?

I'm trying to see if instead of building multiple hashes for different types of turnins, if I can build a single large hash and filter results based on data in that hash. I'm not super savvy with these so kinda learning as I go, any help is appreciated.

Code:
%combine_1 = (
  1 => { "item1" => 1234, "item2" => 1111, "type" => 1,  "reward" => 11111 }, # Ring
  2 => { "item1" => 1234, "item2" => 2222, "type" => 4,  "reward" => 22222 }, # Veil
  3 => { "item1" => 1234, "item2" => 3333, "type" => 3,  "reward" => 33333 }, # Earring
  4 => { "item1" => 1234, "item2" => 4444, "type" => 1,  "reward" => 44444 }, # Ring
  5 => { "item1" => 1234, "item2" => 5555, "type" => 2,  "reward" => 55555 }, # Necklace
  );
For instance in this example I have 5 combines, I want to present these to the player and filter based on the type field. So if they respond to the NPC with [$type1] cause they want to see rings the npc should only respond with type 1 combines.

Dialogue I have right now:
Code:
    foreach $id (sort keys %combine_1) {
      my $item1_link = quest::varlink($turnin_1{$id}{"item1"});
      my $item2_link = quest::varlink($turnin_1{$id}{"item2"});
      my $reward_link = quest::varlink($turnin_1{$id}{"reward"});
      my $scost = $scomm . '' . pp;
      $client->Message($whisper_color, "$item1_link + $item2_link + $scost = $reward_link");
    }
Turnin:
Code:
  foreach $id (sort keys %combine_1) {
    $item1 = $turnin_1{$item_id}{"item1"};
    $item2 = $turnin_1{$item_id}{"item2"};
    $reward = $turnin_1{$item_id}{"reward"};

    if (plugin::takeItemsCoin(0, 0, 0, $scomm, $item1 => 1, $item2 => 1)) {
      quest::summonitem($reward);
      quest::ding;
    }
  }
I'm sure I'm missing something simple with this.
__________________
Clumsy's World: Resurgence
Clumsy's World [2006-2012]
Reply With Quote