View Single Post
12/22/15, 06:37 PM   #24
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by SnowmanDK View Post
For now I have ended up with this (a kind of a mix):
Lua Code:
  1. --
  2.             if     string.find(icon, "centipede") then  --Crawlers
  3.                 ...
Just a little tip to make that part more concise with just two string matches (using a table for counts instead of individual local vars):
Lua Code:
  1. -- at file scope
  2. local bait_to_water = {
  3.   centipede="Foul", fish_roe="Foul",
  4.   torchbug="River", shad="River",
  5.   worms="Ocean", fish_tail="?",
  6.   guts="Lake", river_betty="Lake"
  7. }
  8.  
  9. -- in func
  10.   local counts = {}
  11.  
  12. -- in loop
  13.   local k = icon:match("centipede|fish_roe|torchbug|shad|worms|fish_tail|guts|river_betty")
  14.   local water = bait_to_water[k]
  15.   if water == "?" then
  16.     if name:find("simple|einfacher|appāt") then --Simle Bait
  17.         water = "General"
  18.     else    --Chub
  19.         water = "Ocean"
  20.     end
  21.   end
  22.   if water then
  23.     counts[water] = (counts[water] or 0) + stack
  24.   end
  Reply With Quote