From d1eec61e5c41f2c96325ff6315ed60e7f0987f53 Mon Sep 17 00:00:00 2001 From: astrofra Date: Tue, 16 Aug 2022 21:29:32 +0200 Subject: [PATCH] Fixed a series of array out bounds errors (Lua -> Python typical issues). --- src/animations.py | 2 +- src/main.py | 4 ++-- src/walkman.py | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/animations.py b/src/animations.py index bd11e1e..909400c 100644 --- a/src/animations.py +++ b/src/animations.py @@ -8,7 +8,7 @@ def anim_player(scene, anims, anim_has_started, playing_anim, current_anim): else: if playing_anim is None or scene.IsPlaying(playing_anim) == False: current_anim = current_anim + 1 - if current_anim > len(anims): + if current_anim >= len(anims): current_anim = 0 # end playing_anim = scene.PlayAnim(scene.GetSceneAnim(anims[current_anim])) diff --git a/src/main.py b/src/main.py index ee59c4e..97d3f19 100644 --- a/src/main.py +++ b/src/main.py @@ -230,7 +230,7 @@ def main(): walkman_button_pressed = -1 walkman_button_pressed_timeout = hg.GetClock() walkman_buttons_nodes = [] - for i in range(3): + for i in range(4): nd = scene.GetNode("walkman_click_zone_" + str(i)) if nd.IsValid(): walkman_buttons_nodes.append(nd) @@ -257,7 +257,7 @@ def main(): "riddlemak_ia", ], "durations":[], - "current_song_idx":1, + "current_song_idx":0, "current_song_timestamp":-1, "repeat_mode":False, "song_ref":None diff --git a/src/walkman.py b/src/walkman.py index 7c1f414..451b900 100644 --- a/src/walkman.py +++ b/src/walkman.py @@ -12,10 +12,10 @@ # riddlemak "AI" # button index -> walkman def (play, stop, ...) -WALKMAN_PREV = 1 -WALKMAN_PLAY = 2 -WALKMAN_NEXT = 3 -WALKMAN_MODE = 4 +WALKMAN_PREV = 0 +WALKMAN_PLAY = 1 +WALKMAN_NEXT = 2 +WALKMAN_MODE = 3 # map the song title to the vertical position # in the songs titles textures @@ -69,7 +69,7 @@ def hover_objects_test(objects_list, camera, resolution, mouse_position, object_ def get_hovered_button(scene, buttons, mouse_pos, resolution, lines=[]): idx, button_hover, lines = hover_objects_test(buttons, scene.GetCurrentCamera(), resolution, mouse_pos, 0.4, lines) if button_hover is not None: - # print("button " + idx) + # print("button " + str(idx)) return idx, lines # end @@ -236,10 +236,10 @@ def song_player_update(song_player, walkman_osd, walkman_button_change_state, wa # end # wrap around the music index - if song_player["current_song_idx"] > len(song_player["titles"]): - song_player["current_song_idx"] = 1 - elif song_player["current_song_idx"] < 1: - song_player["current_song_idx"] = len(song_player["titles"]) + if song_player["current_song_idx"] > len(song_player["titles"]) - 1: + song_player["current_song_idx"] = 0 + elif song_player["current_song_idx"] < 0: + song_player["current_song_idx"] = len(song_player["titles"]) - 1 # end # autopress PLAY if PREV/NEXT where pressed