includes/modules/draw.lua:92: attempt to index local 'colour' (a number value)
3 replies, posted
Im making a little search menu for myself.
:byodood: And I ran into a problem:
[code]
includes/modules/draw.lua:92: attempt to index local 'colour' (a number value)[/code]
I know that the error not comes from my script, but there must be something in my script causing it!
I know that the problem is between line 33 to 40, but I cant see the problem.. :ohdear:
[lua]
concommand.Add( "SearchMenu", function()
Menu = vgui.Create( "DFrame" )
Menu:SetPos( 10, 80 )
Menu:SetSize( 350, 360 )
Menu:SetTitle( "Search Menu :3" )
Menu:SetVisible( true )
Menu:SetDraggable( true )
Menu:ShowCloseButton( true )
Menu:MakePopup()
local Sheet = vgui.Create( "DPropertySheet" )
Sheet:SetParent( Menu )
Sheet:SetPos( 5, 30 )
Sheet:SetSize( 340, 325 )
local Search = vgui.Create("DFrame")
Search:SetParent( PropertySheet )
Search:Center()
Search:SetPos( 5, 5 )
Search:SetTitle("Search For Entities")
Search:SetDraggable( false )
Search:ShowCloseButton( false )
local Search1 = vgui.Create( "DTextEntry", Search )
Search1:SetParent( Search )
Search1:SetPos( 10,35 )
Search1:SetTall( 20 )
Search1:SetWide( 305 )
Search1:SetEnterAllowed( true )
Search1.OnEnter = function()
for k,v in pairs(ents.GetAll()) do
if v:GetClass()==Search1:GetValue() then
local Position = v:GetPos() + Vector( 0, 0, 20 )
Position = Position:ToScreen()
draw.RoundedBox(0, Position.x-75, Position.y-20, 150, 20, Color(20,20,20,150) )
draw.SimpleText( Search1:GetValue(), Position.x, Position.y-10, Color(0,255,0,255),0, 0)
end
end
end
Sheet:AddSheet("Search 4 Entities", Search, "gui/silkicons/application", false, false)
end )
[/lua]
Many thanks for help! :goleft:
You are missing the font argument to [b][url=http://wiki.garrysmod.com/?title=Draw.SimpleText]Draw.SimpleText [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]. This means that you are sending your XAlign argument as the colour.
draw.SimpleText( Search1:GetValue(), Position.x, Position.y-10, Color(0,255,0,255),0, 0)
Use
draw.SimpleText( Search1:GetValue(), nil, Position.x, Position.y-10, Color(0,255,0,255),0, 0)
2'th argument is font
[editline]06:13PM[/editline]
Ninja's
:razz: Thanks to both of you!
Sorry, you need to Log In to post a reply to this thread.