[solved] imagemap issues: expected a keyword argument or child statement.

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
ComputerArt.Club
Veteran
Posts: 427
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

[solved] imagemap issues: expected a keyword argument or child statement.

#1 Post by ComputerArt.Club »

I am making a game for kids, it will have a quiz in it comprised of imagemaps made from animated LiveComposite images to reduce file size. The livecomposite images are displaying with the show statement in a test outside of the imagemap statement, but this is the first time I have tried imagemaps and I am having a lot of problems.

Errors like:
File "game/script.rpy", line 375: u'return' is not a keyword argument or valid child for the label statement.
File "game/script.rpy", line 376: u'play' is not a keyword argument or valid child for the label statement.
play "duck.mp3"
the latest error is: File "game/script.rpy", line 372: expected a keyword argument or child statement.
"Where is the red duck?"

I suspect all of these issues are coming from the same place but also that there may be several issues with the code that might cause future problems.

Code: Select all

    screen quiz_p1:
        imagemap:
            ground "quizp1"
            hover "quizp1"
            idle "quizp1"
            
            hotspot (30, 900, 330, 330) action Return("red")
            hotspot (360, 900, 330, 330) action Return("yellow")
            hotspot (30, 570, 330, 330) action Return("green")
            hotspot (360, 570, 330, 330) action Return("blue")
            
            $ result = _return
            
            "Where is the red duck?"
            
            label quizq1:
                if result == "red":
                    play "duck.mp3"
                    jump quizq2
                else:
                    play "wrongduck.mp3"
                    jump quizq1
Also, do I need to specify hover and idle images? It is an android game, hover is irrelevant.

Thanks for taking the time to read this far. I really appreciate it.
Last edited by ComputerArt.Club on Wed Nov 15, 2017 9:50 am, edited 1 time in total.

User avatar
NineBells
Newbie
Posts: 9
Joined: Mon Jun 05, 2017 9:01 am
Projects: https://ninebells.wordpress.com/current-projects/
Location: Some place where it's GMT+8
Contact:

Re: imagemap issues: expected a keyword argument or child statement.

#2 Post by NineBells »

Currently untested but it should be something like this:

In script.rpy:

Code: Select all

label start:
    jump quizq1
    
    return
    
label quizq1:
    call screen quiz_p1
    
    return
In some other .rpy file (screen.rpy, perhaps? or at the bottom of script.rpy?):

Code: Select all

screen quiz_p1:
    imagemap:
        ground "quizp1"
        hover "quizp1"
        idle "quizp1"
        
        hotspot (30, 900, 330, 330) action [Play (sound,"duck.mp3"), Jump ('quizq2')]
        hotspot (360, 900, 330, 330) action [Play (sound,"wrongduck.mp3"), Jump ('quizq1')]
        hotspot (30, 570, 330, 330) action [Play (sound,"wrongduck.mp3"), Jump ('quizq1')]
        hotspot (360, 570, 330, 330) action [Play (sound,"wrongduck.mp3"), Jump ('quizq1')]
        
    text "Where is the red duck?" xalign 0.5 yalign 0.5 # Change position of text as you see fit

Screens should be outside labels and labels should not be inside screens if I'm not mistaken.
Hi. I'm a programmer. I'm currently available for short or simple projects. Check out my thread here.

Want to see how I work? Check out my blog!

One of my teams also has a blog here. Check it out for updates on our game TLH: Freud Was Right.

User avatar
ComputerArt.Club
Veteran
Posts: 427
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

Re: imagemap issues: expected a keyword argument or child statement.

#3 Post by ComputerArt.Club »

Thanks for your reply! It was very helpful, though I'm still experiencing a few problems.

I'm getting an error with your suggested code "NameError: name 'sound' is not defined", but even when I take out the play/sound element it runs but doesn't quite accomplish what I was hoping to accomplish (I hoped to reuse each imagemap for four separate questions - thus the return action). I see that the screens code seems to take a very different form and I guess it creates limitations regarding how it can interact with the main code. Is it possible for me to use the return function with the imagemap code such that I can combine it with if and else statements and text from the main script?

e.g.

Code: Select all

label quizq1:
	call screen quiz_p1
	"Where is the red duck?"
        if result == "red":
            play "duck.mp3"
            action Jump ('quizq2')
        else:
            play "wrongduck.mp3"
            action Jump ('quizq1')
            
label quizq2:
	call screen quiz_p1
	"Where is the blue duck?"
        if result == "blue":
            play "duck.mp3"
            action Jump ('quizq3')
        else:
            play "wrongduck.mp3"
            action Jump ('quizq2')

User avatar
NineBells
Newbie
Posts: 9
Joined: Mon Jun 05, 2017 9:01 am
Projects: https://ninebells.wordpress.com/current-projects/
Location: Some place where it's GMT+8
Contact:

Re: imagemap issues: expected a keyword argument or child statement.

#4 Post by NineBells »

I don't really have any experience with playing sounds in Ren'Py but try putting sound inside double quotes like this:

Code: Select all

Play ("sound","duck.mp3")
. Although if you're not using the code I provided before due to using the method below, you don't need to do this. ^^;

As for reusing the screen, you might be better off customizing the choice menu screen. There's a tutorial here for doing that.
Hi. I'm a programmer. I'm currently available for short or simple projects. Check out my thread here.

Want to see how I work? Check out my blog!

One of my teams also has a blog here. Check it out for updates on our game TLH: Freud Was Right.

User avatar
ComputerArt.Club
Veteran
Posts: 427
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

Re: imagemap issues: expected a keyword argument or child statement.

#5 Post by ComputerArt.Club »

Wow! Thanks so much for your speedy reply.

Yes, I had bookmarked that one already, I thought the focus was elsewhere (on the styling rather than the actions) though I guess I will need to comb through it further. I guess I don't really understand the screen language and how to use the return function in combination with the main script. It's getting late now and I only had a few hours sleep last night so nothing really makes sense ^^ Will try again tomorrow.

I really appreciate all your help. Thanks again!

User avatar
ComputerArt.Club
Veteran
Posts: 427
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

Re: [solved] imagemap issues: expected a keyword argument or child statement.

#6 Post by ComputerArt.Club »

Problem with the return function solved. Onto my next question, creating an efficient way to change the text at the top of the imagemaps for each question - perhaps by creating reusable code snippets. Thank you for your help!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Andredron