Help! TypeError: %c requires int or char

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
derpmister1234
Newbie
Posts: 5
Joined: Sat Apr 27, 2019 12:37 pm
Contact:

Help! TypeError: %c requires int or char

#1 Post by derpmister1234 »

Hi, I've been working on a silly little visual novel to help me learn the ins and outs of renpy. And I've encountered an issue that I can't find a solution for.

Here's my code. When I run the game up to the point of the first menu coming up, it gives me the following error message:

"Line 61 in script
menu
TypeError: %c requires int or char"

I have no idea what this means!

I've tried everything and I don't know what is upsetting the game!
Help would be greatly appreciated thank you ^^

Code: Select all

 init:
    $ sy = Character("Sylvester", color="#CC0000", what_color="#CC0000")
    $ l  = Character("Laurence", color="#3399CC", what_color="#3399CC")
    $ w = Character("Walter", color="#FFFFFF", what_color="#FFFFFF")
    $ wi = Character("William", color="#0000ffff", what_color="#0000ffff")
    $ m = Character("Marcel", color="#CC3399", what_color="CC3399")
    define c = Character("Customer")
    $ mys = Character("???")]


label start:
 init:
     $ lpsy = 0
     $ lpl = 0
     $ lpw = 0
     $ lpwi = 0
     $ lpwi = 0
     $ lpm = 0
 "Welcome to the game!"
 "Quick tutorial:"
 "Perfoming actions within my game will use time. Time is limited, of course, so try to use it well!"
 "At work, You must deal with customers. This means memorising their orders. Usually this is a simple task, however there are exceptions."
 scene alarm
 show phone at top
 m "{i} I'm late, judging by the boss' passive aggressive messages. {/i}"
 m "{i} Ugh... Monday. It's gonna be busy today. {/i}"
 "You reluctantly worm your way out of bed and get dressed."
 m "{i} I better get going. {/i}"
 scene cafe with fade
 show clock8 at right
 show monday at left
 "You walk behind the counter and wait. It's early morning so you figure that it will get busy soon."
 "As you are thinking this, a customer waltzes in. This man looks so pissed and you wonder if he's gonna what some complicated-ass coffee"
 show acustomer
 c "I WANT A COFFEE RIGHT NOW YOU SKINNY. SKIM MILK, PINCH OF SUGAR, A LOT OF FOAM AND MAKE SURE THE BEANS ARE ETHICALLY SOURCED."
 m "{i} OH GOD. I have to remember this damn order… {/i}"
 scene kitchen with fade
 "You walk into the kitchen, walk up to the coffee machine and pick out a pack of beans."
 m "What beans do you choose?"
menu:
     "Mr Smith's 100% child labour beans":
        $ beans = "unethical"
        "You use Mr Smith's beans."
        "You go up to the fridge and pick out a jug of milk"
        $ unethical = True

        menu:
            "Choose skim milk":
                "You use skim milk"
                $ milk = skim
                "You go to the sugar dish and add a pinch of sugar to the coffee."
                $ skim = True

            "Choose full cream milk":
                "You use full cream milk"
                $ milk = "full"
                "You go to the sugar dish and add a pinch of sugar to the coffee."
                $ full = True


     "Nanna's ethical and epic beans":
            $ beans = "ethical"
            "You use Nanna's beans"
            "You go up to the fridge and pick out a jug of milk"
            $ ethical = True
            menu:
                "Choose skim milk":
                    "You use skim milk"
                    $ milk = "skim"
                    "You go to the sugar dish and add a pinch of sugar to the coffee."
                    $ skim = True

                "Choose full cream milk":
                    "You use full cream milk"
                    $ milk = "full"
                    "You go to the sugar dish and add a pinch of sugar to the coffee."
                    $ full = True



if ethical == True:
    scene cafe with dissolve
    show coffee
    show acustomer
    c "WOW! THIS IS EXACTLY WHAT I NEEDED! THANK YOU LANKY MAN!"
    "He seemed really pleased."
    return

if unethical == True:
    scene cafe with dissolve
    show coffeebad
    show customermad
    c "YOU FRICKED UP MY COFFEE FOR THE LAST TIME YOU FILTHY PIECE OF UNETHICAL DIRTY SCUM!"
    "The customer lunges at you at lightspeed, he leaps as agile as a cat and lands on top of you like an elephant, crushing you instantly."
    m "{i} I'm dead. {i}"
    scene wasted
    "Rip"
    return

Thanks a lot <3
Last edited by derpmister1234 on Sat Dec 14, 2019 12:33 pm, edited 2 times in total.

User avatar
Autumnotopia
Regular
Posts: 59
Joined: Sun May 19, 2019 8:53 pm
Completed: Making Friends
Tumblr: autumnotopiadev
Github: autumngreenley
itch: autumnotopia
Contact:

Re: Help! TypeError: %c requires int or char

#2 Post by Autumnotopia »

First of all, it may be helpful to people reading the thread if you wrap big chunks of code in a code tag! Otherwise it can be a little hard to read. (For example, your error says it's on line 61, but without line numbers it's hard to tell at a glance where the issue is)

Since I'm on my phone and can't check line numbers easily, here's a couple of issues I notice:

*'$ milk = skim' should have the word skim within quotation marks
*Your italics tags never close! Be sure to make the second {i} tag have a backslash (/i}

(for reference, you can use a code block by wrapping the section of code with these tags:)

Code: Select all

[code][/code ]
(and it'll look like that too!)
Image
A game about loneliness, chess, and fighting monsters with magic

derpmister1234
Newbie
Posts: 5
Joined: Sat Apr 27, 2019 12:37 pm
Contact:

Re: Help! TypeError: %c requires int or char

#3 Post by derpmister1234 »

Thanks for the reply ^^ I've done what you've said :)

Do you notice anything that could be causing the TypeError %c requires int or char thing?
Thank you :)

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Help! TypeError: %c requires int or char

#4 Post by Per K Grok »

derpmister1234 wrote: Sat Dec 14, 2019 11:45 am Hi, I've been working on a silly little visual novel to help me learn the ins and outs of renpy. And I've encountered an issue that I can't find a solution for.

Here's my code. When I run the game up to the point of the first menu coming up, it gives me the following error message:

"Line 61 in script
menu
TypeError: %c requires int or char"

I have no idea what this means!

-----

"Mr Smith's 100% child labour beans":
-----

% is a string format operator. If you want to use % in a string you need to write \% (or %%).


When you show your code in a post, use the code-tags (button marked</>). That will make it easier to read.


You are using 'init:' where I don't see a need for it.

when you define a variable use 'default' and do it before the labels.
define is used for constants, such as characters

Code: Select all

define sy = Character("Sylvester", color="#CC0000", what_color="#CC0000")
define l = Character("Laurence", color="#3399CC", what_color="#3399CC")
define w = Character("Walter", color="#FFFFFF", what_color="#FFFFFF")
define wi = Character("William", color="#0000ffff", what_color="#0000ffff")
define m = Character("Marcel", color="#CC3399", what_color="CC3399")
define c = Character("Customer")
define mys = Character("???")

default lpsy = 0
default  lpl = 0
default  lpw = 0
default  lpwi = 0
default  lpwi = 0
default  lpm = 0

label start:
    "Welcome to the game!"

User avatar
dGameBoy101b
Regular
Posts: 31
Joined: Sun Aug 12, 2018 8:32 am
itch: dgameboy101b
Contact:

Re: Help! TypeError: %c requires int or char

#5 Post by dGameBoy101b »

Try moving your nested menus to labelled sections of the script.

Code: Select all

label start:
	menu:
		"This is the outermost menu. Please select an option."
		"option 1":
			call option1
		"option 2":
			call option2
	"This is where the script continues after both choices have been made"
	return
label option1:
	menu:
		"You chose the first option of the first menu. Now choose another option."
		"option 1-1":
			call option1_1
		"option 1-2":
			call option1_2
	"This is where option one ends."
	return
label option2:
	menu:
		"You chose the second option of the first menu. Now choose another option."
		"option 2-1":
			call option2_1
		"option 2-2":
			call option2_2
	"This is where option two ends."
	return
label option1_1:
	"You chose the first option of the second menu after the first option of the first menu."
	return
label option1_2:
	"You chose the second option of the second menu after the first option of the first menu."
	return
label option2_1:
	"You chose the first option of the second menu after the second option of the first menu."
	return
label option2_2:
	"You chose the second option of the second menu after the second option of the first menu."
	return
The error is probably coming from some internal code in the RenPy engine since the %c thing probably refers to string formatting which is trying to substitute a character variable into a string but got the wrong type of variable. So if you provide the full stack trace, we might be able to find where the error is in your code.

derpmister1234
Newbie
Posts: 5
Joined: Sat Apr 27, 2019 12:37 pm
Contact:

Re: Help! TypeError: %c requires int or char

#6 Post by derpmister1234 »

Thank you so much!! I couldn't find the problem for the life of me! Thank you for pointing this out :D

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot]