Skip to content

Commit

Permalink
Fixed a series of array out bounds errors (Lua -> Python typical issu…
Browse files Browse the repository at this point in the history
…es).
  • Loading branch information
astrofra committed Aug 16, 2022
1 parent bfc2280 commit d1eec61
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/animations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
4 changes: 2 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/walkman.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d1eec61

Please sign in to comment.