Fixed subject title. I meant removing those words out of the string in that affects variable. Hopefully I'm saying it right now.
Here's the entirety of the affects code.
local AffectName = {}
local AffectDuration = {}
local AffectMax = 0
function init_affects (data)
index = 0
startpos = 1
max = 0
for i = startpos, string.len(data), 1 do
if string.byte(data,i) == 1 or i == string.len(data) then
if string.byte(data,i) == 1 then
endpos = 1
else
endpos = 0
end -- if
variable = string.sub(data,startpos,i-endpos)
startpos = i+1
index = index + 1
pos1 = string.find(variable, "\002")
if pos1 ~= nil then
AffectName[index] = string.sub(variable, 1, pos1-1)
AffectDuration[index] = string.sub(variable, pos1+1)
end -- if
end -- if
end -- for
-- AffectMax is the highest EVER number - we need to keep track of all created icons
if index < AffectMax then
for i=index+1,AffectMax,1 do
AffectName[i] = nil
win = "affect_window_"..i
WindowShow (win, false)
end -- for
AffectMax = index
elseif index > AffectMax then
AffectMax = index
end -- if
end -- function
function draw_affects ()
affects = msdp["AFFECTS"]
if affects == nil or affects == "None" then
for i=1,AffectMax,1 do
WindowShow ("affect_window_"..i, false)
end -- for
AffectMax = 0
return
end -- if
init_affects (affects)
offset_x = 0
offset_y = 0
for i=1,AffectMax,1 do
if AffectName[i] ~= nil then
win = "affect_window_"..i
affect = "affect_"..i
-- draw the icons left to right, top to bottom
if i > 1 then
if offset_x == 0 then
offset_x = 36
elseif offset_x == 36 then
offset_x = 72
elseif offset_x == 72 then
offset_x = 108
else
offset_x = 0
offset_y = offset_y + 36
end -- if
end -- if
colour = colourWhite
Rest of this function is just it creating a miniwindow, loading icon images, and adding hot spots. Here's the loading image part of it if it helps any.
if WindowLoadImage (win, affect, GetInfo (66) .. "Generic/affects/" .. AffectName[i] .. ".png") == eOK then
check (WindowDrawImage (win, affect, 1, 1, 33, 33, 2)) -- draw the icon
elseif WindowLoadImage (win, affect, GetInfo (66) .. "Generic/affects/default.png") == eOK then
check (WindowDrawImage (win, affect, 1, 1, 33, 33, 2)) -- draw the default icon instead
else -- even the default spell icon is missing
Note( "Missing spell icons.")
return
end -- if
The AffectName[eye] part is actually the letter i. I had to make it that way so it wouldn't make it that italic code when posting.
So when msdp["AFFECTS"] puts that enchant weapon part into the affects string, I need to somehow remove it. Would gsub work for something like this? Maybe string.match for enchant weapon then remove it with gsub like "" ? Doing it like that I suppose it would be easy to match the space, but what about that tiny upside-down L and the -1 part? Sorry for this confusing question.
Here's the screenshot on imgur, hopefully that one isn't blocked for you.
http://i.imgur.com/Vf79m7y.png
[EDIT] Escaped square brackets. |