Help with a table and styles

Posted by Slick2175 on Fri 21 Nov 2014 11:34 PM — 1 posts, 8,620 views.

USA #0
So I have created a equipment capture to capture my equipment. the equipment line looks like this


<worn on hind paws>    a pair of shit covered steel toe boots


What Im trying to do is split the string up. I want to remove the pattern (<.+>) from the string and add it back to the table. Which is where im running into issues. So

<worn on hind paws> and A pair of shit covered steel toe boots are two separate values in the table.

Cause I think it would prob be alot better then what I currently have spec when I want to be able to adjust where the text starts on the screen with hotspots.

what I currently have :

local y = font_height * 2 + font_height

local z = font_height + font_height

for i, styles in ipairs (equip) do

  local x = 5 + font_height
 
  for _, style in ipairs (styles) do

style.text = style.text:gsub("%s%s+", " ")

for w in string.gmatch (style.text, "<.+>") do
	local j = 5 + font_height
	j = j + WindowText (eq, font, w, j, z, 0, 0, ColourNameToRGB("yellow"))

	z = z + font_height * 2
end -- for

style.text = style.text:gsub("<.+>", "")

x = x + WindowText (eq, font, style.text, x, y, 0, 0, style.textcolour)
end -- for
y = y + font_height * 2

--- show window

WindowShow (eq, true)
 

end -- for each equipment item


the code I currently have captures the pattern writes it to the miniwindow then deletes it from the actually string then prints the string, and I lose (<.+>) the pattern for good from the equip table.

Hope that makes sense. i cant wrap my head around these style tables.