I also tried this:
Code: Select all
image x:
choice( gender == "Female"):
'characters/You_F_Speak_Left.png'
choice( gender == "Male"):
'characters/You_M_Speak_Left.png'
but it throws up this
Code: Select all
I'm sorry, but an uncaught exception occurred.
Compiling ATL code at game/images.rpy:28
NameError: name 'gender' is not defined
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "C:\Users\Admin\Documents\Work in Progress\0 Robin Projects\renpy-7.0.0-sdk\renpy\bootstrap.py", line 316, in bootstrap
renpy.main.main()
File "C:\Users\Admin\Documents\Work in Progress\0 Robin Projects\renpy-7.0.0-sdk\renpy\main.py", line 519, in main
renpy.atl.compile_all()
File "C:\Users\Admin\Documents\Work in Progress\0 Robin Projects\renpy-7.0.0-sdk\renpy\atl.py", line 231, in compile_all
i.compile()
File "C:\Users\Admin\Documents\Work in Progress\0 Robin Projects\renpy-7.0.0-sdk\renpy\atl.py", line 489, in compile
block = self.atl.compile(self.context)
File "C:\Users\Admin\Documents\Work in Progress\0 Robin Projects\renpy-7.0.0-sdk\renpy\atl.py", line 684, in compile
statements = [ i.compile(ctx) for i in self.statements ]
File "C:\Users\Admin\Documents\Work in Progress\0 Robin Projects\renpy-7.0.0-sdk\renpy\atl.py", line 1384, in compile
return Choice(self.loc, [ (ctx.eval(chance), block.compile(ctx)) for chance, block in self.choices])
File "C:\Users\Admin\Documents\Work in Progress\0 Robin Projects\renpy-7.0.0-sdk\renpy\atl.py", line 246, in eval
return eval(expr, renpy.store.__dict__, self.context) # @UndefinedVariable
File "<string>", line 1, in <module>
NameError: name 'gender' is not defined
Windows-7-6.1.7601-SP1
Ren'Py 7.3.5.606
Slave Maker Revenge 1.1
Sat Feb 22 19:45:15 2020
I have my .rpy files in sections to make it easier for me to see where I am. This was mentioned as being okay to do in another post somewhere.
My .rpy files in the order they run as far as this bit is concerned is:
script.rpy which takes me to
char_selection.rpy where you choose your gender and name them, which leads to
story_intro.rpy where the background story is explained to the new player which leads to
office.rpy where the character is briefed by their boss as to their mission, which is the point of the game.
The images are stored in
images.rpy which is where the very first code above is stored.
Additionally, characters are laid out in
character.rpy, and every scene has its own .rpy file, for example
hotel.rpy
So it's telling me that
NameError: name 'gender' is not defined. I thought that it was defined when I first added the menu as seen in the original post.
Code: Select all
menu:
'Male':
$ gender = "Male"
'Female':
$ gender = "Female"
jump test
Because I was able to then add
Code: Select all
label test:
scene gendertest
if gender == "Female":
o "I'm a woman"
else:
o "I'm a man"
and it worked. So where have I erred?
I apologize if I have bent the rules, but I believe this is pertinent to the original question.
What, spy on our spy as he searches for their spy? Why not, sounds rather like fun.