Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Help with a table and styles

Help with a table and styles

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Slick2175   USA  (27 posts)  Bio
Date Fri 21 Nov 2014 11:34 PM (UTC)
Message
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.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


8,238 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.