Problems calling array in text - index is unicode?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
DoubleProlix
Regular
Posts: 33
Joined: Thu Oct 19, 2017 8:04 pm
Contact:

Problems calling array in text - index is unicode?

#1 Post by DoubleProlix »

I'm trying to use a simple list to store the days of the week, cycling through them with an index. However, when I try and display the current day's name, I get an error, "list indices must be integers, not unicode."

Here's my code:

Code: Select all

init:
    $ day = 1
    python:
        dayName = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]

label start:
            
        if day >4:
            "It's the weekend. How do you want to spend your day?"
        else:
            "[dayName[day]]. An unfulfilling day at the office comes to an end. What do you want to do?"
            
return
I'm assuming that somehow Ren'Py is turning day into the unicode for 1 instead of reading it as an integer? Is there some trick to using arrays within text?
Current Project: Thaumarotica - an occult erotic thriller
SubscribeStar - Patreon - Itch.io

philat
Eileen-Class Veteran
Posts: 1895
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Problems calling array in text - index is unicode?

#2 Post by philat »


DoubleProlix
Regular
Posts: 33
Joined: Thu Oct 19, 2017 8:04 pm
Contact:

Re: Problems calling array in text - index is unicode?

#3 Post by DoubleProlix »

Awesome, thanks.
Current Project: Thaumarotica - an occult erotic thriller
SubscribeStar - Patreon - Itch.io

Post Reply

Who is online

Users browsing this forum: Google [Bot]