Help with menu and calculations

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Khaleon
Newbie
Posts: 2
Joined: Fri Oct 19, 2018 3:21 pm
Deviantart: Khaleon
Contact:

Help with menu and calculations

#1 Post by Khaleon »

Hi, first of all, i'm new on ren'py and the forum, and english isn't my native language, so I hope you can understand me :D, I've been reading a lot about how to use ren'py, and everything was going fine until I've tried to do something with the menu and the calculations. I've been looking on google and here but couldn't find something useful!

Here is an example of what I want to do:

Code: Select all

define c= Character("Character")
#Let's suppose that my character have different statistics, and based on that, I want certain options appear.
define strength= 3 

menu:

    "What should I do?"

#I want this option to show the percent of success that i can have in base of my strength.
    "Beat him": 
        jump beatHim

    "Let him leave":
        jump letHimLeave

    "Give him my money":
        jump giveMoney

        label beatHim:
            "You beat his ass"
            jump after

        label letHimLeave:
            p "Leave, I don't want to see your face again."
            jump after

        label giveMoney:
            p "Take my money, please don't hurt me!."
            jump after

label after:
    "You keep your path."

return
Let's suppose that I have 3 strength and that 5 is the 100% of the "beat him" option, so 3 would be a 60%, I want the option showing something like "beat him (60%)" something like Fallout 3!

How can I do something like that? I suppose that it is possible, but I don't know where should put the calculations and how to show the percentage on the menu. Hope someone can help me, and sorry if you don't understand me or if this is posted somewhere else! Thanks!

User avatar
Andredron
Miko-Class Veteran
Posts: 718
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Help with menu and calculations

#2 Post by Andredron »

Image

Image


And

label start:
....$ godnota = 10
...."[godnota] add 3"
....$ godnota += 3
...."[godnota]"

Khaleon
Newbie
Posts: 2
Joined: Fri Oct 19, 2018 3:21 pm
Deviantart: Khaleon
Contact:

Re: Help with menu and calculations

#3 Post by Khaleon »

Thanks for your help Andredron, but I didn't understood anything :lol:

Anyway, I figured how to make it work!

This is the code that I got now, hope can help someone:

Code: Select all

define p = Character("Protagonista")
define strength = 3
define successRate = 0
define percent = "%"

$ rNum = renpy.random.randint(0,100)

$ successRate = strength * 100 / 5
menu:

    "What should I do?"

    "Beat him [successRate][percent]":
        jump beatHim

    "Let him leave":
        jump letHimLeave

    "Give him my money":
        jump giveMoney


        label letHimLeave:
            p "Leave, I don't want to see your face again."
            jump after

        label giveMoney:
            p "Take my money, please don't hurt me!."
            jump after

        label beatHim:
            if rNum <= 60:
                "You beat his ass"
                define successRate = 0
                jump after
            else:
                "You weren't strong enough to fight him. He kicked your ass and took your money."+
                 define successRate = 0
                jump after

label after:
    "You keep your path."


return

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot], Rhapsy