Hello everyone,
I really hate...making threads like this, but I really cannot deal with this problem anymore, it's literally stopping me from producing anything.
I have these strange encounters when trying to do simple things in lua.
Examples are:
[CODE]local frame = vgui.Create( "Frame" )
frame:SetSize( 100, 100 )
frame:Center()
frame:SetVisible( true )
frame:MakePopup()
[/CODE]
And then I get an error like:
[CODE][ERROR] lua/autorun/menu.lua:1: attempt to index global 'vgui' (a nil value)
1. unknown - lua/autorun/menu.lua:1[/CODE]
And another thing that bothers me a lot is the fact that I can't do things like this anymore:
[CODE]function GM:RenderScreenspaceEffects()
DrawMaterialOverlay( "models/props_c17/fisheyelens", -0.06 )
end[/CODE]
Error would be:
[CODE][ERROR] lua/autorun/menu.lua:1: attempt to index global 'GM' (a nil value)
1. unknown - lua/autorun/menu.lua:1
[/CODE]
Did I miss an update or something? Because these problems have been going on for a while now.
Autorun is called shared, you need to put your file in autorun/client. The GM problem comes because the gamemode has not initialized yet, use hook.Add instead.
Make sure you're creating vgui stuff clientside, and you have to use hooks for GM stuff.
NINJA: damnit
Alright, it's been a while since I picked up the whole lua thing. But, I'm remembering stuff now.
[editline]22nd August 2013[/editline]
So, I tried doing something simple like:
[CODE]function yes()
local Base = vgui.Create( "DFrame" )
Base:SetPos( 0, 0 )
Base:SetSize( ScrW, ScrH )
Base:SetTitle( "" )
Base:SetVisible( true )
Base:SetDraggable( true ) -- For now
Base:ShowCloseButton( true )
Base:MakePopup()
end
concommand.Add( "no", yes )[/CODE]
And put the file in lua/autorun/client nothing happened.
So, then I thought. Okay maybe I'm doing something stupid. So I did:
[CODE]local Base = vgui.Create( "DFrame" )
Base:SetPos( 0, 0 )
Base:SetSize( ScrW, ScrH )
Base:SetTitle( "" )
Base:SetVisible( true )
Base:SetDraggable( true ) -- For now
Base:ShowCloseButton( true )
Base:MakePopup()[/CODE]
Nothing happened, anything I did wrong?
ScrW(), ScrH() instead of ScrW, ScrH
[QUOTE=Looter;41927641]ScrW(), ScrH() instead of ScrW, ScrH[/QUOTE]
Woops, thanks for finding that, but still nothing.
[editline]22nd August 2013[/editline]
Oh! Okay, well...lua autorefresh stunk so I restarted Gmod and I finally got something out of console:
[CODE][ERROR] lua/autorun/client/menu.lua:2: attempt to index local 'Base' (a nil value)
1. unknown - lua/autorun/client/menu.lua:2
[/CODE]
[editline]22nd August 2013[/editline]
[QUOTE=pilot;41927690]Woops, thanks for finding that, but still nothing.
[editline]22nd August 2013[/editline]
Oh! Okay, well...lua autorefresh stunk so I restarted Gmod and I finally got something out of console:
[CODE][ERROR] lua/autorun/client/menu.lua:2: attempt to index local 'Base' (a nil value)
1. unknown - lua/autorun/client/menu.lua:2
[/CODE][/QUOTE]
So I changed Base to DermaPanel and now it's working...I...um...
One more thing before I head out. Apparently setting the size of images doesn't work. Did I do anything wrong? I just have a regular:
[CODE]Image = vgui.Create( "DImage", Base )
Image:SetPos( 0, 0 )
Image:SetSize( ScrW(), ScrH() )
Image:SetImage( "[Image_location]" )
Image:SizeToContents() [/CODE]
Sorry, you need to Log In to post a reply to this thread.