how to pass a variable to the call screen function? [solved]
Posted: Sun Nov 08, 2020 7:13 am
Hello!
It's me again.
How do I pass a variable to the call screen character_sheet function?
I'd like to give a variable containing the character's info that should be displayed at the screen.
Here's the code:
(contasinms story spoilers)
It's me again.
How do I pass a variable to the call screen character_sheet function?
I'd like to give a variable containing the character's info that should be displayed at the screen.
Here's the code:
(contasinms story spoilers)
Code: Select all
# The script of the game goes in this file.
# Declare characters used by this game. The color argument colorizes the
# name of the character.
# Class for managing PC and NPC stats:
init python:
import random
class MyCharacter(ADVCharacter):
def __init__(self, name, char_dict, color='#FFA500'):
ADVCharacter.__init__(self, name, color='#FFA500')
self.name = name
self.nickname = char_dict['nickname']
self.age = char_dict['age']
self.affiliation = char_dict['affiliation']
self.personality = char_dict['personality']
self.likes = char_dict['likes']
self.dislikes = char_dict['dislikes']
self.skills = char_dict['skills']
self.quirks = char_dict['quirks']
self.dreams = char_dict['personality']
self.fears = char_dict['fears']
self.family = char_dict['family']
self.character_background = char_dict['background']
def say_random_phrase(self):
return "bla bla bla"
# creating npcs
#TODO: Add Nicknames!
makoto_dict = {'age': 'in her mid twenties',
'nickname': 'the sergeant',
'affiliation':'Trails End Military',
'personality':'honest, strict, rational, no sense of humour, religious',
'likes':'training, market days',
'dislikes':['chaos', 'laziness'],
'skills':['fencing', 'shooting', 'riding'],
'quirks':['can not dance'],
'dreams':['retirement'],
'fears':['to suffer grave injuries', 'failing to protect her subordinates in battle'],
'family':['None'],
'secrets':['None'],
'background':['Makoto says she comes from ?? and joined the military there.','She got promoted sergeant in the revolution wars.', "She's living in Trails End for about 2 years now."]
}
joanna_dict = {'age': '19',
'nickname': 'Drummer',
'affiliation':'Trails End Military',
'personality':'usually cheerful and open-minded, but the horrors she saw calmed her down quite a bit',
'likes':'taking care of the military's animals',
'dislikes': 'Rain',
'skills':['fencing', 'playing drums'],
'quirks':['staring into the air'],
'dreams':['a future outside the military, founding a family'],
'fears':['bleeding to death on the battlefield'],
'family':['Parents, 3 brothers, 1 sister'],
'secrets':['she has a crush on Hakim''],
'background':["Joanna's parents are farmers, she spend a lot of time herding sheep before joining the military during the revolution."]
}
nelly_dict = {}
makoto = MyCharacter('Makoto Martins', makoto_dict, color='#FFA500')
joanna = MyCharacter('Joanna Pfeifer', joanna_dict, color='#99CC99')
define e = Character("Eileen")
define email_1 = "800 years of trade agreements"
# The game starts here.
label start:
# Show a background. This uses a placeholder by default, but you can
# add a file (named either "bg room.png" or "bg room.jpg") to the
# images directory to show it.
scene bg room
# This shows a character sprite. A placeholder is used, but you can
# replace it by adding a file named "eileen happy.png" to the images
# directory.
show eileen happy
# These display lines of dialogue.
e "You've created a new Ren'Py game."
makoto "Once you add a story, pictures, and music, you can release it to the world!"
label name:
$ povname = renpy.input("What is your name?")
$ povname = povname.strip()
if povname == "":
$ povname = "Jane"
else:
povname "My name is [povname]!"
e " Hello, [povname]! "
jump test
# This ends the game.
return
label test:
e "Last..."
#show screen character_sheet
call screen character_sheet(makoto)
e "... have a character sheet!"
e "..."
scene bg room
show eileen happy
e "It looks nice, right?"
#screen email_display(email):
# style_prefix "email_display"
# frame:
# area (10, 100, 200, 500) #xpos, ypos, width, height
# viewport:
# scrollbars "vertical"
# mousewheel True
# draggable True
# vbox:
# text '[email]'
screen character_sheet(character_obj):
modal False
zorder 100
add "sheet_of_old paper.png" xalign 0.0 yalign 0.0
add "nelly_small.png" xalign 0.75 yalign 0.5
hbox:
xalign 0.10
yalign 0.10
vbox:
xalign 0.10
yalign 0.10
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}[character_obj.name]{/color}{/font}"
null height 20
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}Age:??{/color}{/font}"
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}Birthday: ??{/color}{/font}"
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}Alignment: - {/color}{/font}"
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}Personality:{/color}{/font}"
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}Likes: ... {/color}{/font}"
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}Dislikes: ...{/color}{/font}"
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}Skills: ...{/color}{/font}"
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}Quirks: ... {/color}{/font}"
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}Dreams: ... {/color}{/font}"
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}Fears: ... {/color}{/font}"
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}Familiy: ... {/color}{/font}"
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}Secrets: ... {/color}{/font}"
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}Background:{/color}{/font}"
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}aaaa.{/color}{/font}"
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}bbbb.{/color}{/font}"
text "{font=CheGuevaraFancy-Regular.ttf}{color=#000033}ccc.{/color}{/font}"
textbutton _("Back") action [Hide("character_sheet"), Return()]
#imagebutton idle "images/your_image.png" hover "images/your_image.png" action [Hide("your_screen_name"), Return()]