VGUI displaying table content not working

I also posted this in DarkRP help forum but thought I’d post it here to get a little more attention (hoping to finish it today).
I’m guessing this isn’t Dark RP specific.

Can someone give me a hand with this:



for k, v in pairs (DarkRP.getLaws()) do
    lawHeight = 10
    lawsPanelLaws = vgui.Create( "DLabel"  )
    lawsPanelLaws:SetFont( "title" )
    lawsPanelLaws:SetText( v )
    lawsPanelLaws:SetSize( 100, 100 )
    lawsPanelLaws:SetContentAlignment( 7 )
    lawsPanelLaws:SetPos( 0, lawHeight )
    lawsPanelLaws:SetTextColor( Color( 255, 255, 255, 255 ) )
    lawHeight = lawHeight + 20
end


It’s not showing the laws on screen ,however if in console I do



lua_run_cl for k, v in pairs(DarkRP.getLaws()) do print(v) end


It does print all the laws :confused: so I know ‘v’ holds them, what am I doing wrong?

Just as an added check, I did the following which DOES print 1-10 on screen, so I know the script for showing the HUD works.



for i=1,10 do
    lawsPanelLaws = vgui.Create( "DLabel", lawsPanel );
    lawsPanelLaws:SetFont( "title" )
    lawsPanelLaws:SetText( i );
    lawsPanelLaws:SetSize( lawsPanel:GetWide(), 20 ) 
    lawsPanelLaws:SetContentAlignment( 7 )
    lawsPanelLaws:SetPos( 10, lawsPanelTitleBar:GetTall() + replyPosition )
    lawsPanelLaws:SetTextColor( Color( 255, 255, 255, 255 ) )
    replyPosition = ( replyPosition + lawsGap + lawsPanelLaws:GetTall() )
end


and that does print 1-10 on screen, so I know all the code works.

[editline]1st June 2014[/editline]

I just tried taking out for k, v in pairs and doing



 lawsPanelLaws:SetText( table.ToString(DarkRP.getLaws() ) )


and it simply prints { } which to me says the table is empty? But it’s not :confused:

Okay, next test: I’ve just done


for k, v in pairs(DarkRP.getLaws()) do print(v[1]) end


and it returns the first letter of each law:

So if I do print(v[15]) it prints the 15th letter of each law :confused:

Okay I think it was because I was doing a check to see if the HUD was already drawn after for k, v in pairs but apparently it was stopping it from printing the laws :confused: