From 868e729d68b5913716bfe5ddb512f4099851e9a2 Mon Sep 17 00:00:00 2001 From: Apickx Date: Mon, 28 Dec 2015 19:18:30 -0500 Subject: Initial commit --- gamemode/cl_various/input.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 gamemode/cl_various/input.lua (limited to 'gamemode/cl_various/input.lua') 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 -- cgit v1.2.3-70-g09d2