If statements in screens error

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
User avatar
Pent
Newbie
Posts: 12
Joined: Wed Apr 04, 2018 2:37 pm
Completed: Project N (Not public), Project N 2 (Not Public)
Projects: Project N, Project N 2, Project G
Contact:

If statements in screens error

#1 Post by Pent »

I wanted to create something;
If the player clicks on all (in this case, 2) defined hotspots, the game advances to the next part:

Code: Select all

   screen bat:
            	imagemap:
                	ground "black.png"
                	hover "hover.png"
                
                    
                	hotspot (50, 50, 80, 75) clicked SetVariable("hit1",True)
                	hotspot (500, 500, 80, 75) clicked SetVariable("hit2",True)
               		if hit1 and hit2 == True:
                    		jump chapter1
I get the following error:

Code: Select all

File "game/script.rpy", line 586: u'jump' is not a keyword argument or valid child for the imagemap statement.
    jump chap1
I tried using

Code: Select all

Jump("chapter1")
but I got the same error.
I don't really know where my mistake is.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: If statements in screens error

#2 Post by Per K Grok »

Pent wrote: Tue Nov 13, 2018 2:16 pm I wanted to create something;
If the player clicks on all (in this case, 2) defined hotspots, the game advances to the next part:

Code: Select all

   screen bat:
            	imagemap:
                	ground "black.png"
                	hover "hover.png"
                
                    
                	hotspot (50, 50, 80, 75) clicked SetVariable("hit1",True)
                	hotspot (500, 500, 80, 75) clicked SetVariable("hit2",True)
               		if hit1 and hit2 == True:
                    		jump chapter1
I get the following error:

Code: Select all

File "game/script.rpy", line 586: u'jump' is not a keyword argument or valid child for the imagemap statement.
    jump chap1
I tried using

Code: Select all

Jump("chapter1")
but I got the same error.
I don't really know where my mistake is.
I think this would work but I have not tested it.

Code: Select all

        if hit2:
            hotspot (50, 50, 80, 75) clicked Jump("chapter1")
        else:
            hotspot (50, 50, 80, 75) clicked SetVariable("hit1",True)

        if hit1:
            hotspot (500, 500, 80, 75) clicked Jump("chapter1")
        else:
            hotspot (500, 500, 80, 75) clicked SetVariable("hit2",True)
 

User avatar
Pent
Newbie
Posts: 12
Joined: Wed Apr 04, 2018 2:37 pm
Completed: Project N (Not public), Project N 2 (Not Public)
Projects: Project N, Project N 2, Project G
Contact:

Re: If statements in screens error

#3 Post by Pent »

Per K Grok wrote: Wed Nov 14, 2018 2:28 am
Pent wrote: Tue Nov 13, 2018 2:16 pm I wanted to create something;
If the player clicks on all (in this case, 2) defined hotspots, the game advances to the next part:

Code: Select all

   screen bat:
            	imagemap:
                	ground "black.png"
                	hover "hover.png"
                
                    
                	hotspot (50, 50, 80, 75) clicked SetVariable("hit1",True)
                	hotspot (500, 500, 80, 75) clicked SetVariable("hit2",True)
               		if hit1 and hit2 == True:
                    		jump chapter1
I get the following error:

Code: Select all

File "game/script.rpy", line 586: u'jump' is not a keyword argument or valid child for the imagemap statement.
    jump chap1
I tried using

Code: Select all

Jump("chapter1")
but I got the same error.
I don't really know where my mistake is.
I think this would work but I have not tested it.

Code: Select all

        if hit2:
            hotspot (50, 50, 80, 75) clicked Jump("chapter1")
        else:
            hotspot (50, 50, 80, 75) clicked SetVariable("hit1",True)

        if hit1:
            hotspot (500, 500, 80, 75) clicked Jump("chapter1")
        else:
            hotspot (500, 500, 80, 75) clicked SetVariable("hit2",True)
 
It didn't raise an error but no matter on which spot you click first, it goes to chapter 1.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: If statements in screens error

#4 Post by Per K Grok »

Pent wrote: Thu Nov 15, 2018 1:50 pm ---
It didn't raise an error but no matter on which spot you click first, it goes to chapter 1.

Did you set hit1 and hit2 to False to start with? If they already are True you would get the result that you have.

I did a quick test and the code worked fine for me.

User avatar
Pent
Newbie
Posts: 12
Joined: Wed Apr 04, 2018 2:37 pm
Completed: Project N (Not public), Project N 2 (Not Public)
Projects: Project N, Project N 2, Project G
Contact:

Re: If statements in screens error

#5 Post by Pent »

Per K Grok wrote: Thu Nov 15, 2018 4:15 pm
Pent wrote: Thu Nov 15, 2018 1:50 pm ---
It didn't raise an error but no matter on which spot you click first, it goes to chapter 1.

Did you set hit1 and hit2 to False to start with? If they already are True you would get the result that you have.

I did a quick test and the code worked fine for me.
Thanks a bunch, that was my mistake. It works now!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]