diff options
| author | Apickx <Apickx@cogarr.org> | 2015-12-28 19:18:30 -0500 |
|---|---|---|
| committer | Apickx <Apickx@cogarr.org> | 2015-12-28 19:18:30 -0500 |
| commit | 868e729d68b5913716bfe5ddb512f4099851e9a2 (patch) | |
| tree | 6441108754145dfd68a6e23bea382b5cb1ab63d5 /gamemode/cl_various/input.lua | |
| download | gearfox-868e729d68b5913716bfe5ddb512f4099851e9a2.tar.gz gearfox-868e729d68b5913716bfe5ddb512f4099851e9a2.tar.bz2 gearfox-868e729d68b5913716bfe5ddb512f4099851e9a2.zip | |
Diffstat (limited to 'gamemode/cl_various/input.lua')
| -rw-r--r-- | gamemode/cl_various/input.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gamemode/cl_various/input.lua b/gamemode/cl_various/input.lua new file mode 100644 index 0000000..519dbaf --- /dev/null +++ b/gamemode/cl_various/input.lua @@ -0,0 +1,27 @@ +local B = {} +local A = {} + +function input.IsMouseInBox( x , y , w , h ) + local mx, my = gui.MousePos() + return (mx > x and mx < x+w and my > y and my < y+h) +end + +function input.IsInBox( x2 , y2 , x , y , w , h ) + return (x2 > x and x2 < x+w and y2 > y and y2 < y+h) +end + +function input.KeyPress(KEY,ID) + ID = ID or "" + if (input.IsKeyDown(KEY) and !IsChatOpen()) then + if (!A[KEY..ID]) then A[KEY..ID] = true return true + else return false end + elseif (A[KEY..ID]) then A[KEY..ID] = false end +end + +function input.MousePress(MOUSE,ID) + ID = ID or "" + if (input.IsMouseDown(MOUSE)) then + if (!B[MOUSE..ID]) then B[MOUSE..ID] = true return true + else return false end + elseif (B[MOUSE..ID]) then B[MOUSE..ID] = false end +end |
