string/lower

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Also menu state)
m
Line 3: Line 3:
 
|Realm=Shared and Menu
 
|Realm=Shared and Menu
 
|IsClass=No
 
|IsClass=No
|Name=lower
 
|Parent=string
 
 
}}
 
}}
 
{{Arg
 
{{Arg
Line 22: Line 20:
 
print( string.lower( "1234567890" ) )
 
print( string.lower( "1234567890" ) )
 
|Output=<br/>abcdefg<br/>abcdefg<br/>abcdefg<br/>1234567890
 
|Output=<br/>abcdefg<br/>abcdefg<br/>abcdefg<br/>1234567890
 +
}}
 +
{{Example
 +
|Description=Demonstrates opening a menu when !openmenu is typed in chat.
 +
|Code=local function myMenu()
 +
    local frame = vgui.Create( "DFrame" )
 +
frame:SetSize( 400, 400 )
 +
frame:Center()
 +
frame:MakePopup()
 +
end
 +
 +
hook.Add( "OnPlayerChat" , "AnyName" , function( ply, text )
 +
    if ply == LocalPlayer() then -- Makes sure its the local player
 +
        if string.lower( text ) == "!openmenu" then -- Checks if the player had wrote a chat message saying !openmenu
 +
            myMenu() -- Calling the local function to start
 +
        end
 +
    end
 +
end )
 +
|Output=When you type !openmenu in chat, the DFrame pops up.
 
}}
 
}}

Revision as of 03:13, 21 November 2016

 string.lower( )

Contents

Description

Changes any upper-case letters in a string to lower-case letters.

Arguments

string str

The string to convert.

Returns

string

A string representing the value of a string converted to lower-case.

Examples

Example

Demonstrates the use of this function.

print( string.lower( "ABCDEFG" ) )
print( string.lower( "AbCdefG" ) )
print( string.lower( "abcdefg" ) )
print( string.lower( "1234567890" ) )

Output:


abcdefg
abcdefg
abcdefg
1234567890

Examples

Example

Demonstrates opening a menu when !openmenu is typed in chat.

local function myMenu()
    local frame = vgui.Create( "DFrame" )
	frame:SetSize( 400, 400 )
	frame:Center()
	frame:MakePopup()
end

hook.Add( "OnPlayerChat" , "AnyName" , function( ply, text )
    if ply == LocalPlayer() then -- Makes sure its the local player
        if string.lower( text ) == "!openmenu" then -- Checks if the player had wrote a chat message saying !openmenu
            myMenu() -- Calling the local function to start
        end
    end
end )

Output:

When you type !openmenu in chat, the DFrame pops up.
Personal tools
Navigation