Hi guys, first post so take it easy on me.
I am in the process of converting a old gamemode and I have hit a brick wall with the bit of code. It's only some simple code(I think...), but I have looked around and I am unable to find any update with regards to this command.
Code:
draw.DrawText(util:WordWrap("About this class: "..tbl.DESCRIPTION,"Default",1200)("Default",10,60,Color(255,255,255,255),0,1))
Error from Console:
[ERROR] gamemodes/fortwars/gamemode/cl_menu.lua:154: attempt to call field 'WordWrap' (a nil value)
1. unknown - gamemodes/fortwars/gamemode/cl_menu.lua:154
Now, I have tried simply removing the util.WordWrap which seems to cause more issues than I can get my head around.
Anyone seen this issue/command before?
Thanks,
.0mega
. not :
Still getting the same error.
Function like this doesn't exist.
Any ideas what to replace it with? I am unsure how it worked in the original code. I assume that I am going to have to rewrite the how menu system?
Lua users has a textWrap function here: [URL="http://lua-users.org/wiki/StringRecipes"]http://lua-users.org/wiki/StringRecipes[/URL]
[CODE]
function wrap(str, limit, indent, indent1)
indent = indent or ""
indent1 = indent1 or indent
limit = limit or 72
local here = 1-#indent1
return indent1..str:gsub("(%s+)()(%S+)()",
function(sp, st, word, fi)
if fi-here > limit then
here = st - #indent
return "\n"..indent..word
end
end)
end
[/CODE]
You can call it like this:
[CODE]
local text = wrap("About this class: "..tbl.DESCRIPTION,256,"","")
draw.SimpleText(text,"Default",0,0,Color(255,255,255),TEXT_ALIGN_LEFT,TEXT_ALIGN_TOP)
[/CODE]
DarkRP also has a textwrap function DarkRP.textWrap() which does nearly the same
Perfect!
Thanks for the help on that one Angry!
Sorry, you need to Log In to post a reply to this thread.