Moderators IIYAMA Posted January 24, 2014 Moderators Share Posted January 24, 2014 Hey, I am trying to make a label text fit able, but I am ending up at an infinity loop. Anybody has a solution? local maxLabelSizeTable = {40,40,40,40,40} local makeTextFitForGrid = function (element,index) local text = guiGetText ( element ) local size = guiLabelGetTextExtent ( element ) outputChatBox(size) local maxSize = maxLabelSizeTable[index] if size > maxSize then repeat guiSetText( element,string.sub(text,1,-2)) size = guiLabelGetTextExtent ( element ) until maxSize > size local text = guiGetText ( element ) guiSetText( element, text .. "..") end end Link to comment
Sasu Posted January 25, 2014 Share Posted January 25, 2014 Because you have to update the variable "text" each time you change the gui text. Try this: local maxLabelSizeTable = {40,40,40,40,40} local makeTextFitForGrid = function (element,index) local text local size = guiLabelGetTextExtent ( element ) outputChatBox(size) local maxSize = maxLabelSizeTable[index] if size > maxSize then repeat text = guiGetText(element) guiSetText( element,string.sub(text,1,-2)) size = guiLabelGetTextExtent ( element ) until maxSize > size text = guiGetText(element) guiSetText( element, text .. "..") end end Link to comment
Moderators IIYAMA Posted January 25, 2014 Author Moderators Share Posted January 25, 2014 oh lol Thanks! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now