numpad.Register

From GMod Wiki

Jump to: navigation, search
Function
Syntax numpad.Register( String name, Function func )
Where is this used?
Description:
Registers a function with the numpad library for use with numpad.OnDown and numpad.OnUp.
Returns: nil
Part of Library: numpad
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Numpad.Register]Numpad.Register [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Example

DescriptionWhen you press down the 0 key on the number pad, the message "MingeBag called the example function with the argument: Pressed" will be written to the console. Keep in mind that it is not necessary to have the calls to numpad.Register and numpad.OnDown called in immediate succession, or even to have them in the same file.
Used onNewerServer.png
Code
function example_function( pl, arg1 )
    print( pl:Name().." called the example function with the argument: "..arg1 )
end
 
-- Register the function with the numpad library.
numpad.Register( "example_function", example_function )
 
-- Register the impulse with the numpad library.
numpad.OnDown( player.GetByID( 1 ), 0, "example_function", "Pressed" )
 
OutputN/A

Additional Notes

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox