I made an lua addon that when you type the //stna command sends a command to your alt to cast -na spells on you based on status effects you have gained during battle. Now, i didn't add erase because that's easy to just macro, but it's based on a priority queue inside the stna.lua file. (priority is left to right top to bottom i had them numbered but lua didn't like that) You may change the priority as you wish. Anyway here it is (you'll need 3 files i'll post them in seperate code blocks.. just put tablehelper/mathhelper in <windowerfolder>/addons/libs/ That way later addons later can use it if need be)
Edit: Changed some of the wording. Also, this addon uses send addon or multisend command to send the -na spell command.
edit2 Evidently arcon put requirement for mathhelper in tablehelper and i didn't notice it. adding it.
stna.lua
Code:
require 'tablehelper'
function event_load()
player = get_player()
send_command('alias stna lua c stna')
statSpell = {
Paralysis='Paralyna',
Curse='Cursna',
Doom='Cursna',
Silence='Silena',
Plague='Viruna',
Diseased='Viruna',
Petrification='Stona',
Poison='Poisona',
Blindness='Blindna'
}
--You may change this priority as you see fit this is my personal preference
priority = {
'Doom','Curse','Petrification',
'Paralysis','Plague','Silence',
'Blindness','Poison','Diseased'
}
statusTable = T{}
end
function event_addon_command()
if statusTable[1] == nil then
add_to_chat(55,"You are not afflicted by a status with a -na spell.")
else
for i = 1, 9 do
for u = 1, #statusTable do
if statusTable[u]:lower() == priority[i]:lower() then
send_command('send @others '..statSpell[priority[i]]..' '..player['name'])
return
end
end
if i == 9 then
add_to_chat(55,"You are not afflicted by a status with a -na spell.")
end
end
end
end
function event_gain_status(id,name)
if #statusTable == 0 then
for i = 1, #priority do
if priority[i]:lower() == name:lower() then
statusTable[#statusTable+1] = name
end
end
else
for u = 1, #statusTable do
if statusTable[u]:lower() == name:lower() then
return
else
for i = 1, #priority do
if priority[i]:lower() == name:lower() then
statusTable[#statusTable+1] = name
end
end
end
end
end
end
function event_lose_status(id,name)
for u = 1, #statusTable do
if statusTable[u]:lower() == name:lower() then
table.remove(statusTable,u)
return
end
end
end
tablehelper.lua -- Courtesy of Arcon
Code:
require 'mathhelper'
_table_meta = {__index=table}
function T(t)
return setmetatable(t, _table_meta)
end
function table.slice(t, from, to)
from = from or 1
if from < 0 then
from = from%#t+1
end
to = to or #t
if to < 0 then
to = (to-1)%#t+1
end
local res = T{}
for i = from, to do
res[#res+1] = t[i]
end
return res
end
function table.map(t, fn)
local res = T{}
if #t == 0 then
for key, val in pairs(t) do
res[key] = fn(val)
end
else
for key = 1, #t do
res[key] = fn(t[key])
end
end
return res
end
function table.filter(t, fn)
local res = T{}
if #t == 0 then
for key, val in pairs(t) do
if fn(val) then
res[key] = val
end
end
else
for key = 1, #t do
if fn(t[key]) then
res[#res+1] = t[key]
end
end
end
return res
end
function table.keyfilter(t, fn)
local res = T{}
if #t == 0 then
for key, val in pairs(t) do
if fn(key) then
res[key] = val
end
end
else
for key = 1, #t do
if fn(key) then
res[#res+1] = t[key]
end
end
end
return res
end
function table.reduce(t, fn, init)
t = T(t)
if t:isempty() then
return init
end
acc = init
for key, val in pairs(t) do
if acc == nil then
acc = val
else
acc = fn(acc, val)
end
end
return acc
end
function table.any(t, fn)
for key, val in pairs(t) do
if(fn(val) == true) then
return true
end
end
return false
end
function table.all(t, fn)
for key, val in pairs(t) do
if(fn(val) ~= true) then
return false
end
end
return true
end
function table.sum(t)
return table.reduce(t, math.sum, 0)
end
function table.mult(t)
return table.reduce(t, math.mult, 1)
end
function table.isempty(t)
return next(t) == nil
end
mathhelper.lua
Code:
function math.round(num, prec)
local mult = 10^(prec or 0)
return math.floor(num * mult + 0.5) / mult
end
function math.sgn(num)
return num/math.abs(num)
end
function math.even(num)
return num%2 == 0
end
function math.odd(num)
return num%2 == 1
end
function math.sum(val1, val2)
return val1+val2
end
function math.mult(val1, val2)
return val1*val2
end