Trouble with if and points

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
Mevers
Newbie
Posts: 14
Joined: Tue Sep 22, 2015 1:37 pm
Contact:

Trouble with if and points

#1 Post by Mevers » Thu Sep 24, 2015 2:35 pm

So I've been having a play with points in renpy, and discovered how to multiply and divide points however, I can't seem to get a menu/label option to show if I want two or more sets of points to be of a specific value, for example:

Code: Select all

if loop_points == 4 + luck_points == 3:
The player would need 4 points in loop and 3 in luck. No more or no less.

Renpy finds no error with this but I can only get the option up If I remove one type of point or the other.

So I tried disregarding the exact amount I wanted in favour of more than or less than signs but I can't seem to get that to work either.

Code: Select all

if loop_points >= 2:
again renpy finds no issues with the script but in this instance the option shows regardless. In addition I have only tried the more or less than with only one variable.

Any pointers?

User avatar
Darim
Regular
Posts: 67
Joined: Sun Jun 21, 2015 4:17 pm
Organization: Setsuna Ken
Github: SetsunaKen
Location: Germany
Contact:

Re: Trouble with if and points

#2 Post by Darim » Thu Sep 24, 2015 3:04 pm

Try this one :D

Code: Select all

if loop_points == 4 and luck_points == 3:
You should also post how you increase the loop and luck points.

Mevers
Newbie
Posts: 14
Joined: Tue Sep 22, 2015 1:37 pm
Contact:

Re: Trouble with if and points

#3 Post by Mevers » Thu Sep 24, 2015 3:40 pm

I increase and decrease the luck and loop points in the same way with the following,

Code: Select all

$ luck_points += 1

Code: Select all

$ luck_points -= 1

Code: Select all

$ luck_points *= 1

Code: Select all

$ luck_points /= 1
Unfortunately, I can't tell if change the "+" to an "and" worked. The option doesn't seem to come up in one place but in another it does but if you decrease the variables it still works... So this works even though the points don't match up.

Code: Select all

label tmt:
    $ loop_points +=2
    $ luck_points +=1
    "You decided to visit the local shops"
    "You know the perfect spot for a new outfit"
    jump whichshop

label whichshop:
    if loop_points == 2 and luck_points == 2:
        "You find nothing"
        "you return home"
        jump whichshop2

label whichshop2:
    "You find nothing12"
    "you return home12"
    jump end
note this is an example I made up. To hep me understand the point options.

Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: Trouble with if and points

#4 Post by Onishion » Thu Sep 24, 2015 5:07 pm

Well, one tip is that if you hit "shift-d" while playing the game, it brings up a menu that includes a variable viewer. Check the variable in question and make sure that it ends up being what you think it should be. If you check "Variable >= 5" and you think it should be a 6 at that point, but it's actually a 3, then you're having problems with the increment, not with the checking, right? It can also be helpful when trying to test things like this to just have "loop points = [loop_points]" lines of dialog in between testing things, so that it prints out what the variables you're working with are. That way you don't even need the variable viewer, and you can just remove them once you have it working right.

As for your example, it's got some clear flaws. For one thing, what will happen there is that if the first bit is found true, if both variables = 2, then it will say words and jump to label 2. If it's false, it won't say those lines, but it will still jump to label 2, because you haven't put anything else for it to do if it finds false, it just falls through to the next thing, which is label 2. You should either add an "else" block, or just have another set of commands under there that would act as a de facto "else" block. But yeah, the "correct" response to the example as written should be that it runs through, finds the result "False" because loop_points == 2 but luck_points != 2 (it equals 1), therefore it should skip the following block and fall down to whichshop2, print the following dialog, and then jump to end.

Mevers
Newbie
Posts: 14
Joined: Tue Sep 22, 2015 1:37 pm
Contact:

Re: Trouble with if and points

#5 Post by Mevers » Sat Oct 03, 2015 8:42 am

Thank you, "Shift-d" was a big help, and it helped me get the "and" option to work, still working on the more or less than options. Though, I really do need a better example, it was something I strung together fairly quickly instead of what I was actually working on, as I'm still trying to come to grips with the software.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]