https://github.com/mysterypancake/gmod-binding
Button binding for Garry's Mod
https://github.com/mysterypancake/gmod-binding
addon bind binding garry-mod garrys-mod garrysmod garrysmod-addon glua gmod gmod-lua lua
Last synced: 3 months ago
JSON representation
Button binding for Garry's Mod
- Host: GitHub
- URL: https://github.com/mysterypancake/gmod-binding
- Owner: MysteryPancake
- License: unlicense
- Created: 2017-04-17T07:11:18.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-07T04:59:20.000Z (over 6 years ago)
- Last Synced: 2025-05-13T00:39:38.281Z (5 months ago)
- Topics: addon, bind, binding, garry-mod, garrys-mod, garrysmod, garrysmod-addon, glua, gmod, gmod-lua, lua
- Language: Lua
- Homepage:
- Size: 20.5 KB
- Stars: 18
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Garry's Mod Binding
This is a simple script that lets you create bindings for [keys](https://wiki.garrysmod.com/page/Enums/KEY), as well as [mouse](https://wiki.garrysmod.com/page/Enums/MOUSE) and [controller](https://wiki.garrysmod.com/page/Enums/JOYSTICK) buttons.
It only works clientside, since on serverside you can use [the numpad library](http://wiki.garrysmod.com/page/Category:numpad).Use it for whatever you want, and have fun!
## Example Usage
### Adding a binding:
```
bind.Add( KEY_R, "", function()
notification.AddLegacy( "This script works!", NOTIFY_GENERIC, 2 )
end )
```
### Adding a mouse binding:
```
bind.Add( MOUSE_LEFT, "", function()
notification.AddLegacy( "Left clicked!", NOTIFY_GENERIC, 2 )
end )
```
### Removing a binding:
```
bind.Remove( KEY_R, "" )
```
### Printing all the bindings:
```
PrintTable( bind.GetTable() )
```## Lite Version
For people who only want to bind a single key.
```
local FirstPressed = falsehook.Add( "Think", "CallBinding", function()
local cache = input.IsButtonDown( )
if cache and FirstPressed then
end
FirstPressed = not cache
end )
```