<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MudletPackage>
<MudletPackage version="1.0">
    <ScriptPackage>
        <ScriptGroup isActive="yes" isFolder="yes">
            <name>Rift</name>
            <packageName></packageName>
            <script>-------------------------------------------------
--         Put your Lua functions here.        --
--                                             --
-- Note that you can also use external Scripts --
-------------------------------------------------
</script>
            <eventHandlerList/>
            <Script isActive="yes" isFolder="no">
                <name>rift</name>
                <packageName></packageName>
                <script>--[[ Original Script by Trevize Moonflair, adapted for Mudlet by Sohl Vallah

Rift Management version 2.0

IR - displays your rift normally, capturing information
RIFT - displays your rift from memory
RIFT &lt;group&gt; - same as RIFT for only one group
RIFT BELOW &lt;#&gt; - shows all items below the specified amount
RIFT &lt;group&gt; BELOW &lt;#&gt; - same as RIFT BELOW &lt;#&gt; for only one group
RIFT GROUPS - shows what groups display
RIFT &lt;group&gt; ON|OFF - enables or disables a group
RIFT HELP - shows all rift commands

RIFT TATTOOS - calculate how many tattoos you can ink
RIFT TATTOOS &lt;tattoo&gt; - set the furthest tattoo you can ink
RIFT RUNES - calculate how many runes you can sketch
RIFT RUNES &lt;rune&gt; - set the furthest rune you can sketch
RIFT MILL - calculate how many inks you can mill
RIFT MILL &lt;ink&gt; - set the furthest ink you can mill

Enjoy!

-Trevize
--]]

-- ============
--  foundation
-- ============

string.proper = function (x)
  return string.upper (string.sub(x, 1, 1)) .. string.lower (string.sub(x, 2))
end -- func

sortedpairs = function (tbl)
  local i = 0
  local tmp = {}
  for n in pairs (tbl) do table.insert (tmp, n) end
  table.sort (tmp)
  return function ()
    i = i + 1
    if tmp[i] ~= nil then return tmp[i], tbl[tmp[i]] end
  end -- func
end -- func

prompt_t = {}
prompt_t.data = false
prompt_t.draw = function ()
  if prompt_t.data then
    for k,v in ipairs (prompt_t.data) do
      ColourTell (RGBColourToName (v.textcolour),
                  RGBColourToName (v.backcolour),
                  v.text)
    end -- for
  end -- if
  echo (&quot;&quot;)
end -- func



-- ==============
--  Rift Drawing
-- ==============

rift = {
  furthest = {
    tattoo = &quot;chameleon&quot;,
    rune   = &quot;loshre&quot;,
    mill   = &quot;black&quot;,
    },

  cats = {&quot;herbs&quot;, &quot;concoct&quot;, &quot;inks&quot;, &quot;comms&quot;, &quot;crys&quot;, &quot;misc&quot;, &quot;reag&quot;, &quot;cook&quot;, &quot;tran&quot;,&quot;alch&quot;},
  long = {concoctables = &quot;concoct&quot;, commodities = &quot;comms&quot;, crystals = &quot;crys&quot;, miscellaneous = &quot;misc&quot;, reagents = &quot;reag&quot;, ingredients = &quot;cook&quot;, transmutations = &quot;tran&quot;, alchemicals = &quot;alch&quot;},
  short = {concoct = &quot;concoctables&quot;, comms = &quot;commodities&quot;, crys = &quot;crystals&quot;, misc = &quot;miscellaneous&quot;, reag = &quot;reagents&quot;, cook = &quot;ingredients&quot;, tran = &quot;transmutations&quot;, alch = &quot;alchemicals&quot;},

  table = {
    herbs = {
      [&quot;prickly ash bark&quot;] = &quot;ash&quot;,
      [&quot;bayberry bark&quot;]    = &quot;bayberry&quot;,
      [&quot;bellwort flower&quot;]  = &quot;bellwort&quot;,
      [&quot;bloodroot leaf&quot;]   = &quot;bloodroot&quot;,
      [&quot;black cohosh&quot;]     = &quot;cohosh&quot;,
      [&quot;echinacea&quot;]        = &quot;echinacea&quot;,
      [&quot;ginseng root&quot;]     = &quot;ginseng&quot;,
      [&quot;goldenseal root&quot;]  = &quot;goldenseal&quot;,
      [&quot;hawthorn berry&quot;]   = &quot;hawthorn&quot;,
      [&quot;irid moss&quot;]        = &quot;moss&quot;,
      [&quot;kelp&quot;]             = &quot;kelp&quot;,
      [&quot;kola nut&quot;]         = &quot;kola&quot;,
      [&quot;lobelia seed&quot;]     = &quot;lobelia&quot;,
      [&quot;myrrh gum&quot;]        = &quot;myrrh&quot;,
      [&quot;prickly pear&quot;]     = &quot;pear&quot;,
      [&quot;sileris&quot;]          = &quot;sileris&quot;,
      [&quot;skullcap&quot;]         = &quot;skullcap&quot;,
      [&quot;slippery elm&quot;]     = &quot;elm&quot;,
      [&quot;valerian&quot;]         = &quot;valerian&quot;,
      [&quot;ginger root&quot;]         = &quot;ginger&quot;,
      },
    concoct = {
      [&quot;eagle's feather&quot;]     = &quot;feather&quot;,
      [&quot;kuzu root&quot;]           = &quot;kuzu&quot;,
      [&quot;venom sac&quot;]           = &quot;sac&quot;,
      [&quot;sidewinder skin&quot;]     = &quot;skin&quot;,
      [&quot;lady's slipper&quot;]      = &quot;slipper&quot;,
      [&quot;lady's slipper root&quot;] = &quot;slipper&quot;,
      },
    inks = {
      [&quot;blue ink&quot;]   = &quot;blue&quot;,
      [&quot;gold ink&quot;]   = &quot;gold&quot;,
      [&quot;green ink&quot;]  = &quot;green&quot;,
      [&quot;purple ink&quot;] = &quot;purple&quot;,
      [&quot;red ink&quot;]    = &quot;red&quot;,
      [&quot;yellow ink&quot;] = &quot;yellow&quot;,
      [&quot;black ink&quot;]  = &quot;black&quot;,
      },
    comms = {
      [&quot;bone&quot;]                 = &quot;bone&quot;,
      [&quot;cloth&quot;]                = &quot;cloth&quot;,
      [&quot;coal&quot;]                 = &quot;coal&quot;,
      [&quot;diamond dust&quot;]         = &quot;dust&quot;,
      [&quot;gems&quot;]                 = &quot;gems&quot;,
      [&quot;gold&quot;]                 = &quot;gold&quot;,
      [&quot;piece of stag's&quot;]      = &quot;horn&quot;,
      [&quot;piece of stag's horn&quot;] = &quot;horn&quot;,
      [&quot;ice&quot;]                  = &quot;ice&quot;,
      [&quot;iron&quot;]                 = &quot;iron&quot;,
      [&quot;leather&quot;]              = &quot;leather&quot;,
      [&quot;obsidian&quot;]             = &quot;obsidian&quot;,
      [&quot;platinum&quot;]             = &quot;platinum&quot;,
      [&quot;rope&quot;]                 = &quot;rope&quot;,
      [&quot;silver bar&quot;]           = &quot;silver&quot;,
      [&quot;steel&quot;]                = &quot;steel&quot;,
      [&quot;wood&quot;]                 = &quot;wood&quot;,
      },
    crys = {
      [&quot;crystal cube&quot;]       = &quot;cube&quot;,
      [&quot;crystal cylinder&quot;]   = &quot;cylinder&quot;,
      [&quot;crystal diamond&quot;]    = &quot;diamond&quot;,
      [&quot;crystal disc&quot;]       = &quot;disc&quot;,
      [&quot;crystal egg&quot;]        = &quot;egg&quot;,
      [&quot;crystal pentagon&quot;]   = &quot;pentagon&quot;,
      [&quot;crystal polyhedr&quot;]   = &quot;polyhedron&quot;,
      [&quot;crystal polyhedron&quot;] = &quot;polyhedron&quot;,
      [&quot;crystal pyramid&quot;]    = &quot;pyramid&quot;,
      [&quot;crystal sphere&quot;]     = &quot;sphere&quot;,
      [&quot;crystal spiral&quot;]     = &quot;spiral&quot;,
      [&quot;crystal torus&quot;]      = &quot;torus&quot;,
      },
    misc = {
      [&quot;blueberry&quot;] = &quot;blueberry&quot;,
      [&quot;gleam&quot;]     = &quot;gleam&quot;,
      [&quot;lifestone&quot;] = &quot;lifestone&quot;,
      [&quot;ruby&quot;]      = &quot;ruby&quot;,
      [&quot;weed&quot;]      = &quot;weed&quot;,
      },
    reag = {
      [&quot;red clay&quot;] = &quot;clay&quot;,
      [&quot;red chitin&quot;] = &quot;redchitin&quot;,
      [&quot;ink bladder&quot;] = &quot;bladder&quot;,
      [&quot;lumic moss&quot;] = &quot;lumicmoss&quot;,
      [&quot;yellow chitin&quot;] = &quot;yellowchitin&quot;,
      [&quot;gold flakes&quot;] = &quot;flakes&quot;,
      [&quot;fish scales&quot;] = &quot;scales&quot;,
      [&quot;buffalo horn&quot;] = &quot;horn&quot;,
      [&quot;shark tooth&quot;] = &quot;tooth&quot;,
      [&quot;wyrm tongue&quot;] = &quot;tongue&quot;,
      },
	 cook = {
		[&quot;butter&quot;]        = &quot;butter&quot;,
		[&quot;egg&quot;]           = &quot;egg&quot;,
		[&quot;fish&quot;]          = &quot;fish&quot;,
		[&quot;flour&quot;]         = &quot;flour&quot;,
		[&quot;fruit&quot;]         = &quot;fruit&quot;,
		[&quot;grain&quot;]         = &quot;grain&quot;,
		[&quot;meat&quot;]          = &quot;meat&quot;,
		[&quot;nuts&quot;]          = &quot;nuts&quot;,
		[&quot;olive&quot;]        = &quot;olive&quot;,
		[&quot;poultry&quot;]       = &quot;poultry&quot;,
		[&quot;salt&quot;]          = &quot;salt&quot;,
		[&quot;seeds&quot;]         = &quot;seeds&quot;,
		[&quot;spice&quot;]         = &quot;spice&quot;,
		[&quot;sugar&quot;]         = &quot;sugar&quot;,
		[&quot;sugarcane&quot;]     = &quot;sugarcane&quot;,
		[&quot;vegetable&quot;]     = &quot;vegetable&quot;,
		[&quot;chocolate bean&quot;]= &quot;bean&quot;,
		[&quot;cacao&quot;]         = &quot;cacao&quot;,
		[&quot;cheese&quot;]        = &quot;cheese&quot;,
		[&quot;dough&quot;]         = &quot;dough&quot;,
		[&quot;pasta&quot;]         = &quot;pasta&quot;,
		},
   tran = {
      [&quot;argentum&quot;]      = &quot;argentum&quot;,
      [&quot;arsenic&quot;]       = &quot;arsenic&quot;,
      [&quot;aurum&quot;]         = &quot;aurum&quot;,
      [&quot;azurite&quot;]       = &quot;azurite&quot;,
      [&quot;bisemutum&quot;]     = &quot;bisemutum&quot;,
      [&quot;calamine&quot;]      = &quot;calamine&quot;,
      [&quot;cinnabar&quot;]      = &quot;cinnabar&quot;,
      [&quot;cuprum&quot;]        = &quot;cuprum&quot;,
      [&quot;dolomite&quot;]      = &quot;dolomite&quot;,
      [&quot;ferrum&quot;]        = &quot;ferrum&quot;,
      [&quot;gypsum&quot;]        = &quot;gypsum&quot;,
      [&quot;magnesium&quot;]     = &quot;magnesium&quot;,
      [&quot;malachite&quot;]     = &quot;malachite&quot;,
      [&quot;plumbum&quot;]       = &quot;plumbum&quot;,
      [&quot;potash&quot;]        = &quot;potash&quot;,
      [&quot;quartz&quot;]        = &quot;quartz&quot;,
      [&quot;quicksilver&quot;]   = &quot;quicksilver&quot;,
      [&quot;realgar&quot;]       = &quot;realgar&quot;,
      [&quot;stannum&quot;]       = &quot;stannum&quot;
      },
   alch = {
      [&quot;alchemical coppe&quot;] = &quot;copper&quot;,
      [&quot;alchemical gold&quot;]  = &quot;gold&quot;,
      [&quot;alchemical iron&quot;]  = &quot;iron&quot;,
      [&quot;alchemical lead&quot;]  = &quot;lead&quot;,
      [&quot;alchemical mercu&quot;] = &quot;mercury&quot;,
      [&quot;alchemical salt&quot;]  = &quot;salt&quot;,
      [&quot;alchemical silve&quot;] = &quot;silver&quot;,
      [&quot;alchemical sulph&quot;] = &quot;sulphur&quot;,
      [&quot;alchemical tin&quot;]   = &quot;tin&quot;,
      [&quot;antimony&quot;]         = &quot;antimony&quot;,
      [&quot;calcite&quot;]          = &quot;calcite&quot;,
      },

    },

  current = {
    herbs   = {ash       = 0, bayberry  = 0, bellwort  =  0, bloodroot  = 0,
               cohosh    = 0, echinacea = 0, ginseng    = 0, goldenseal = 0,
               hawthorn  = 0, moss      = 0, kelp       = 0, kola       = 0,
               lobelia   = 0, myrrh     = 0, pear       = 0, sileris    = 0,
               skullcap  = 0, elm       = 0, valerian   = 0, ginger     = 0},
    concoct = {feather   = 0, kuzu       = 0, sac        = 0,
               skin      = 0, slipper   = 0},
    inks    = {blue      = 0, gold      = 0, green      = 0, purple     = 0,
               red       = 0, yellow    = 0, black      = 0},
    comms   = {bone      = 0, cloth     = 0, coal       = 0, dust       = 0,
               gems      = 0, gold      = 0, horn       = 0, ice        = 0,
               iron      = 0, leather   = 0, obsidian   = 0, platinum   = 0,
               rope      = 0, silver    = 0, steel      = 0, wood       = 0},
    crys    = {cube      = 0, cylinder  = 0, diamond    = 0, disc       = 0,
               egg       = 0, pentagon  = 0, polyhedron = 0, pyramid    = 0,
               sphere    = 0, spiral    = 0, torus      = 0},
    misc    = {blueberry = 0, gleam     = 0, lifestone  = 0, ruby       = 0,
               weed      = 0, alchlead  = 0},
    reag    = {clay      = 0, redchitin = 0, bladder    = 0, lumicmoss  = 0,
               flakes    = 0, scales    = 0, horn       = 0, tooth      = 0,
               tongue    = 0, yellowchitin  = 0},
    cook    = {butter    = 0, egg       = 0, fish       = 0, flour      = 0,
               fruit     = 0, grain     = 0, meat       = 0, nuts       = 0,
               olive     = 0, poultry   = 0, salt       = 0, seeds      = 0,
               spice     = 0, sugar     = 0, sugarcane  = 0, vegetable  = 0,
               bean      = 0, cacao     = 0, cheese     = 0, pasta      = 0,
               dough     = 0},
    tran    = {argentum  = 0, arsenic   = 0, aurum      = 0, azurite    = 0,
               bisemutum = 0, calamine  = 0, cinnabar   = 0, cuprum     = 0,
               dolomite  = 0, ferrum    = 0, gypsum     = 0, magnesium  = 0,
               malachite = 0, plumbum   = 0, potash     = 0, quartz     = 0,
               quicksilver=0, realgar   = 0, stannum    = 0},
    alch    = {copper    = 0, gold      = 0, iron       = 0, mercury    = 0,
               salt      = 0, silver    = 0, sulphur    = 0, tin        = 0,
               antimony  = 0, calcite   = 0, lead       = 0},
    },


  reset = function ()
    for type, tab in pairs (rift.current) do
      for k in pairs (tab) do tab[k] = 0 end
    end -- for
  end, -- function

  parse = function (item, amount)
    local x = false
    for k, v in pairs (rift.table) do
      if v[item] then -- if rift.table[type][item]
        rift.current[k][v[item]] = amount
        x = true
      end -- if
    end -- for
    if not x then
      cecho(&quot;&lt;black&gt;[rift.parse]: &lt;red&gt;Unrecognised Rift Item: &quot; .. amount .. &quot; &quot; .. item)
    end -- if
  end, -- func

  below = function (num, group)
    if not group then
      rift.min = tonumber(num)
      rift.display ()
    else
      group = rift.long[group] or group
      rift.min = tonumber(num)
      rift.display (group)
    end -- if
  end, -- func

  display = function (spec)
    if spec then string.lower (spec) end
    spec = rift.long[spec] or spec
    cecho(&quot;\n&lt;green&gt;Your rift contains:&quot;)
    for k, v in ipairs (rift.cats) do
      if (spec == v) or ((not spec) and rift.groups[v]) then
        cecho(&quot;&lt;blue&gt;\n&quot; .. string.title(rift.short[v] or v) .. &quot;\n&quot;)
        rift.displaygroup (v)
      end -- if
    end -- for
    prompt_t.draw ()
    rift.min = nil
  end, -- func

  displaygroup = function (category)
    local itempos = 1
    local riftline = {}
    for item, itemnum in sortedpairs (rift.current[category]) do
      if (not rift.min) or (tonumber(itemnum) &lt; rift.min) then
        riftline[itempos] = {item = item, itemnum = itemnum}
        if itempos == 3 then
                    cecho(&quot;&lt;blue&gt; [&lt;white&gt;&quot;  .. string.format (&quot;%4s&quot;, riftline[1].itemnum))
                    cecho(&quot;&lt;blue&gt;]&lt;white&gt;&quot; .. string.format (&quot;%-13s&quot;, riftline[1].item))
                    cecho(&quot;&lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, riftline[2].itemnum))
                    cecho(&quot;&lt;blue&gt;]&lt;white&gt;&quot; .. string.format (&quot;%-13s&quot;, riftline[2].item))
                    cecho(&quot;&lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, riftline[3].itemnum))
                    cecho(&quot;&lt;blue&gt;]&lt;white&gt;&quot; .. riftline[3].item .. &quot;\n&quot;)
          riftline = {}
          itempos = 1
        else itempos = itempos + 1 end
      end -- if
    end -- for
    if itempos == 2 then
                    cecho(&quot; &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, riftline[1].itemnum))
                    cecho(&quot;&lt;blue&gt;]&lt;white&gt;&quot; .. riftline[1].item .. &quot;\n&quot;)
    elseif itempos == 3 then
                    cecho(&quot; &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, riftline[1].itemnum))
                    cecho(&quot;&lt;blue&gt;]&lt;white&gt;&quot; .. string.format (&quot;%-13s&quot;, riftline[1].item))
                    cecho(&quot;&lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, riftline[2].itemnum))
                    cecho(&quot;&lt;blue&gt;]&lt;white&gt;&quot; .. riftline[2].item .. &quot;\n&quot;)
    end -- if
  end, -- func

  groupset = function (group, state)
    group, state = string.lower (group), string.lower (state)
    group = rift.long[group] or group
    cecho(&quot;\nYou turn &quot; .. state .. &quot; the &quot; .. (rift.short[group] or group) .. &quot; rift group.&quot;)
    rift.groups[group] = (state == &quot;on&quot;)
    rift_save ()
    prompt_t.draw ()
  end, -- func

  groupsdisplay = function ()
    cecho(&quot;\n&lt;white&gt;Rift Groups\n-----------\n&quot;)
    for k, v in ipairs (rift.cats) do
      cecho(&quot;\n&lt;white&gt;&quot; .. string.format (&quot;%-8s %4s&quot;, string.title (v) .. &quot;:&quot;, rift.groups[v] and &quot;on&quot; or &quot;off&quot;) .. &quot; &quot;)
    end -- for
    prompt_t.draw ()
  end, -- func

  help = function ()
    cecho(&quot;\n&lt;white&gt;Rift Commands\n-------------&quot;)
    cecho(&quot;\n&lt;white&gt;IR   - displays your rift normally, capturing information&quot;)
    cecho(&quot;\n&lt;white&gt;RIFT - displays your rift from memory&quot;)
    cecho(&quot;\n&lt;white&gt;RIFT [group] - same as RIFT for only one group&quot;)
    cecho(&quot;\n&lt;white&gt;RIFT BELOW &lt;#&gt; - shows all items below the specified amount&quot;)
    cecho(&quot;\n&lt;white&gt;RIFT [group] BELOW &lt;#&gt; - same as RIFT BELOW &lt;#&gt; for one group&quot;)
    cecho(&quot;\n&lt;white&gt;RIFT GROUPS - shows what groups display&quot;)
    cecho(&quot;\n&lt;white&gt;RIFT [group] ON|OFF - enables or disables a group&quot;)
    cecho(&quot;\n&lt;white&gt;RIFT HELP - shows all rift commands&quot;)
    cecho(&quot;\n&lt;white&gt;\nRift Modules\n------------&quot;)
    cecho(&quot;\n&lt;white&gt;RIFT TATTOOS - calculate how many tattoos you can ink&quot;)
    cecho(&quot;\n&lt;white&gt;RIFT TATTOOS [tattoo] - set the furthest tattoo you can ink&quot;)
    cecho(&quot;\n&lt;white&gt;RIFT RUNES - calculate how many runes you can sketch&quot;)
    cecho(&quot;\n&lt;white&gt;RIFT RUNES [rune] - set the furthest rune you can sketch&quot;)
    cecho(&quot;\n&lt;white&gt;RIFT MILL - calculate how many inks you can mill&quot;)
    cecho(&quot;\n&lt;white&gt;RIFT MILL [ink] - set the furthest ink you can mill\n&quot;)
    prompt_t.draw ()
  end, -- func

  finish = function ()
    disableTrigger(&quot;riftitem&quot;)
    prompt_t.draw ()
  end, -- func

  groups = {
    herbs   = true,
    concoct = false,
    inks    = false,
    comms   = false,
    crys    = false,
    misc    = false,
    },

save = function ()
	if string.char(getMudletHomeDir():byte()) == &quot;/&quot; 
 	 then _sep = &quot;/&quot; 
  	  else _sep = &quot;\\&quot; 
     	   end -- if
local rift_current = getMudletHomeDir() .. _sep .. &quot;rift_current.lua&quot;
 table.save(rift_current, rift.current)
local rift_groups = getMudletHomeDir() .. _sep .. &quot;rift_groups.lua&quot;
 table.save(rift_groups, rift.groups)

end, -- func

load = function ()
	if string.char(getMudletHomeDir():byte()) == &quot;/&quot; 
 	 then _sep = &quot;/&quot; 
  	  else _sep = &quot;\\&quot; 
     	   end -- if
local rift_current = getMudletHomeDir() .. _sep .. &quot;rift_current.lua&quot;
if (io.exists(rift_current)) then
 table.load(rift_current, rift.current)
end -- if
local rift_groups = getMudletHomeDir() .. _sep .. &quot;rift_groups.lua&quot;
if (io.exists(rift_groups)) then
 table.load(rift_groups, rift.groups)
end -- if

end, -- func

  }

-- ======================
--  Rift Module: Tattoos
-- ======================

rift.tattoos = {

  order = {&quot;firefly&quot;, &quot;moss&quot;, &quot;feather&quot;, &quot;shield&quot;, &quot;mindseye&quot;, &quot;hammer&quot;, &quot;cloak&quot;,
           &quot;bell&quot;, &quot;crystal&quot;, &quot;moon&quot;, &quot;starburst&quot;, &quot;boar&quot;, &quot;web&quot;, &quot;tentacle&quot;,
           &quot;hourglass&quot;, &quot;brazier&quot;, &quot;prism&quot;, &quot;tree&quot;, &quot;megalith&quot;, &quot;ox&quot;, &quot;chameleon&quot;},

  table = {
    firefly   = {yellow = 1},
    moss      = {blue = 1, red = 1, yellow = 1},
    feather   = {blue = 2, red = 1},
    shield    = {green = 1, red = 2},
    mindseye  = {blue = 2, green = 1},
    hammer    = {purple = 1, red = 2},
    cloak     = {blue = 3},
    bell      = {blue = 3, red = 2},
    crystal   = {green = 1, purple = 1, yellow = 1},
    moon      = {blue = 1, red =  1, yellow = 1},
    starburst = {blue = 1, gold =  1, green = 1, purple = 1, red = 1, yellow = 1},
    boar      = {purple = 1, red = 2},
    web       = {green = 1, yellow = 1},
    tentacle  = {green = 2, purple = 1},
    hourglass = {blue = 1, yellow = 2},
    brazier   = {red = 2, yellow = 2},
    prism     = {blue = 1, green = 1, purple = 1, red = 1, yellow = 1},
    tree      = {green = 5},
    megalith  = {gold = 2},
    ox        = {gold = 1, red = 1, yellow = 1, blue = 1},
    chameleon = {gold = 1, purple = 1, yellow = 1},
    },

  getnum = function (tattoo)
    local num
    for k, v in pairs (rift.tattoos.table[tattoo]) do
      local i = math.floor (rift.current.inks[k] / v)
      if not num or i &lt; num then num = i end
    end -- for
    return num
  end, -- func

  set = function (x)
    x = string.lower (x)
    if rift.tattoos.table[x] then
      cecho(&quot;\nYour furthest tattoo is now \&quot;&quot; .. x .. &quot;\&quot;.&quot;)
      rift.furthest.tattoo = x
    else
      cecho(&quot;\nNo tattoo by the name \&quot;&quot; .. x .. &quot;\&quot;.&quot;)
    end -- if
    prompt.draw ()
  end, -- func

  run = function ()
    local tattoolist = {}
    for k, v in ipairs (rift.tattoos.order) do
      tattoolist[v] = true
      if v == rift.furthest.tattoo then do break end end
    end -- for
    cecho(&quot;&lt;green&gt;\nYou can ink the following tattoos:\n&quot;)
    local tattoopos = 1
    local tattooline = {}
    for k in sortedpairs (tattoolist) do
      tattooline[tattoopos] = {tattoo = k, num = rift.tattoos.getnum (k)}
      if tattoopos == 3 then
        cecho(&quot;\n &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, tattooline[1].num))
                  cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. string.format (&quot;%-13s&quot;, tattooline[1].tattoo))
                  cecho(&quot; &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, tattooline[2].num))
                  cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. string.format (&quot;%-13s&quot;, tattooline[2].tattoo))
                  cecho(&quot; &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, tattooline[3].num))
                  cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. tattooline[3].tattoo)
        tattooline = {}
        tattoopos = 1
      else tattoopos = tattoopos + 1 end
    end -- for
    if tattoopos == 2 then
      cecho(&quot;\n &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, tattooline[1].num))
                cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. tattooline[1].tattoo)
    elseif tattoopos == 3 then
      cecho(&quot;\n [&quot; .. string.format (&quot;%4s&quot;, tattooline[1].num))
                cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. string.format (&quot;%-13s&quot;, tattooline[1].tattoo))
                cecho(&quot; &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, tattooline[2].num))
                cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. tattooline[2].tattoo)
    end -- if
    prompt.draw ()
  end, -- func
  }


-- ====================
--  Rift Module: Runes
-- ====================

rift.runes = {

  order = {&quot;kena&quot;, &quot;uruz&quot;, &quot;fehu&quot;, &quot;pithakhan&quot;, &quot;jera&quot;, &quot;algiz&quot;, &quot;berkana&quot;,
           &quot;inguz&quot;, &quot;wunjo&quot;, &quot;lagul&quot;, &quot;lagua&quot;, &quot;laguz&quot;, &quot;sowulu&quot;, &quot;gebo&quot;,
           &quot;gebu&quot;, &quot;gular&quot;, &quot;hugalaz&quot;, &quot;sleizak&quot;, &quot;raido&quot;, &quot;nauthiz&quot;,
           &quot;mannaz&quot;, &quot;nairat&quot;, &quot;eihwaz&quot;, &quot;dagaz&quot;, &quot;thurisaz&quot;, &quot;tiwaz&quot;,
           &quot;othala&quot;, &quot;isaz&quot;, &quot;loshre&quot;},

  table = {
    kena      = {red = 1},
    uruz      = {blue = 1, yellow = 1},
    fehu      = {red = 1},
    pithakhan = {red = 1},
    jera      = {purple = 1},
    algiz     = {green = 1},
    berkana   = {yellow = 3},
    inguz     = {red = 1},
    wunjo     = {red = 1},
    lagul     = {purple = 1},
    lagua     = {purple = 1},
    laguz     = {purple = 1},
    sowulu    = {red = 1},
    gebo      = {gold = 1},
    gebu      = {gold = 1},
    gular     = {red = 1},
    hugalaz   = {blue = 1},
    sleizak   = {blue = 1},
    raido     = {green = 1},
    nauthiz   = {blue = 1, yellow = 1},
    mannaz    = {red = 1},
    nairat    = {yellow = 1},
    eihwaz    = {blue = 1, yellow = 1},
    dagaz     = {red = 1, green = 1},
    thurisaz  = {red = 1, blue = 1},
    tiwaz     = {red = 2, blue = 1},
    othala    = {red = 5},
    isaz      = {blue = 1, red = 1},
    loshre    = {blue = 1},
    },

  getnum = function (rune)
    local num
    for k, v in pairs (rift.runes.table[rune]) do
      local i = math.floor (rift.current.inks[k] / v)
      if not num or i &lt; num then num = i end
    end -- for
    return num
  end, -- func

  set = function (x)
    x = string.lower (x)
    if rift.runes.table[x] then
      cecho(&quot;\nYour furthest rune is now \&quot;&quot; .. x .. &quot;\&quot;.&quot;)
      rift.furthest.rune = x
    else
      cecho(&quot;\nNo rune by the name \&quot;&quot; .. x .. &quot;\&quot;.&quot;)
    end -- if
    prompt.draw ()
  end, -- func

  run = function ()
    local runelist = {}
    for k, v in ipairs (rift.runes.order) do
      runelist[v] = true
      if v == rift.furthest.rune then do break end end
    end -- for
    cecho(&quot;&lt;green&gt;\nYou can sketch the following runes:\n&quot;)
    local runepos = 1
    local runeline = {}
    for k in sortedpairs (runelist) do
      runeline[runepos] = {rune = k, num = rift.runes.getnum (k)}
      if runepos == 3 then
        cecho(&quot;\n &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, runeline[1].num))
                  cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. string.format (&quot;%-13s&quot;, runeline[1].rune))
                  cecho(&quot; &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, runeline[2].num))
                  cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. string.format (&quot;%-13s&quot;, runeline[2].rune))
                  cecho(&quot; &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, runeline[3].num))
                  cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. runeline[3].rune)
        runeline = {}
        runepos = 1
      else runepos = runepos + 1 end
    end -- for
    if runepos == 2 then
      cecho(&quot;\n &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, runeline[1].num))
                cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. runeline[1].rune)
    elseif runepos == 3 then
      cecho(&quot;\n &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, runeline[1].num))
                cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. string.format (&quot;%-13s&quot;, runeline[1].rune))
                cecho(&quot; &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, runeline[2].num))
                cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. runeline[2].rune)
    end -- if
    prompt.draw ()
  end, -- func
  }


-- ====================
--  Rift Module: Milling
-- ====================

rift.mill = {

  order = {&quot;red&quot;, &quot;blue&quot;, &quot;yellow&quot;, &quot;green&quot;, &quot;purple&quot;, &quot;gold&quot;, &quot;black&quot;},

  table = {
    red    = { redchitin = 1, scales = 1},
    blue   = { bladder = 1, horn = 1},
    yellow = { yellowchitin = 1, tooth = 1},
    green  = { bladder = 2, yellowchitin = 1, horn = 2, tooth = 1},
    purple = { redchitin = 2, bladder = 2, scales = 2, horn = 2, tongue = 1},
    gold   = { flakes = 1, scales = 2, horn = 2, tooth = 2, tongue = 1},
    black  = { redchitin = 1, bladder = 1, yellowchitin = 1, flakes = 1, scales = 2, horn = 2, tooth = 2, tongue = 3},
    },

  getnum = function (ink)
    local num
    local n = {}
    for k,v in pairs(rift.mill.table[ink]) do
     if k == &quot;redchitin&quot; then
      table.insert(n, string.format(&quot;%d&quot;, rift.current.reag[k] + rift.current.reag.clay / v))
     elseif k == &quot;bladder&quot; then
      table.insert(n, string.format(&quot;%d&quot;, rift.current.reag[k] + rift.current.reag.lumicmoss / v))
     else
      table.insert(n, string.format(&quot;%d&quot;, rift.current.reag[k] / v))
     end-- if
    end -- for
    for k,v in ipairs(n) do
     if not num or tonumber(v) &lt; tonumber(num) then
      num = v
     end -- if
    end -- for
    return num
  end, -- func

  set = function (x)
    x = string.lower (x)
    if rift.mill.table[x] then
      cecho(&quot;\nYour furthest millable ink is now \&quot;&quot; .. x .. &quot;\&quot;.&quot;)
      rift.furthest.mill = x
    else
      cecho(&quot;\nNo ink by the name \&quot;&quot; .. x .. &quot;\&quot;.&quot;)
    end -- if
    prompt.draw ()
  end, -- func

  run = function ()
    local milllist = {}
    for k, v in ipairs (rift.mill.order) do
      milllist[v] = true
      if v == rift.furthest.mill then do break end end
    end -- for
    cecho(&quot;&lt;green&gt;\nYou can mill the following inks:\n&quot;)
    local millpos = 1
    local millline = {}
    for k in sortedpairs (milllist) do
      millline[millpos] = {mill = k, num = rift.mill.getnum (k)}
      if millpos == 3 then
        cecho(&quot;\n &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, millline[1].num))
                  cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. string.format (&quot;%-13s&quot;, millline[1].mill))
                  cecho(&quot; &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, millline[2].num))
                  cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. string.format (&quot;%-13s&quot;, millline[2].mill))
                  cecho(&quot; &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, millline[3].num))
                  cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. millline[3].mill)
        millline = {}
        millpos = 1
      else millpos = millpos + 1 end
    end -- for
    if millpos == 2 then
      cecho(&quot;\n &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, millline[1].num))
                cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. millline[1].mill)
    elseif millpos == 3 then
      cecho(&quot;\n &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, millline[1].num))
                cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. string.format (&quot;%-13s&quot;, millline[1].mill))
                cecho(&quot; &lt;blue&gt;[&lt;white&gt;&quot; .. string.format (&quot;%4s&quot;, millline[2].num))
                cecho(&quot;&lt;blue&gt;]&lt;white&gt; &quot; .. millline[2].mill)
    end -- if
    prompt.draw ()
  end, -- func
  }

rift.load ()</script>
                <eventHandlerList/>
            </Script>
        </ScriptGroup>
    </ScriptPackage>
    <AliasPackage>
        <AliasGroup isActive="yes" isFolder="yes">
            <name>Rift</name>
            <script></script>
            <command></command>
            <packageName></packageName>
            <regex></regex>
            <Alias isActive="yes" isFolder="no">
                <name>rift help</name>
                <script>rift.help ()</script>
                <command></command>
                <packageName></packageName>
                <regex>^\s*rift\shelp$</regex>
            </Alias>
            <Alias isActive="yes" isFolder="no">
                <name>rift display</name>
                <script>rift.display ()</script>
                <command></command>
                <packageName></packageName>
                <regex>^\s*rift\s*$</regex>
            </Alias>
            <Alias isActive="yes" isFolder="no">
                <name>rift display specific</name>
                <script>rift.display (matches[2])</script>
                <command></command>
                <packageName></packageName>
                <regex>^\s*rift\s+(herbs|concoct|concoctables|inks|comms|commodities|crys|crystals|misc|miscellaneous|reag|reagents|cook|ingredients|tran|transmutations|alch|alchemicals)\s*$</regex>
            </Alias>
            <Alias isActive="yes" isFolder="no">
                <name>rift group set</name>
                <script>rift.groupset (matches[2], matches[3])</script>
                <command></command>
                <packageName></packageName>
                <regex>^\s*rift\s+(herbs|concoct|concoctables|inks|comms|commodities|crys|crystals|misc|miscellaneous|reag|reagents|cook|ingredients|tran|transmutations)\s+(on|off)\s*$</regex>
            </Alias>
            <Alias isActive="yes" isFolder="no">
                <name>rift below specific</name>
                <script>rift.below (matches[3], matches[2])</script>
                <command></command>
                <packageName></packageName>
                <regex>^\s*rift\s+(herbs|concoct|concoctables|inks|comms|commodities|crys|crystals|misc|miscellaneous|reag|reagents|cook|ingredients|tran|transmutations|alch|alchemicals)\s+below\s+(\d+)\s*$</regex>
            </Alias>
            <Alias isActive="yes" isFolder="no">
                <name>rift below</name>
                <script>rift.below (matches[2])</script>
                <command></command>
                <packageName></packageName>
                <regex>^\s*rift\s+below\s+(\d+)\s*$</regex>
            </Alias>
            <Alias isActive="yes" isFolder="no">
                <name>rift groups display</name>
                <script>rift.groupsdisplay ()</script>
                <command></command>
                <packageName></packageName>
                <regex>^\s*rift\s+groups\s*$</regex>
            </Alias>
            <Alias isActive="yes" isFolder="no">
                <name>rift tattoos</name>
                <script>rift.tattoos.run ()</script>
                <command></command>
                <packageName></packageName>
                <regex>^\s*rift\s+tattoos\s*$</regex>
            </Alias>
            <Alias isActive="yes" isFolder="no">
                <name>rift tattoos set</name>
                <script>rift.tattoos.set (matches[2])</script>
                <command></command>
                <packageName></packageName>
                <regex>^\s*rift\s+tattoos\s+(\w+)\s*$</regex>
            </Alias>
            <Alias isActive="yes" isFolder="no">
                <name>rift runes</name>
                <script>rift.runes.run ()</script>
                <command></command>
                <packageName></packageName>
                <regex>^\s*rift\s+runes\s*$</regex>
            </Alias>
            <Alias isActive="yes" isFolder="no">
                <name>rift runes set</name>
                <script>rift.runes.set (matches[2])</script>
                <command></command>
                <packageName></packageName>
                <regex>^\s*rift\s+runes\s+(\w+)\s*$</regex>
            </Alias>
            <Alias isActive="yes" isFolder="no">
                <name>rift mill</name>
                <script>rift.mill.run ()</script>
                <command></command>
                <packageName></packageName>
                <regex>^\s*rift\s+mill\s*$</regex>
            </Alias>
            <Alias isActive="yes" isFolder="no">
                <name>rift mill set</name>
                <script>rift.mill.set (matches[2])</script>
                <command></command>
                <packageName></packageName>
                <regex>^\s*rift\s+mill\s+(\w+)\s*$</regex>
            </Alias>
        </AliasGroup>
    </AliasPackage>
    <TriggerPackage>
        <TriggerGroup isActive="yes" isFolder="yes" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
            <name>Rift</name>
            <script></script>
            <triggerType>0</triggerType>
            <conditonLineDelta>99</conditonLineDelta>
            <mStayOpen>0</mStayOpen>
            <mCommand></mCommand>
            <packageName></packageName>
            <mFgColor>#ff0000</mFgColor>
            <mBgColor>#ffff00</mBgColor>
            <mSoundFile></mSoundFile>
            <colorTriggerFgColor>#000000</colorTriggerFgColor>
            <colorTriggerBgColor>#000000</colorTriggerBgColor>
            <regexCodeList/>
            <regexCodePropertyList/>
            <Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
                <name>rift reset</name>
                <script>rift.reset ()
enableTrigger(&quot;riftitem&quot;)
-- deleteLine()</script>
                <triggerType>0</triggerType>
                <conditonLineDelta>0</conditonLineDelta>
                <mStayOpen>0</mStayOpen>
                <mCommand></mCommand>
                <packageName></packageName>
                <mFgColor>#ff0000</mFgColor>
                <mBgColor>#ffff00</mBgColor>
                <mSoundFile></mSoundFile>
                <colorTriggerFgColor>#000000</colorTriggerFgColor>
                <colorTriggerBgColor>#000000</colorTriggerBgColor>
                <regexCodeList>
                    <string>^Glancing into the Rift\, you see\:$</string>
                </regexCodeList>
                <regexCodePropertyList>
                    <integer>1</integer>
                </regexCodePropertyList>
            </Trigger>
            <Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
                <name>remove/store</name>
                <script>rift.parse (matches[2], matches[3])
rift.save ()</script>
                <triggerType>0</triggerType>
                <conditonLineDelta>0</conditonLineDelta>
                <mStayOpen>0</mStayOpen>
                <mCommand></mCommand>
                <packageName></packageName>
                <mFgColor>#ff0000</mFgColor>
                <mBgColor>#ffff00</mBgColor>
                <mSoundFile></mSoundFile>
                <colorTriggerFgColor>#000000</colorTriggerFgColor>
                <colorTriggerBgColor>#000000</colorTriggerBgColor>
                <regexCodeList>
                    <string>^You (?:remove|store) \d+ ([a-z\' ]+?), bringing the total (?:in the Rift )?to (\d+)(?:, which is the maximum for that type of object)?\.$</string>
                </regexCodeList>
                <regexCodePropertyList>
                    <integer>1</integer>
                </regexCodePropertyList>
            </Trigger>
            <Trigger isActive="no" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
                <name>riftitem</name>
                <script>rift.parse (matches[3], matches[2])
if matches[4] ~= &quot;&quot; then rift.parse (matches[5], matches[4]) end
if matches[6] ~= &quot;&quot; then rift.parse (matches[7], matches[6]) end
rift.save ()
-- deleteLine()</script>
                <triggerType>0</triggerType>
                <conditonLineDelta>99</conditonLineDelta>
                <mStayOpen>0</mStayOpen>
                <mCommand></mCommand>
                <packageName></packageName>
                <mFgColor>#ff0000</mFgColor>
                <mBgColor>#ffff00</mBgColor>
                <mSoundFile></mSoundFile>
                <colorTriggerFgColor>#000000</colorTriggerFgColor>
                <colorTriggerBgColor>#000000</colorTriggerBgColor>
                <regexCodeList>
                    <string>^\s{2}\[\s*(\d+)\] ([a-z\' ]+?)(?:\s+\[\s*(\d+)\] ([a-z\' ]+?))?(?:\s+\[\s*(\d+)\] ([a-z\' ]+))?$</string>
                </regexCodeList>
                <regexCodePropertyList>
                    <integer>1</integer>
                </regexCodePropertyList>
            </Trigger>
            <Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
                <name>prompt</name>
                <script>-- prompt.data = TriggerStyleRuns
disableTrigger(&quot;riftitem&quot;)</script>
                <triggerType>0</triggerType>
                <conditonLineDelta>99</conditonLineDelta>
                <mStayOpen>0</mStayOpen>
                <mCommand></mCommand>
                <packageName></packageName>
                <mFgColor>#ff0000</mFgColor>
                <mBgColor>#ffff00</mBgColor>
                <mSoundFile></mSoundFile>
                <colorTriggerFgColor>#000000</colorTriggerFgColor>
                <colorTriggerBgColor>#000000</colorTriggerBgColor>
                <regexCodeList>
                    <string>return isPrompt()</string>
                </regexCodeList>
                <regexCodePropertyList>
                    <integer>4</integer>
                </regexCodePropertyList>
            </Trigger>
        </TriggerGroup>
    </TriggerPackage>
</MudletPackage>
