Character definitions not working

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
RewindTheGame
Regular
Posts: 62
Joined: Thu Dec 31, 2020 3:37 pm
Contact:

Character definitions not working

#1 Post by RewindTheGame »

Suddenly, some character definitions aren't working in my game for no reason at all. Does anyone have any idea what could cause this? At the top of my code, I have this:

Code: Select all

define kantrell = Character("Kantrell")
define marie = Character("Marie")
Then, later in the code I have:

Code: Select all

marie "Hello, Kantrell."
kantrell "Hello, Marie."
When I run this, I get an error saying that "sayer kantrell is not a function or string". It's apparently fine with marie, but kantrell it can't cope with. I can see no logical reason why it would do this. Ideas please?

Edited to put in the correct inline code tags.
Last edited by RewindTheGame on Tue Jan 12, 2021 5:05 pm, edited 2 times in total.

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Character definitions not working

#2 Post by RicharDann »

c tags are for single line code, if you want to show a code block you have to use code and /code tags.

As for your question, the code you presented seems fine, but you perhaps have another variable somewhere with the same name, or accidentally overwrite it?
That's the only reason I can think that error would show up. For example:

Code: Select all

define kantrell = Character("Kantrell")

label start:
    $ kantrell = 0 #or some other object other than a string or Character instance
    kantrell "Hello" 
That would overwrite the value of kantrell variable, which wouldn't be a Character or a string anymore, as dialogue statements expect.
The most important step is always the next one.

RewindTheGame
Regular
Posts: 62
Joined: Thu Dec 31, 2020 3:37 pm
Contact:

Re: Character definitions not working

#3 Post by RewindTheGame »

You know, that's exactly what I'd done. Duh. I wasn't thinking about character definitions and variables as the same thing. Cheers!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]