Skip to content

Commit d7a92b2

Browse files
authored
Update BetterMouseAndGamepad.lua
1 parent f00210c commit d7a92b2

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

BetterMouseAndGamepad.lua

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
--- MOD_NAME: Better Mouse And Gamepad
33
--- MOD_ID: BetterMouseAndGamepad
44
--- MOD_AUTHOR: [Kooluve]
5-
--- MOD_DESCRIPTION: V1.0.3 Make mouse and gamepad more efficient and easier to use. View "README.md" and "*.lua" file for all functions and settings.
5+
--- MOD_DESCRIPTION: [V1.0.4] Make mouse and gamepad more efficient and easier to use. View "README.md" and "*.lua" file for all functions and settings. https://github.com/Kooluve/Better-Mouse-And-Gamepad
66
----------------------------------------------
77
------------MOD CODE -------------------------
88

@@ -91,6 +91,8 @@ R_cursor_up = {T = {x=0, y=0}, target = nil, time = 0.1, handled = true}
9191
M_clicked = {handled = true}
9292
M_cursor_down = {handled = true}
9393
M_cursor_up = {handled = true}
94+
Game_last_state = G.STATES.SPLASH
95+
Game_state_change_to_selecting_hand = false --prevent repetitive playing card and discarding
9496

9597
--------------------------------------------------
9698
------------LOVE2D FUNCTION REWRITING-------------
@@ -169,6 +171,14 @@ local update_ref = Controller.update
169171
function Controller.update(self, dt)
170172
update_ref(self, dt)
171173

174+
if Game_last_state ~= G.STATES.SELECTING_HAND and G.STATE == G.STATES.SELECTING_HAND then
175+
Game_state_change_to_selecting_hand = true
176+
end
177+
if Game_last_state == G.STATES.SELECTING_HAND and G.STATE ~= G.STATES.SELECTING_HAND then
178+
Game_state_change_to_selecting_hand = false
179+
end
180+
Game_last_state = G.STATE
181+
172182
if R_cursor_queue then
173183
R_cursor_press(R_cursor_queue.x, R_cursor_queue.y)
174184
R_cursor_queue = nil
@@ -427,20 +437,22 @@ end
427437

428438
function queue_U_wheel_press()
429439
if C.locks.frame or not mod_functions_can["middle_mouse_button_up"] then return end
430-
if not G.SETTINGS.paused and G.STATE == G.STATES.SELECTING_HAND then
440+
if not G.SETTINGS.paused and G.STATE == G.STATES.SELECTING_HAND and Game_state_change_to_selecting_hand and C.cursor_down.target.states.drag.is == false then
431441
local play_button = G.buttons:get_UIE_by_ID('play_button')
432442
if play_button and play_button.config.button then
433443
G.FUNCS.play_cards_from_highlighted()
444+
Game_state_change_to_selecting_hand = false
434445
end
435446
end
436447
end
437448

438449
function queue_D_wheel_press()
439450
if C.locks.frame or not mod_functions_can["middle_mouse_button_down"] then return end
440-
if not G.SETTINGS.paused and G.STATE == G.STATES.SELECTING_HAND then
451+
if not G.SETTINGS.paused and G.STATE == G.STATES.SELECTING_HAND and Game_state_change_to_selecting_hand and C.cursor_down.target.states.drag.is == false then
441452
local discard_button = G.buttons:get_UIE_by_ID('discard_button')
442453
if discard_button and discard_button.config.button then
443454
G.FUNCS.discard_cards_from_highlighted()
455+
Game_state_change_to_selecting_hand = false
444456
end
445457
end
446458
end

0 commit comments

Comments
 (0)