Skip to content

Commit dec6670

Browse files
author
madalee-com
committed
- Fix issue causing clip show to get stuck on one user and have other issues
- Fix issue causing clipshow to be broken entirely - Made clip show try to better spread out clips among users. Shuffles a list, draws a user, repeats until the deck is empty, reshuffles deck. This can result in a user getting their clip played twice in a row on occasion.
1 parent ad5d0fa commit dec6670

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/commands.gd

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ var recent_raider = ""
135135
var clip_show_running = false
136136
# Flag to track if self clip show is running
137137
var self_clip_show_running = false
138+
# Keeps a list of which users are pending play in clip show, to prevent repeats
139+
var pend_clip_show_users = []
138140

139141

140142
## Main process function that handles frame timing and animation updates
@@ -854,7 +856,7 @@ func get_random_clip_url(username: String) -> TwitchClip:
854856
var so_user: TwitchUser
855857
so_user = await Twitch.get_user(username)
856858
if so_user == null:
857-
logger.log("Couldn't get shoutout for user: %s" % username)
859+
logger.log("Couldn't get data for user: %s" % username)
858860
return
859861
# Fetch a list of clips for the user
860862
var clips: TwitchGetClips.Response
@@ -873,6 +875,8 @@ func get_random_clip_url(username: String) -> TwitchClip:
873875
return null
874876
logger.log_debug("Got clips for user: %s and stored in clip cache" % username)
875877
user_clips[username] = { "unplayed": clips.data, "played": [] }
878+
if !pend_clip_show_users.is_empty():
879+
pend_clip_show_users.append(username)
876880

877881
# Pick a random clip from the list
878882
if user_clips[username].unplayed.is_empty():
@@ -1228,12 +1232,12 @@ func add_random_clip_from_cache(count: int = 1):
12281232
for each in count:
12291233
if user_clips.is_empty():
12301234
return
1231-
var cur_user_clips = user_clips[user_clips.keys().pick_random()]
1232-
var cur_user
1233-
if cur_user_clips.unplayed.is_empty():
1234-
cur_user = cur_user_clips.played[0].display_name
1235-
else:
1236-
cur_user = cur_user_clips.unplayed[0].display_name
1235+
var cur_user = user_clips.keys().front()
1236+
if user_clips.size() > 1:
1237+
if pend_clip_show_users.is_empty():
1238+
pend_clip_show_users = user_clips.keys().duplicate()
1239+
cur_user = pend_clip_show_users.pick_random()
1240+
pend_clip_show_users.erase(cur_user)
12371241
await add_random_clip(cur_user)
12381242

12391243

@@ -1447,6 +1451,8 @@ func _on_stop_clip_show_command_received(_from_username: String, _info: TwitchCo
14471451
if %UseStopClipShowCmd.button_pressed:
14481452
clip_show_running = false
14491453
self_clip_show_running = false
1454+
pend_clip_show_users = []
1455+
logger.log("Stopping clip show")
14501456

14511457

14521458
## Handles the event when a self clip show command is received.

0 commit comments

Comments
 (0)