Derma help

Okay i’m trying make a Menu with 3 tabs

-Help
-Rules
-Changelog

I want to add text to these
Could anyone help me? …

i have maked the tabs, and the menu, but i dont know how to add the rules and text into it…

Hey, this is a lot easier to do than you think. Let me show you an example script, but also: don’t forget to use the Gmod Wiki. All of the examples found on it are functional, as long as you follow the tutorials to the ‘T’.

When you say tabs, you’re refering to the Derma control known as a DPropertySheet. The way it works is you define the actual PropertySheet first, you parent it to your frame, and then you add elements to it, like this:

[lua]function Example_PropertySheet( )

-- Make a frame
local frame = vgui.Create( "DFrame" )
frame:SetSize( 512, 368 )
frame:Center( )
frame:MakePopup( true )

-- Define the property sheet first
local property_sheet = vgui.Create( "DPropertySheet", frame )
property_sheet:StretchToParent( 5, 25, 5, 5 )

-- Now we define the elements we want to add to the property sheet,
-- In this case, we'll add a simple label.
local label = vgui.Create( "DLabel" ) -- Notice how we don't parent the elements to anything
label:SetText( "This is text, from a label, that has been added to a property sheet." )
label:StretchToParent( 2, 24, 2, 2 )

-- This is what makes the label appear in the property sheet under it's own tab
property_sheet:AddItem( "Help", label, "gui/silkicons/user", false, false, "Has a simple label with text in it." )

end
concommand.Add( “vguiexample_DPropertySheet”, Example_PropertySheet )[/lua]

Just type ‘vguiexample_DPropertySheet’ into your console to test it.

I hope this helps, and I apologize if you have any errors while testing, I haven’t gotten the chance to do it myself yet.

I have also used wiki a lot.

But i could’t find how to set text.

btw, thanks :slight_smile:

Do you know how to open the menu by preesing F1?

That’s even easier :slight_smile:

Make sure you place this code somewhere in a server-side file. (Like init.lua or something)

[lua]-- This is the hook called when you press F1
function GM:ShowHelp( pl )

-- Run the console command you want, Example:
pl:ConCommand( "vguiexample_DPropertySheet" )

end

– Called when you press F2
function GM:ShowTeam( pl )
end

– F3
function GM:ShowSpare( pl )
end

– F4
function GM:ShowSpare2( pl )
end[/lua]

Okay, thanks :slight_smile:
Do you know a better place to learn lua, than wiki?
You seems like a person who knows a lot of it.

Or, where have you learned it? :smiley:

I learned through the wiki, the Lua-bin, and others’ code.

And this thread will always guide you, even if it’s not your first time reading it.

Also, remember that learning things takes time, patience will help you learn faster.