If Statements

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.
Message
Author
Fang-tan
Regular
Posts: 72
Joined: Mon Mar 30, 2009 3:59 am
Location: Moriya Shrine, Gensokyo
Contact:

If Statements

#1 Post by Fang-tan »

I've been having trouble with If Statements and after messing around with it, I got this error. I figured if I posted that somebody could help me set it up properly. The line that is supposed to be triggered by the If Statement still shows up in the route where it shouldn't.
Attachments
traceback.txt
(1.11 KiB) Downloaded 126 times
"I've heard that villains who go soft and then crazy are pretty popular these days, right?
Even sooo, I've studied a lot of manga, anime and galge that have been popular, you seeee?" - Beatrice, Umineko no Naku Koro ni

Loli Salad~ Music, Doujin, Touhou, Umineko and Anime
(previously I was Hashihime~)

EvilDragon
Veteran
Posts: 284
Joined: Fri Dec 28, 2007 5:47 am
Location: Where the Dragons rule!
Contact:

Re: If Statements

#2 Post by EvilDragon »

Can you post the code in question too?
Angels of paradise, angels of sacrifice
Please let me be under your wings...

Fang-tan
Regular
Posts: 72
Joined: Mon Mar 30, 2009 3:59 am
Location: Moriya Shrine, Gensokyo
Contact:

Re: If Statements

#3 Post by Fang-tan »

Hmmm I should just attach the whole script right? Or would that be a bit much to search through? Because if I posted it here it might take up some space...
"I've heard that villains who go soft and then crazy are pretty popular these days, right?
Even sooo, I've studied a lot of manga, anime and galge that have been popular, you seeee?" - Beatrice, Umineko no Naku Koro ni

Loli Salad~ Music, Doujin, Touhou, Umineko and Anime
(previously I was Hashihime~)

EvilDragon
Veteran
Posts: 284
Joined: Fri Dec 28, 2007 5:47 am
Location: Where the Dragons rule!
Contact:

Re: If Statements

#4 Post by EvilDragon »

No, just some lines before and after the row which causes error.
Angels of paradise, angels of sacrifice
Please let me be under your wings...

Fang-tan
Regular
Posts: 72
Joined: Mon Mar 30, 2009 3:59 am
Location: Moriya Shrine, Gensokyo
Contact:

Re: If Statements

#5 Post by Fang-tan »

Oh, okay~

Code: Select all

    
scene bg hall
    with fade
    
    a "Another boring night ahead. I guess I should do my homework for real this time..."
    
    if goto_class:
       a  "The teachers went easy on me afterall..."
       
    a "Maybe that hikikomori will help me too..."
That's where I get the error.
"I've heard that villains who go soft and then crazy are pretty popular these days, right?
Even sooo, I've studied a lot of manga, anime and galge that have been popular, you seeee?" - Beatrice, Umineko no Naku Koro ni

Loli Salad~ Music, Doujin, Touhou, Umineko and Anime
(previously I was Hashihime~)

EvilDragon
Veteran
Posts: 284
Joined: Fri Dec 28, 2007 5:47 am
Location: Where the Dragons rule!
Contact:

Re: If Statements

#6 Post by EvilDragon »

You need to define variable before you use it. Do you by any chance have

goto_class = True

somewhere before that if statement occurs?
Angels of paradise, angels of sacrifice
Please let me be under your wings...

Fang-tan
Regular
Posts: 72
Joined: Mon Mar 30, 2009 3:59 am
Location: Moriya Shrine, Gensokyo
Contact:

Re: If Statements

#7 Post by Fang-tan »

I had it at the beginning where the new label started and I didn't get the error. But it still showed up for the route that didn't choose the choice that should have activated it.

Code: Select all

    jump walkhome

label walkhome:
    
    $ goto_class = True
    
    scene bg street day
    with fade
Unless it's supposed to. I was under the impression it wouldn't show if I chose a different option from the menu.
"I've heard that villains who go soft and then crazy are pretty popular these days, right?
Even sooo, I've studied a lot of manga, anime and galge that have been popular, you seeee?" - Beatrice, Umineko no Naku Koro ni

Loli Salad~ Music, Doujin, Touhou, Umineko and Anime
(previously I was Hashihime~)

F.I.A
Miko-Class Veteran
Posts: 546
Joined: Wed Sep 21, 2005 10:49 pm
Projects: Winter Shard, EVE, Hyperion
Contact:

Re: If Statements

#8 Post by F.I.A »

Generally, it is a good idea to have a full list of variables defined from the beginning. So go and add something like...

Code: Select all

label start:
    $ goto_room = False
「通りすがりのメーカだ。覚えとけ。」

----------
Winter shard
Image
WIP: Hyperion(Trace unknown), ?????(Progressing)

Fang-tan
Regular
Posts: 72
Joined: Mon Mar 30, 2009 3:59 am
Location: Moriya Shrine, Gensokyo
Contact:

Re: If Statements

#9 Post by Fang-tan »

Yeah, I had that in too.
"I've heard that villains who go soft and then crazy are pretty popular these days, right?
Even sooo, I've studied a lot of manga, anime and galge that have been popular, you seeee?" - Beatrice, Umineko no Naku Koro ni

Loli Salad~ Music, Doujin, Touhou, Umineko and Anime
(previously I was Hashihime~)

EvilDragon
Veteran
Posts: 284
Joined: Fri Dec 28, 2007 5:47 am
Location: Where the Dragons rule!
Contact:

Re: If Statements

#10 Post by EvilDragon »

This may seem ridiculous, but try this for if statement:

if goto_class==True:

This is out on a limb, though, because if goto_class: should do the same.
Angels of paradise, angels of sacrifice
Please let me be under your wings...

Fang-tan
Regular
Posts: 72
Joined: Mon Mar 30, 2009 3:59 am
Location: Moriya Shrine, Gensokyo
Contact:

Re: If Statements

#11 Post by Fang-tan »

Okay, I tried that. It still didn't work.

Could the following be the trouble?

Code: Select all

   
a "What should I do?"

menu:
    "Got to class":
         jump goto_class

    "Skip class":
         jump skip

label goto_class:
    
    $ goto_class = True
    
    a "I'll have other chances to talk to her. I might be able to explain myself to the teacher anyways..."
"I've heard that villains who go soft and then crazy are pretty popular these days, right?
Even sooo, I've studied a lot of manga, anime and galge that have been popular, you seeee?" - Beatrice, Umineko no Naku Koro ni

Loli Salad~ Music, Doujin, Touhou, Umineko and Anime
(previously I was Hashihime~)

EvilDragon
Veteran
Posts: 284
Joined: Fri Dec 28, 2007 5:47 am
Location: Where the Dragons rule!
Contact:

Re: If Statements

#12 Post by EvilDragon »

Yes, you can't have a label and a variable with the same name. I think. Change the name of label to something different.
Angels of paradise, angels of sacrifice
Please let me be under your wings...

Fang-tan
Regular
Posts: 72
Joined: Mon Mar 30, 2009 3:59 am
Location: Moriya Shrine, Gensokyo
Contact:

Re: If Statements

#13 Post by Fang-tan »

Ah, I was hoping that would work. I shorted the label down to 'goto' but still no luck, the line still appears regardless.
"I've heard that villains who go soft and then crazy are pretty popular these days, right?
Even sooo, I've studied a lot of manga, anime and galge that have been popular, you seeee?" - Beatrice, Umineko no Naku Koro ni

Loli Salad~ Music, Doujin, Touhou, Umineko and Anime
(previously I was Hashihime~)

EvilDragon
Veteran
Posts: 284
Joined: Fri Dec 28, 2007 5:47 am
Location: Where the Dragons rule!
Contact:

Re: If Statements

#14 Post by EvilDragon »

goto is a reserved word I think. Try some other words instead.
Angels of paradise, angels of sacrifice
Please let me be under your wings...

chronoluminaire
Eileen-Class Veteran
Posts: 1153
Joined: Mon Jul 07, 2003 4:57 pm
Completed: Elven Relations, Cloud Fairy, When I Rule The World
Tumblr: alextfish
Skype: alextfish
Location: Cambridge, UK
Contact:

Re: If Statements

#15 Post by chronoluminaire »

Hmm. Since our first couple of attempts to track this down have failed, it sounds like it'd be a good idea to post your entire script. (If you'd rather keep it secret, strip it down to a small bit of it, but the important thing is that it's (1) a complete script file that we can run in our own Ren'Py and (2) still produces the error you're seeing.)
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!

Post Reply

Who is online

Users browsing this forum: Imperf3kt