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.
-
littlepeach90
- Newbie
- Posts: 5
- Joined: Mon Mar 19, 2012 6:04 pm
-
Contact:
#1
Post
by littlepeach90 » Mon Mar 14, 2016 5:47 pm
I'm working on a project where a character has supplies that can be used. I have no problems creating menu options to hide the option to interact with the item once that specific item count is at zero, but I can't quite puzzle out how to account for if all of the items are at zero at the same time.
Here's part of the code that works as it should:
Code: Select all
"Practice composing" if musicsupply > 0:
"I went to a nice, shady table to practice my composing."
But this is the part that I'm having problems with:
Code: Select all
"People Watch" if linedsupply > 0 and if papersupply > 0 and if musicsupply > 0:
I have zero idea what I'm doing, and I can't seem to find anything about this anywhere else. Any help would be greatly appreciated.
-
justcolorado
- Regular
- Posts: 47
- Joined: Sun Feb 07, 2016 9:32 pm
- Completed: Experiment Gone Rogue, Caravan Of Saints, HeartBaked, Hipster Axe
- Projects: Iragon
- Organization: Repulse.com
- Github: coloradostark
- Location: Plovdiv
-
Contact:
#2
Post
by justcolorado » Mon Mar 14, 2016 6:51 pm
There is a bunch of ways to do that
I usually like to sum up things that require a series of decisions into one simple answer with a very descriptive name
it is a little extra work, but it makes it easier to read which can be helpful if a bunch of people are working on the project
Code: Select all
call checkIfPlayerCanDoSomething
if PlayerCanDoIt == True:
"do something"
label checkIfPlayerCanDoSomething:
$ PlayerCanDoIt = False
if condition_A_is_Met:
if condition_B_is_Met:
if condition_C_is_Met:
$ PlayerCanDoIt = True
return
Last edited by
justcolorado on Mon Mar 14, 2016 7:36 pm, edited 1 time in total.
-
Zetsubou
- Miko-Class Veteran
- Posts: 513
- Joined: Wed Mar 05, 2014 1:00 am
- Completed: See my signature
- Github: koroshiya
- itch: zetsuboushita
-
Contact:
#3
Post
by Zetsubou » Mon Mar 14, 2016 7:08 pm
littlepeach90 wrote:Code: Select all
"People Watch" if linedsupply > 0 and if papersupply > 0 and if musicsupply > 0:
Only the first "if" is needed. Everything after that is part of the if statement.
ie.
Code: Select all
"People Watch" if linedsupply > 0 and papersupply > 0 and musicsupply > 0:
Some programming languages mandate brackets for if statements, which might make this concept easier to grasp.
eg. if (linedsupply > 0 and papersupply > 0 and musicsupply > 0)
One "if", multiple conditions.
Finished games
-My games: Sickness, Wander No More, Max Massacre, Humanity Must Perish, Tomboys Need Love Too, Sable's Grimoire, My Heart Grows Fonder, Man And Elf, A Dragon's Treasure
-Commissions: No One But You, Written In The Sky, Diamond Rose, To Libertad, Catch Canvas, Love Ribbon, Happy Campers, Wolf Tails
Working on:
Sable's Grimoire 2

-
littlepeach90
- Newbie
- Posts: 5
- Joined: Mon Mar 19, 2012 6:04 pm
-
Contact:
#4
Post
by littlepeach90 » Mon Mar 14, 2016 9:25 pm
I tried to do it without the multiple "if" statements, but the statement wasn't working at all; it just skipped ahead to some random section later in the script.
But I figured out that I could make it go through a jump, and even though there wasn't a specific menu option to click, I can still get it to go through the scenario of character realizing that she's out of all of her supplies, which is all that I wanted. :/
-
philat
- Eileen-Class Veteran
- Posts: 1853
- Joined: Wed Dec 04, 2013 12:33 pm
-
Contact:
#5
Post
by philat » Mon Mar 14, 2016 10:27 pm
I don't know if you've fixed this already, and since you appear to have gotten what you wanted, perhaps this is a moot point, but still: shouldn't the condition be checking if the supplies are at or below zero rather than above zero? In other words, your first menu choice only appears if musicsupply is above zero -- i.e., if you keep using up musicsupply and musicsupply hits 0, the choice will disappear. Similary, the second choice only appears if all three supplies are above zero -- which is the opposite of what you said you want.
-
littlepeach90
- Newbie
- Posts: 5
- Joined: Mon Mar 19, 2012 6:04 pm
-
Contact:
#6
Post
by littlepeach90 » Tue Mar 15, 2016 1:14 pm
philat wrote:I don't know if you've fixed this already, and since you appear to have gotten what you wanted, perhaps this is a moot point, but still: shouldn't the condition be checking if the supplies are at or below zero rather than above zero? In other words, your first menu choice only appears if musicsupply is above zero -- i.e., if you keep using up musicsupply and musicsupply hits 0, the choice will disappear. Similary, the second choice only appears if all three supplies are above zero -- which is the opposite of what you said you want.
I'm not quite sure, but it vanishes when it's supposed to, so I'm not going to question it. 0.o
Users browsing this forum: Bing [Bot]