- Sep 7, 2017
- 694
- 4,185
Trying to take advantage of renpy's replay mode and I've gotten many errors, corrected few, and am down to what I believe may be the last one needing a fix.
Here is the traceback
At first, I was getting a Maximum Recursion Depth error, then I saw a post by anne O'nymous in regards to player name setup using text substitution and fixed that error.
However, now I am getting the one above.
Here is the code used for my character setup now.
Thank you all in advanced.
Here is the traceback
Code:
[code]
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 1642, in script
"But what Claire was unaware of was the fact that just a moment ago, someone had entered the shower room."
KeyError: u'cname'
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 1642, in script
"But what Claire was unaware of was the fact that just a moment ago, someone had entered the shower room."
File "renpy/ast.py", line 715, in execute
renpy.exports.say(who, what, *args, **kwargs)
File "renpy/exports.py", line 1384, in say
who(what, *args, **kwargs)
File "renpy/character.py", line 1164, in __call__
what = what_pattern.replace("[what]", sub(what, translate=True))
File "renpy/character.py", line 1153, in sub
return renpy.substitutions.substitute(s, scope=scope, force=force, translate=translate)[0]
File "renpy/substitutions.py", line 270, in substitute
s = formatter.vformat(s, (), kwargs)
File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/string.py", line 563, in vformat
File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/string.py", line 596, in _vformat
File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/string.py", line 613, in format_field
File "renpy/character.py", line 1049, in __format__
return format(str(self), spec)
File "renpy/character.py", line 1032, in __unicode__
return renpy.substitutions.substitute(who)[0]
File "renpy/substitutions.py", line 270, in substitute
s = formatter.vformat(s, (), kwargs)
File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/string.py", line 563, in vformat
File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/string.py", line 585, in _vformat
File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/string.py", line 646, in get_field
File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/string.py", line 605, in get_value
KeyError: u'cname'
Windows-10-10.0.19041
Ren'Py 7.4.2.1292
Because I Love Her Version_1.0
Mon Sep 27 18:34:58 2021
At first, I was getting a Maximum Recursion Depth error, then I saw a post by anne O'nymous in regards to player name setup using text substitution and fixed that error.
However, now I am getting the one above.
Here is the code used for my character setup now.
Code:
init python:
import re
def word_replace(text):
"""
take a text and replace words that match the key in a dictionary
with the associated value, return the changed text
"""
def translate(match):
word = match.group(0)
return replace_dict.get(word, word)
return re.sub(r"\b[A-Za-z_]\w*\b", translate, text)
init python:
# create a dictionary of key_word:replace_with pairs
replace_dict = {
"John" : "[n]",
"JOHN" : "[n]",
"john" : "[n]",
"Claire" : "[c]",
"CLAIRE" : "[c]",
"claire" : "[c]",
}
define config.say_menu_text_filter = word_replace
# Declare characters used by this game. The color argument colorizes the
# name of the character.
define n = Character("[nname]", color="#CCFFFF")
define c = Character("[cname]", color="#FF00CC")
define o = Character("Olivia", color="#FF0033")
define j = Character("Jenni", color="#6600FF")
define nar = Character("Narrator", color="#00FFCC")
define t = Character("Thinking")
define man1 = Character("Man")
define man2 = Character("Man2")
define man3 = Character("Man3")
define v = Character("Voice", color="#CC0033")
define s = Character("Server", color="#FFCCFF")
define a = Character("Abigail", color="#FF9933")
define d = Character("Damon", color="#CCCCCC")
define b = Character("Darryl")
define ct = Character("Claire's Thoughts", color="#FF00CC")
define k = Character("Krystal", color="#FF9933")
define r = Character("Rose", color="#CCCCCC")
define jas = Character("Jason",color="#CCCCCC")
define girl = Character("Woman",color="#FF0033")
define bt = Character("Bartender",color="#FF9933")
define g = Character("Autumn", color="#FF9933")
define anna = Character("Anna", color="#FF0033")
define king = Character("King", color="FFC48E")
define dust = Character("Dustin", color="#F4D2F4")
define h = Character("H", color="#F4D2F4")
label start:
$ jennilust = 0
$ jennilove = 0
$ clairelove = 0
$ clairelust = 0
$ goodbf = 0
$ badbf = 0
scene downtown
$ nname = renpy.input("What is your name?")
$ nnname = nname.strip()
if nname == "":
$ nname="John"
$ cname = renpy.input("What is your fiances name?")
$ cname = cname.strip()
if cname == "":
$ cname="Claire"