Adding Stats to Characters ... easily

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Message
Author
User avatar
badanni
Newbie
Posts: 9
Joined: Fri Jan 24, 2020 11:57 am
itch: badanni
Location: Quito, Ecuador
Contact:

Re: Adding Stats to Characters ... easily

#31 Post by badanni »

Code: Select all

image side addison = "addison.png"
define a = Avatar("name", image="addison")
on screen

Code: Select all

viewport:
                    scrollbars "vertical"
                    mousewheel True
                    grid columns rows:
                        transpose True
                        style_group "dropdown_gm2"
                        xfill True
                        ysize 300
                        spacing -10
                        $ i=0
                        vbox:
                                null height 30
                                $ name =party_i.name
                                $ level = party_i.level
                                $ job = party_i.job
                                $ job_level = party_i.jobs[job]["level"]
                                $ HP = party_i.HP
                                $ maxHP = party_i.base_HP+party_i.add_HP
                                $ MP = party_i.MP
                                $ maxMP = party_i.base_MP+party_i.add_MP
                                $ maxAttack=party_i.base_attack+party_i.add_attack
                                $ maxDefense=party_i.base_defense+party_i.add_defense
                                $ totalExp=party_i.exp_accumulated
                                $ base_attack=party_i.base_attack
                                $ add_attack=party_i.add_attack
                                $ base_defense=party_i.base_defense
                                $ add_defense=party_i.add_defense
                                $ base_magic=party_i.base_magic
                                $ add_magic=party_i.add_magic
                                $ base_resist=party_i.base_resist
                                $ add_resist=party_i.add_resist
                                $ base_agility=party_i.base_agility
                                $ add_agility=party_i.add_agility
                                $ base_luck=party_i.base_luck
                                $ add_luck=party_i.add_luck
                                $ hit_rate=party_i.hit_rate
                                $ critical=party_i.critical
                                $ Phys_eva=party_i.Phys_eva
                                $ Magi_eva=party_i.Magi_eva
                                $ crit_eva=party_i.crit_eva
                                text "[name]"
                                vbox:
                                    hbox:
                                        align (.5, .5)
                                        frame:
                                            background Frame("menu_screen/classic/MC_bg.png", 10, 10)
                                            align (.5, .5)
                                            $ portrait = party_i.face_img
                                            if not renpy.loadable(portrait):
                                                $ portrait = Null(width=90, height=90)
                                            if portrait is not None:
                                                add pscale(portrait, 90, 90) align (.5, .5)
                                        frame:
                                            background None
                                            grid 3 2:
                                                align (0.0,0.5)
                                                text "Level: [level]"
                                                text "HP: [HP] / [maxHP]"
                                                text "MP: [MP] / [maxMP]"
                                            
                                                text " "
                                                text "Attack: [maxAttack]"
                                                text "Defense: [maxDefense]"
                                    null height 50
                                    vbox:
                                        xfill True
                                        grid 2 1:
                                            text "Job: [job]"
                                            text "Job Level: [job_level]"
                                        null height 50
                                        grid 1 12:
                                            text "Experience: [totalExp]"
                                            text "Attack: [base_attack]([add_attack])"
                                            text "Defense: [base_defense]([add_defense])"
                                            text "Magic: [base_magic]([add_magic])"
                                            text "Endurance: [base_resist]([add_resist])"
                                            text "Agility: [base_agility]([base_agility])"
                                            text "Luck: [base_luck]([add_luck])"
                                            text "Hit Rate: [hit_rate]"
                                            text "Critical: [critical]"
                                            text "Physical evasion: [Phys_eva]"
                                            text "Magic evasion: [Magi_eva]"
                                            text "Critical evasion: [crit_eva]"
                                        hbox:
                                            align (.5, .5)
                                            textbutton "BACK":
                                                action SetScreenVariable("menu_big", "status")
this code is from an project i am doing
screenshot0035.png
screenshot0036.png
Attachments
statusFull_menu.rpy
(6.28 KiB) Downloaded 68 times
classic_status.rpy
(3.78 KiB) Downloaded 63 times

JustaHelpfulLurker
Newbie
Posts: 6
Joined: Sun Jan 14, 2018 8:42 pm
Contact:

Re: Adding Stats to Characters ... easily

#32 Post by JustaHelpfulLurker »

EDIT: Nevermind.

JustaHelpfulLurker
Newbie
Posts: 6
Joined: Sun Jan 14, 2018 8:42 pm
Contact:

Re: Adding Stats to Characters ... easily

#33 Post by JustaHelpfulLurker »

So for the inventory system, how do I actually get the quantity of an item? I'd like to be able to use it in expressions, but something like char.item['amount'] doesn't work at all.

envixer
Newbie
Posts: 23
Joined: Tue Jan 09, 2018 2:21 pm
Contact:

Re: Adding Stats to Characters ... easily

#34 Post by envixer »

Not sure if you're still maintaining this, or if there's a better way in python 3, but the code seems to work in the 8.0 preview as long as you update the raise command's syntax.

Post Reply

Who is online

Users browsing this forum: No registered users