# Debug: Print the contents of the OSC In DAT
print([cell.val for cell in row])
# Iterate through the rows of the OSC In DAT
# Ensure row has at least one column to avoid index errors
print("Row does not have enough columns:", row)
# Split the single cell value into address and message content
data = row[0].val.split(' ', 1)
print("Row does not contain a valid address and message:", row)
address = data[0] # OSC address (e.g., '/angel_words')
words = data[1].strip('""') # OSC message content (e.g., 'word1, word2, word3')
# Debug: Print address and words
print(f"Address: {address}, Words: {words}")
# Determine which category's table to update based on the address
if address == '/angel_words':
target_table = op('angel_table')
elif address == '/hero_words':
target_table = op('hero_table')
elif address == '/feminist_words':
target_table = op('feminist_table')
elif address == '/rebel_words':
target_table = op('rebel_table')
print(f"Unrecognized OSC address: {address}")
continue # Ignore unrecognized addresses
# Debug: Print the target table name
print(f"Target Table: {target_table.name}")
# Update the target table with the words
words_list = words.split(', ') if words.strip() else [] # Split the words into a list
random_words = random.sample(words_list, 3) # Randomly pick exactly 3 words
random_words = words_list # If 3 or fewer words, take all
target_table.clear() # Clear the current contents of the table
# Fill the table with the new words
for word in random_words:
target_table.appendRow([word])
# Debug: Print the contents of the updated table
print(f"Updated {target_table.name} contents:")
for table_row in target_table.rows():
print([cell.val for cell in table_row])
# Call the update_text function to update the Text TOP
op('update_text_script').run()