numpad.Register
From GMod Wiki
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: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Numpad.Register]Numpad.Register [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Example
Description | When 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 on | |
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" ) |
Output | N/A |
Additional Notes
- The name argument is a string literal that identifies the function and must be unique from all other functions registered with numpad.Register.
- The func is the function to be called, or nil if you wish to remove the function for whatever reason. When called by the numpad library, it will be passed a reference to the Player that made a key press or key release event, as well as any arguments passed in the call to numpad.OnDown or numpad.OnUp and the unique ID of the player as obtained from a call to Player.UniqueID.