Hello Facepunch,
I've been having a few issues, well I'm working an a inventory and I'm trying to get the content to go downwards but they aren't they're just either stacking over eachother or going to the right.
If someone could help me where i can make them go below each other i'd appreciate it alot, thank you.
[LUA]
local myInv = {}
myInv[1] = "melon"
myInv[2] = "tools"
myInv[3] = "cigar"
myInv[4] = "rope"
for i=1,4 do
surface.DrawText(myInv[i])
surface.SetFont( "tommyCee_font_default" )
surface.SetTextColor( 255, 255, 255, 255 )
surface.SetTextPos( 2, -4 )
end
[/LUA]
Not 100% sure, but I believe you need to set the color, pos, and font before actually drawing the text. And what are you hooking this to?
[QUOTE=Tupac;51091791]Not 100% sure, but I believe you need to set the color, pos, and font before actually drawing the text. And what are you hooking this to?[/QUOTE]
Yes, that was a paste error on my behalf, it's just simply retreving the players pocket items in darkrp and printing them downwards...
[code]surface.SetTextPos( 2, -4 * i )[/code]
You aren't even moving it, so no wonder they are stacking.
[QUOTE=Netheous;51091972][code]surface.SetTextPos( 2, -4 * i )[/code]
You aren't even moving it, so no wonder they are stacking.[/QUOTE]
Thank you!
[QUOTE=Chickengbs;51091689]
[LUA]
local myInv = {}
myInv[1] = "melon"
myInv[2] = "tools"
myInv[3] = "cigar"
myInv[4] = "rope"
for i=1,4 do
for k, v in ipairs( myInv ) do
surface.SetFont( "tommyCee_font_default" )
surface.SetTextColor( 255, 255, 255, 255 )
surface.SetTextPos( 2, -4 * k )
surface.DrawText(v)
end
end
[/LUA][/QUOTE]
By the way, you can just do this:
[lua]local myInv = {
"melon",
"tools",
"cigar",
"rope",
}
for k, v in ipairs( myInv ) do
surface.SetFont( "tommyCee_font_default" )
surface.SetTextColor( 255, 255, 255, 255 )
surface.SetTextPos( 2, -4 * k )
surface.DrawText(v)
end[/lua]
[QUOTE=JasonMan34;51093196]By the way, you can just do this:
local myInv = { "melon", "tools", "cigar", "rope",}for k, v in ipairs( myInv ) do surface.SetFont( "tommyCee_font_default" ) surface.SetTextColor( 255, 255, 255, 255 ) surface.SetTextPos( 2, -4 * k ) surface.DrawText(v) end
[/QUOTE]
-snipbecauseimblind-
[QUOTE=aftokinito;51093268]May I suggest this?:
[CODE]local myInv = {
"melon",
"tools",
"cigar",
"rope",
}
for _, v in ipairs( myInv ) do
surface.SetFont( "tommyCee_font_default" )
surface.SetTextColor( 255, 255, 255, 255 )
surface.SetTextPos( 2, -4 * k )
surface.DrawText(v)
end[/CODE][/QUOTE]
'k' is undefined there.
[QUOTE=Skere_;51093290]'k' is undefined there.[/QUOTE]
NEVERMIND, I'm blind and didn't see you used the K in SetTextPos.
Sorry, you need to Log In to post a reply to this thread.