- Oct 25, 2019
- 1,359
- 1,784
I want to be able to make data sheets like this in my renpy game but no idea where to start or what the coding would be.
I am once again asking help from this great community thank you for any help you can render.
And what make you say this ?That was 100% percent done in Photoshop/GIMP/Any decent photo editor.
screen bio( char ):
add "images/background/leaf.png"
hbox:
add ( "images/bio/{}.png".format( char.name ) )
null width 30
vbox:
for ( field, attr ) in [( "name", "name" , ( "nickname(s)", "nick" ), [...] ]:
hbox:
text ( "{b}" + field + ":{b}" )
null width 5
text ( "{}".format( getattr( char, attr ) ) )
imagebutton:
xalign 0.9
yalign 0.4
idle "gui/back.png"
action Return()
label whatever:
call screen bio( thisChar )
thats seem right but then again ive never done anything like it but I've seen plenty of games doing it and i wanted to add something to it as well with that being said do you think you could break down the explanation more?And what make you say this ?
I mean, something like:
Would give the result shown by his screenshot.Code:screen bio( char ): add "images/background/leaf.png" hbox: add ( "images/bio/{}.png".format( char.name ) ) null width 30 vbox: for ( field, attr ) in [( "name", "name" , ( "nickname(s)", "nick" ), [...] ]: hbox: text ( "{b}" + field + ":{b}" ) null width 5 text ( "{}".format( getattr( char, attr ) ) ) imagebutton: xalign 0.9 yalign 0.4 idle "gui/back.png" action Return() label whatever: call screen bio( thisChar )
[...] with that being said do you think you could break down the explanation more?
screen bio( char ):
char
will be an as yet unspecified class created by the developer.add "images/background/leaf.png"
hbox:
add ( "images/bio/{}.png".format( char.name ) )
/images/bio/
folder. The filename will be derived from the variable/class char
passed to the screen with .png
added.null width 30
vbox:
for ( field, attr ) in [( "Name", "name" ), ( "Nickname(s)", "nick" ), [...] ]:
field
. The second element will be known as attr
.field
= "Name", attr
= "name"field
= "Nickname(s)", attr
= "nick"hbox:
text ( "{b}" + field + ":{b}" )
field
as a text
box. The value will be shown in bold.null width 5
text ( "{}".format( getattr( char, attr ) ) )
getattr()
to go get the values from our, as yet, unspecified class. Using a combination of the char
parameter passed to the screen and the attr
local variable that is part of this loop. This all presumes that the class that contains all the information includes fields called "name, "nick", "role", "age", etc.imagebutton:
action Return()
.label whatever:
call screen bio( thisChar )
char
within the screen.screen:
for each and every character you have in game.default ju_bio = ...
because I am assuming that some of this info might change as the game progresses (mainly the "fullbio" data, though I guess someone could have a birthday too). If this information is fixed and will never change while the game is being played... you would use define ju_bio = ...
instead.hbox
and vbox
cells are notoriously awful to size in way that makes sense to you - because they auto-size according to their contents, but the contents can often not be sized. If there's an easy way... I haven't figured it out yet.