From 64f85ae4e9f28283a4204e67d9ff055af6a65be8 Mon Sep 17 00:00:00 2001 From: SweetSea-ButImNotSweet <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Fri, 17 May 2024 16:33:30 +0700 Subject: [PATCH] Update storeInput function --- game/gamemode.lua | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/game/gamemode.lua b/game/gamemode.lua index 17b5b05..4d459c8 100644 --- a/game/gamemode.lua +++ b/game/gamemode.lua @@ -289,16 +289,25 @@ end function GameMode:storeInput(input_set) - self.recorded_inputs[self.frames] = bit.bor( - input_set['right'] and 1 or 0, - input_set['rotate_right2'] and 2 or 0, - input_set['up'] and 4 or 0, - input_set['rotate_left'] and 8 or 0, - input_set['left'] and 16 or 0, - input_set['down'] and 32 or 0, - input_set['rotate_right'] and 64 or 0, - input_set['rotate_left2'] and 128 or 0 - ) + local input_code_list = { + right = 1 , + rotate_right2 = 2 , + up = 4 , + rotate_left = 8 , + left = 16 , + down = 32 , + rotate_right = 64 , + rotate_left2 = 128, + } + local current_frame_input = 0 + + for key, code in pairs(input_code_list) do + if input_set[key] then + current_frame_input = bit.bor(current_frame_input, code) + end + end + + self.recorded_inputs[self.frames] = current_frame_input end function GameMode:getReplayInputs(input_file) local i = 1