Code: Select all
init python:
F01 = {
'name': 'Food01',
'recipe': ['orange','red','blue'],
'text': 'Item 01'
}
F02 = {
'name': 'Food02',
'recipe': ['blue', 'green', 'orange'],
'text': 'Item 02'
}
fooddic = {
'F01' : F01,
'F02' : F02
}
define n = Character("")
define x = 'recipe'
# The game starts here.
label start:
python:
for k, v in fooddic.items():
for key in v:
if key == x:
say(n,"Result: [key] [v[key]]", interact=True)
return
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 33, in script
python:
File "game/script.rpy", line 37, in <module>
say(n,"Result: [key] [v[key]]", interact=True)
File "renpy/common/00library.rpy", line 284, in say
who(what, interact=interact, *args, **kwargs)
KeyError: 'key'
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 33, in script
python:
File "S:\Program Files\Renpy\renpy-8.0.0-sdk\renpy\ast.py", line 1111, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "S:\Program Files\Renpy\renpy-8.0.0-sdk\renpy\python.py", line 1049, in py_exec_bytecode
exec(bytecode, globals, locals)
File "game/script.rpy", line 37, in <module>
say(n,"Result: [key] [v[key]]", interact=True)
File "renpy/common/00library.rpy", line 284, in say
who(what, interact=interact, *args, **kwargs)
File "S:\Program Files\Renpy\renpy-8.0.0-sdk\renpy\character.py", line 1240, in __call__
what = self.prefix_suffix("what", self.what_prefix, what, self.what_suffix)
File "S:\Program Files\Renpy\renpy-8.0.0-sdk\renpy\character.py", line 1159, in prefix_suffix
return (sub(prefix) + sub(body) + sub(suffix))
File "S:\Program Files\Renpy\renpy-8.0.0-sdk\renpy\character.py", line 1139, in sub
return renpy.substitutions.substitute(s, scope=scope, force=force, translate=translate)[0]
File "S:\Program Files\Renpy\renpy-8.0.0-sdk\renpy\substitutions.py", line 278, in substitute
s = formatter.vformat(s, (), kwargs) # type: ignore
File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python3.9/string.py", line 165, in vformat
File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python3.9/string.py", line 205, in _vformat
File "S:\Program Files\Renpy\renpy-8.0.0-sdk\renpy\substitutions.py", line 168, in get_field
obj, arg_used = super(Formatter, self).get_field(field_name, args, kwargs)
File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python3.9/string.py", line 278, in get_field
KeyError: 'key'
Windows-10-10.0.19043 AMD64
Ren'Py 8.0.0.22062402
DictionaryTesting 1.0
Fri Jul 1 13:46:56 2022