Page 1 of 1

Non-keyword arg after keyword arg? [Solved]

Posted: Wed Dec 28, 2011 3:34 pm
by manga_otaku
I'm using a condition switch in order to change the expression of the MC in her side image, but this error keeps persistently appearing. I have checked it over and over again and compared it to other projects, but I cannot find the root of the error. It works when I have one expression, but when I add extra expressions on it comes up with the error.

This is what I have:

Code: Select all

$ m = Character("Me", color = "#CC99CC", window_left_padding = 210, show_side_image = ConditionSwitch(
        "mc == 'cry'", im.Scale("char/mc/cry.gif", 250, 294), xalign=0.001, yalign=0.99,
        "mc == 'sad'", im.Scale("char/mc/sad.gif", 250, 294), xalign=0.001, yalign=0.99,
        "mc == 'norm'", im.Scale("char/mc/norm.gif", 250, 294), xalign=0.001, yalign=0.99,
        ))
And this is the parse error:

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/script.rpy", line 4: non-keyword arg after keyword arg

Ren'Py Version: Ren'Py 6.13.0.1603
Is there something simple which I have left out? Added in?
Thanks :)

Re: Non-keyword arg after keyword arg?

Posted: Wed Dec 28, 2011 4:04 pm
by ScottySeng
I think you need to delete the comma after the last yalign=0.99
I may be wrong, but that's what it looks like to me.

Re: Non-keyword arg after keyword arg?

Posted: Wed Dec 28, 2011 4:33 pm
by manga_otaku
I tried it but unfortunately that doesn't seem to be the problem D;
Thanks for the help anyway :)

Re: Non-keyword arg after keyword arg?

Posted: Wed Dec 28, 2011 5:41 pm
by KimiYoriBaka
the keyword args are the ones where you have the name of the variable with an equal sign. Generally, keyword args are supposed to be the last things mentioned, because they don't have a specific order for them.

I'm pretty sure xalign and yalign are only supposed to be defined for the entire displayable, and thus are only needed once. Try getting rid of the first two pairs.

Re: Non-keyword arg after keyword arg?

Posted: Wed Dec 28, 2011 5:47 pm
by DrakeNavarone
Looks like someone beat me to it while I was typing this up, but to expand upon KimiYoriBaka's reply with examples:

The ConditionSwitch function expects pairs of one condition (a) and one image (b) to be passed to it. The arguments should go something like this:

ConditionSwitch( a, b, a, b, a, b, keyword args )

but the code you provided is closer to:

ConditionSwitch( a, b, keyword args, a, b, keyword args, a, b, keyword args )

Give the following code a shot... It should get you closer to what you need to do, but I can't guarantee it'll work since I didn't test it myself:

Code: Select all

$ m = Character("Me", color = "#CC99CC", window_left_padding = 210, show_side_image = ConditionSwitch(
        "mc == 'cry'", im.Scale("char/mc/cry.gif", 250, 294),
        "mc == 'sad'", im.Scale("char/mc/sad.gif", 250, 294),
        "mc == 'norm'", im.Scale("char/mc/norm.gif", 250, 294), xalign=0.001, yalign=0.99,
        ))
Hopefully by removing those extra xalign/yalign attributes (which are conveniently the same value), this will work as intended.

Re: Non-keyword arg after keyword arg?

Posted: Thu Dec 29, 2011 7:08 pm
by manga_otaku
Ahah! Thank you! That seemed to do the trick ^_^