TypeError: coercing to 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
User avatar
Smaymay
Regular
Posts: 70
Joined: Fri Jul 01, 2016 11:35 am
Completed: Vicboys demo
Tumblr: esmmeh
Deviantart: Smaymay
Location: The Netherlands
Contact:

TypeError: coercing to Unicode

#1 Post by Smaymay »

Hi there! I've stumbled upon an error today and after changing up the syntax 100 times to fix it and some research I realised I need help haha. I have this screen with an awful lot of imagebuttons. I'm still using placeholder art atm so I will have to change their positions once I get the finished GUI. To save me a lot of time I thought why not use predefined positions? Here's a snippet of the code:

Code: Select all

    $ bakerypos = Position(xpos=589, ypos=143)
    $ bakerypos2 = Position(xpos=589, ypos=99)

Code: Select all

    imagebutton:
        idle "images/GUI/map/abigale_loc.png"
        if abigale_location == "bakery":
            if bakeryCharAmount == 2:
                pos ("bakerypos")
            else:
                pos ("bakerypos2")
But it gives me the folliwing error at pos ("bakerypos")

Code: Select all

TypeError: coercing to Unicode: need string or buffer, int found
I guess it's a syntax error? (My achilles' heel haha) The positions are numbers and not strings so if I understand correctly it can't convert a string to an int. But I don't know how I should write this down instead. Any thoughts? :)

User avatar
Queex
Regular
Posts: 46
Joined: Sat Mar 14, 2015 9:47 am
Contact:

Re: TypeError: coercing to Unicode

#2 Post by Queex »

I think you need to remove the quotes round the variable names:

pos(bakerypos)

When you put it in quotes, it's treated as a string, not a reference to the variable you've defined.

Post Reply

Who is online

Users browsing this forum: apocolocyntose, Google [Bot]