Making a Points Variable having problems

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
CrystalD
Newbie
Posts: 19
Joined: Fri Aug 18, 2017 11:50 pm
Tumblr: CrystalDennisMusic
Skype: valkyrieceles
Soundcloud: crystaldennismusic
Contact:

Making a Points Variable having problems

#1 Post by CrystalD » Sat Jan 27, 2018 1:46 am

I'm fine when I do a basic points statement, but whenever I try and do a different kind it never works and I keep on getting an acception. What I'm trying to do is have a greater than or less than structure, like this:

Code: Select all

if baking_buffup > 2 and baking_buffup < 6:
    jump day_2_good_day
Anytime I try that, it says an acception has been made. I've read a tutorial and I wrote it out like that, and that was how the tutorial displayed it, so I'm wondering what I'm doing wrong here? Thanks!

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 2931
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Making a Points Variable having problems

#2 Post by Imperf3kt » Sat Jan 27, 2018 2:20 am

In my experience, you need to use "greater than or equal to".
So in your example, you want to check if something is more than 2, and another something is less than 6

Code: Select all

if baking_buffup >= 3 and baking_buffup <= 5:
    jump day_2_good_day
I adjusted the numbers by one for obvious reasons.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
Free Android GUI - Updated occasionally

CrystalD
Newbie
Posts: 19
Joined: Fri Aug 18, 2017 11:50 pm
Tumblr: CrystalDennisMusic
Skype: valkyrieceles
Soundcloud: crystaldennismusic
Contact:

Re: Making a Points Variable having problems

#3 Post by CrystalD » Sat Jan 27, 2018 2:31 am

Ah, that was it! I feel like such a derp for not realizing that XD Now I know you always should do <= or >= for things haha. Thanks!

CrystalD
Newbie
Posts: 19
Joined: Fri Aug 18, 2017 11:50 pm
Tumblr: CrystalDennisMusic
Skype: valkyrieceles
Soundcloud: crystaldennismusic
Contact:

Re: Making a Points Variable having problems

#4 Post by CrystalD » Sat Jan 27, 2018 3:44 pm

Might as well ask this here too because I feel like it will come up for me later. If I wanted to weigh one set of points against another without a number attached, would it be the same sort of setup? So like this:

Code: Select all

if baking_buffup <= and >= prepared_points:
    jump bad_day
The tutorial I read didn't have the = sign for that sort of setup either, so just want to make sure.

expenseroso
Regular
Posts: 28
Joined: Tue Mar 14, 2017 7:15 pm
Contact:

Re: Making a Points Variable having problems

#5 Post by expenseroso » Sun Jan 28, 2018 3:56 am

> and < should work fine without testing for equality as well, not sure what was going on with your initial problem. Your last bit of code wouldn't work because you didn't specify two variables to compare after the 'and'... python will not just assume you were intending to test both against the first variable you give it.

CrystalD
Newbie
Posts: 19
Joined: Fri Aug 18, 2017 11:50 pm
Tumblr: CrystalDennisMusic
Skype: valkyrieceles
Soundcloud: crystaldennismusic
Contact:

Re: Making a Points Variable having problems

#6 Post by CrystalD » Sun Jan 28, 2018 5:38 am

Not exactly sure what you mean, like have one variable before the and and two after it? Would you mind writing out a code example?

User avatar
starshine001
Newbie
Posts: 23
Joined: Fri Feb 02, 2018 9:16 am
Completed: None
Projects: The Nightfall [Vampire Thriller]
Organization: None
Contact:

Re: Making a Points Variable having problems

#7 Post by starshine001 » Fri Feb 02, 2018 1:04 pm

Not 100% sure this is what you mean, but I used this code in my game, where I had a situationwhere I needed to compare variables:

Code: Select all

if var1 > var2 and var1 > var2:
	...
It works fine for me (I'm using it in a dating game, the game checks which character has the most points and sends you to the appropriate scene.)

Hope I could help!

EDIT: BTW your code doesn't work because of 2 reasons:

1. The programm would see it as inlogical, since you are practicially saying: If baking_buffup is smaller than and bigger than prepared_points, go to bad day.
As you can see, that wouldn't work.

2. As far as I know (Feel free to correct me if I'm wrong), you have to write the initial variable again after and statements.

So, I quickly looked up an instance where I had to check variables:

Code: Select all

label day3_court_niija_female:
    N N "Anyone else?"
    
if sukaza > hannah and sukaza > niija:
   ...
    jump day3_court_niija_end
    
if hannah > sukaza and hannah > niija:
    ...
    jump day3_court_niija_end
    
Looking cool, Joker!
-Morgana, 2017
----------------------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------
My dreams dictate my reality

CrystalD
Newbie
Posts: 19
Joined: Fri Aug 18, 2017 11:50 pm
Tumblr: CrystalDennisMusic
Skype: valkyrieceles
Soundcloud: crystaldennismusic
Contact:

Re: Making a Points Variable having problems

#8 Post by CrystalD » Fri Feb 02, 2018 2:56 pm

That does clear things up, thanks! Yeah I wound up figuring out that was part of the problem too, but glad to see the logive behind it haha.

Post Reply

Who is online

Users browsing this forum: Google [Bot]