[Ren'Py] If statement

jon95

Member
Game Developer
Sep 29, 2018
95
180
Hello,
I want to know if there is a way to make this more simple?
Code:
hbox:
        xalign 0.5
        yalign 0.54
        if jumping:
            if b.race == 0:
                imagebutton auto "/gui/jump_%s.png":
                    xalign 0.5
                    action [Function(renpy.hide,"kid jumping sport"), Function(renpy.show,"tom jumping sport", at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]
                    if renpy.variant("touch"):
                        at customzoom
                    else:
                        at customzoom2

            if b.race == 1:
                imagebutton auto "/gui/jump_%s.png":
                    xalign 0.5
                    action [Function(renpy.hide,"kid jumping sport"), Function(renpy.show,"j3 jumping sport", at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]
                    if renpy.variant("touch"):
                        at customzoom
                    else:
                        at customzoom2


            if b.race == 2:
                imagebutton auto "/gui/jump_%s.png":
                    xalign 0.5
                    action [Function(renpy.hide,"kid jumping sport"), Function(renpy.show,"lee jumping sport", at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]
                    if renpy.variant("touch"):
                        at customzoom
                    else:
                        at customzoom2

            if b.race == 3:
                imagebutton auto "/gui/jump_%s.png":
                    xalign 0.5
                    action [Function(renpy.hide,"kid jumping sport"), Function(renpy.show,"ricardo jumping sport", at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]
                    if renpy.variant("touch"):
                        at customzoom
                    else:
                        at customzoom2


        else:
            imagebutton idle "/gui/jump_disabled.png":
                xalign 0.5
                action NullAction()
                if renpy.variant("touch"):
                    at customzoom
                else:
                    at customzoom2
            timer 1.0 action SetVariable("jumping", True)

        if jj >= 50:
            timer 0.1 action [Hide("minigame_jumping_jacks", transition=dissolve), Jump("jumping_jacks_win"), SetVariable("jj", 0), SetVariable("cristina.jj", 0)]
Thanks in advance
 

TCMS

Quote my posts if you want an answer
Staff member
Moderator
Donor
Aug 5, 2016
5,401
19,803
Not a python expert in any way, but going by basic coding logic this could be done i'd reckon:
Code:
hbox:
        xalign 0.5
        yalign 0.54
        if jumping:
            imagebutton auto "/gui/jump_%s.png":
                xalign 0.5
                if b.race == 0:
                    action [Function(renpy.hide,"kid jumping sport"), Function(renpy.show,"tom jumping sport", at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]

                if b.race == 1:
                    action [Function(renpy.hide,"kid jumping sport"), Function(renpy.show,"j3 jumping sport", at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]

                if b.race == 2:
                    action [Function(renpy.hide,"kid jumping sport"), Function(renpy.show,"lee jumping sport", at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]

                if b.race == 3:
                    action [Function(renpy.hide,"kid jumping sport"), Function(renpy.show,"ricardo jumping sport", at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]

                if renpy.variant("touch"):
                    at customzoom
                else:
                    at customzoom2

        else:
            imagebutton idle "/gui/jump_disabled.png":
                xalign 0.5
                action NullAction()
                if renpy.variant("touch"):
                    at customzoom
                else:
                    at customzoom2
            timer 1.0 action SetVariable("jumping", True)

        if jj >= 50:
            timer 0.1 action [Hide("minigame_jumping_jacks", transition=dissolve), Jump("jumping_jacks_win"), SetVariable("jj", 0), SetVariable("cristina.jj", 0)]
Also I'd reckon the if b.race codes after the first could be elif. There's probably people with better solutions who are more familiar with python than me, but here's mine <.<
 
  • Like
Reactions: jon95

mgomez0077

Well-Known Member
Game Developer
Oct 12, 2017
1,132
1,523
Maybe like this:

Code:
if b.race == 0:
    $ raceimagename = "tom jumping sport"
if b.race == 1:
    $ raceimagename = "j3 jumping sport"
if b.race == 2:
    $ raceimagename = "lee jumping sport"
if b.race == 3:
    $ raceimagename = "ricardo jumping sport"

default customzoom_mode = "customzoom"
if renpy.variant("touch"):
     $ customzoom_mode = "customzoom2"

hbox:
        xalign 0.5
        yalign 0.54
        if jumping:
           imagebutton auto "/gui/jump_%s.png":
               xalign 0.5
               action Hide("kid jumping sport"),Show([raceimagename]), at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]
               at [customzoom_mode]

        else:
            imagebutton idle "/gui/jump_disabled.png":
                xalign 0.5
                action NullAction()
                at [customzoom_mode]
            timer 1.0 action SetVariable("jumping", True)

        if jj >= 50:
            timer 0.1 action [Hide("minigame_jumping_jacks", transition=dissolve), Jump("jumping_jacks_win"), SetVariable("jj", 0), SetVariable("cristina.jj", 0)]
If the only thing that changes in your commands is what is shown, you can assign a variable and give it the value before executing the command, so the same command will serve for any of the values it has previously assigned.

Update: You can also use another code to make the command shorter. Instead of "[Function(renpy.hide, "kid jumping sport")" you can use "Hide("kid jumping sport")".

Update 2: As for "customzoom" or "customzoom2", you can also use a variable to specify the type of "at" you are going to use, so you only need three lines and you won't have to write the four check lines every time you need it.

(Note: it's an idea, I'm not completely sure and I haven't tried it :p)
 
Last edited:
  • Like
  • Love
Reactions: jon95 and TCMS

jon95

Member
Game Developer
Sep 29, 2018
95
180
Thanks to @TCMS and @mgomez0077 for your help but I have another question
Code:
menu:
        "so what":
            scene 240
            mc "It’s ok! I’m your father so it doesn’t matter."
            mc "And I have already seen your naked butt countless times when you were still small."
            scene 241
            sp "Stepfather, and that was many years ago. My butt is totally deferent now from that time."

            menu:
                "I don’t believe":
                    scene 240
                    mc "I don’t believe it! How much can it change in just a few years ?"
                    scene 241
                    sp "I don’t mind showing you."

                    menu:
                        "Really":
                            $ sp_ass = True

                            scene 240
                            mc "Really!? will you show me your ass?"
                            scene 241
                            sp "If it is [mc], then it’s ok."
                            sp "But you have to get out first so that I can change into a good dress."
                            scene 240
                            mc "Fine! I’ll wait for you to change. You should better not deceive me or I don’t mind punishing you developed
                            butt."

                        "No":
                            scene 240
                            mc "No, I don’t want to see my daughter's ass. I’ll wait for you outside."
                            mc "When you finish, call me."

                "You will always stay a child":
                    scene 240
                    mc "No matter how much you grew up, you will always stay a child in my eyes."
                    mc "I’ll wait for you outside when you finish call me."

        "Sorry":
            scene 240
            mc "Sorry, I didn’t know. I’ll get out now."
Is there a simple way to write this code too?
 

mgomez0077

Well-Known Member
Game Developer
Oct 12, 2017
1,132
1,523
Thanks to @TCMS and @mgomez0077 for your help but I have another question
Code:
menu:
        "so what":
            scene 240
            mc "It’s ok! I’m your father so it doesn’t matter."
            mc "And I have already seen your naked butt countless times when you were still small."
            scene 241
            sp "Stepfather, and that was many years ago. My butt is totally deferent now from that time."

            menu:
                "I don’t believe":
                    scene 240
                    mc "I don’t believe it! How much can it change in just a few years ?"
                    scene 241
                    sp "I don’t mind showing you."

                    menu:
                        "Really":
                            $ sp_ass = True

                            scene 240
                            mc "Really!? will you show me your ass?"
                            scene 241
                            sp "If it is [mc], then it’s ok."
                            sp "But you have to get out first so that I can change into a good dress."
                            scene 240
                            mc "Fine! I’ll wait for you to change. You should better not deceive me or I don’t mind punishing you developed
                            butt."

                        "No":
                            scene 240
                            mc "No, I don’t want to see my daughter's ass. I’ll wait for you outside."
                            mc "When you finish, call me."

                "You will always stay a child":
                    scene 240
                    mc "No matter how much you grew up, you will always stay a child in my eyes."
                    mc "I’ll wait for you outside when you finish call me."

        "Sorry":
            scene 240
            mc "Sorry, I didn’t know. I’ll get out now."
Is there a simple way to write this code too?
I don't see the way you want to improve :unsure:
They're lines of text and menus, it's the basics :p
 
  • Like
Reactions: jon95

TCMS

Quote my posts if you want an answer
Staff member
Moderator
Donor
Aug 5, 2016
5,401
19,803
I don't see any way since there's no logical statements just text, maybe mgomez knows o.0

Edit: Oops, he posted before me :D
 

mgomez0077

Well-Known Member
Game Developer
Oct 12, 2017
1,132
1,523
I don't see any way since there's no logical statements just text, maybe mgomez knows o.0

Edit: Oops, he posted before me :D
The only thing that is repeated are the images, maybe he wants to avoid that... and it could be done with variables, but it would be more complicated and the code would end up being longer, it's not worth it; and there's no problem repeating the images that way, it's the usual thing :D
 
  • Like
Reactions: jon95 and TCMS

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
3,138
6,804
Maybe like this:

Code:
if b.race == 0:
    $ raceimagename = "tom jumping sport"
if b.race == 1:
    $ raceimagename = "j3 jumping sport"
if b.race == 2:
    $ raceimagename = "lee jumping sport"
if b.race == 3:
    $ raceimagename = "ricardo jumping sport"

default customzoom_mode = "customzoom"
if renpy.variant("touch"):
     $ customzoom_mode = "customzoom2"

hbox:
        xalign 0.5
        yalign 0.54
        if jumping:
           imagebutton auto "/gui/jump_%s.png":
               xalign 0.5
               action Hide("kid jumping sport"),Show([raceimagename]), at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]
               at [customzoom_mode]

        else:
            imagebutton idle "/gui/jump_disabled.png":
                xalign 0.5
                action NullAction()
                at [customzoom_mode]
            timer 1.0 action SetVariable("jumping", True)

        if jj >= 50:
            timer 0.1 action [Hide("minigame_jumping_jacks", transition=dissolve), Jump("jumping_jacks_win"), SetVariable("jj", 0), SetVariable("cristina.jj", 0)]
If the only thing that changes in your commands is what is shown, you can assign a variable and give it the value before executing the command, so the same command will serve for any of the values it has previously assigned.

Update: You can also use another code to make the command shorter. Instead of "[Function(renpy.hide, "kid jumping sport")" you can use "Hide("kid jumping sport")".

Update 2: As for "customzoom" or "customzoom2", you can also use a variable to specify the type of "at" you are going to use, so you only need three lines and you won't have to write the four check lines every time you need it.

(Note: it's an idea, I'm not completely sure and I haven't tried it :p)
default customzoom_mode = "customzoom" and at [customzoom_mode] don't work this way. just assign the atl transformation object to a variable with $ customzoom_mode = customzoom. you even can provide arguments, if the transform requests them $ customzoom_mode = customzoom(arg1, arg2). in the displayable definition just use at customzoom_mode. the [] substitution is for strings. with at [customzoom_mode] you create a list with customzoom_mode as only element. same goes for Show([raceimagename]).

and for the original problem...
Code:
$ raceimagename = ["tom jumping sport", "j3 jumping sport", "lee jumping sport",
    "ricardo jumping sport", ]

hbox:
    xalign 0.5
    yalign 0.54
    if jumping:
        imagebutton auto "/gui/jump_%s.png":
            at (customzoom2 if renpy.variant("touch") else customzoom)
            xalign 0.5
            action [Hide("kid jumping sport"), Show(raceimagename[b.race]), at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]
    else:
        imagebutton idle "/gui/jump_disabled.png":
            at (customzoom2 if renpy.variant("touch") else customzoom)
            xalign 0.5
            action NullAction()
        timer 1.0 action SetVariable("jumping", True)

    if jj >= 50:
        timer 0.1 action [Hide("minigame_jumping_jacks", transition=dissolve), Jump("jumping_jacks_win"), SetVariable("jj", 0), SetVariable("cristina.jj", 0)]
 
Last edited:

jon95

Member
Game Developer
Sep 29, 2018
95
180
Maybe like this:

Code:
if b.race == 0:
    $ raceimagename = "tom jumping sport"
if b.race == 1:
    $ raceimagename = "j3 jumping sport"
if b.race == 2:
    $ raceimagename = "lee jumping sport"
if b.race == 3:
    $ raceimagename = "ricardo jumping sport"

default customzoom_mode = "customzoom"
if renpy.variant("touch"):
     $ customzoom_mode = "customzoom2"

hbox:
        xalign 0.5
        yalign 0.54
        if jumping:
           imagebutton auto "/gui/jump_%s.png":
               xalign 0.5
               action Hide("kid jumping sport"),Show([raceimagename]), at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]
               at [customzoom_mode]

        else:
            imagebutton idle "/gui/jump_disabled.png":
                xalign 0.5
                action NullAction()
                at [customzoom_mode]
            timer 1.0 action SetVariable("jumping", True)

        if jj >= 50:
            timer 0.1 action [Hide("minigame_jumping_jacks", transition=dissolve), Jump("jumping_jacks_win"), SetVariable("jj", 0), SetVariable("cristina.jj", 0)]
If the only thing that changes in your commands is what is shown, you can assign a variable and give it the value before executing the command, so the same command will serve for any of the values it has previously assigned.

Update: You can also use another code to make the command shorter. Instead of "[Function(renpy.hide, "kid jumping sport")" you can use "Hide("kid jumping sport")".

Update 2: As for "customzoom" or "customzoom2", you can also use a variable to specify the type of "at" you are going to use, so you only need three lines and you won't have to write the four check lines every time you need it.

(Note: it's an idea, I'm not completely sure and I haven't tried it :p)
When I played the game it broke down at this point
x.jpg
I tried @the66 solution
default customzoom_mode = "customzoom" and at [customzoom_mode] don't work this way. just assign the atl transformation object to a variable with $ customzoom_mode = customzoom. you even can provide arguments, if the transform requests them $ customzoom_mode = customzoom(arg1, arg2). in the displayable definition just use at customzoom_mode. the [] substitution is for strings. with at [customzoom_mode] you create a list with customzoom_mode as only element. same goes for Show([raceimagename]).

and for the original problem...
Code:
$ raceimagename = ["tom jumping sport", "j3 jumping sport", "lee jumping sport",
    "ricardo jumping sport", ]

hbox:
    xalign 0.5
    yalign 0.54
    if jumping:
        imagebutton auto "/gui/jump_%s.png":
            at (customzoom2 if renpy.variant("touch") else customzoom)
            xalign 0.5
            action [Hide("kid jumping sport"), Show(raceimagename[b.race]), at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]
    else:
        imagebutton idle "/gui/jump_disabled.png":
            at (customzoom2 if renpy.variant("touch") else customzoom)
            xalign 0.5
            action NullAction()
        timer 1.0 action SetVariable("jumping", True)

    if jj >= 50:
        timer 0.1 action [Hide("minigame_jumping_jacks", transition=dissolve), Jump("jumping_jacks_win"), SetVariable("jj", 0), SetVariable("cristina.jj", 0)]
But the game didn't even work
I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/script.rpy", line 169, in script call
call events_run_period from _call_events_run_period
File "game/event_dispatcher.rpy", line 270, in script call
call expression _event from call_expression_event_1
File "game/events.rpy", line 601, in script
show screen minigame_jumping_jacks with dissolve
File "renpy/common/000statements.rpy", line 513, in execute_show_screen
renpy.with_statement(eval(transition_expr))
File "game/stats.rpy", line 301, in execute
screen minigame_jumping_jacks():
File "game/stats.rpy", line 301, in execute
screen minigame_jumping_jacks():
File "game/stats.rpy", line 341, in execute
hbox:
File "game/stats.rpy", line 344, in execute
if jumping:
TypeError: 'unicode' object is not callable

-- Full Traceback ------------------------------------------------------------

Full traceback:
File "game/script.rpy", line 169, in script call
call events_run_period from _call_events_run_period
File "game/event_dispatcher.rpy", line 270, in script call
call expression _event from call_expression_event_1
File "game/events.rpy", line 601, in script
show screen minigame_jumping_jacks with dissolve
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\ast.py", line 1907, in execute
self.call("execute")
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\ast.py", line 1895, in call
return renpy.statements.call(method, parsed, *args, **kwargs)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\statements.py", line 220, in call
return method(parsed, *args, **kwargs)
File "renpy/common/000statements.rpy", line 513, in execute_show_screen
renpy.with_statement(eval(transition_expr))
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\exports.py", line 1572, in with_statement
return renpy.game.interface.do_with(trans, paired, clear=clear)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 2237, in do_with
clear=clear)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 2687, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 3071, in interact_core
root_widget.visit_all(lambda i : i.per_interact())
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 531, in visit_all
d.visit_all(callback, seen)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 531, in visit_all
d.visit_all(callback, seen)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 531, in visit_all
d.visit_all(callback, seen)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 531, in visit_all
d.visit_all(callback, seen)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\screen.py", line 424, in visit_all
callback(self)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 3071, in <lambda>
root_widget.visit_all(lambda i : i.per_interact())
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\screen.py", line 434, in per_interact
self.update()
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\screen.py", line 619, in update
self.screen.function(**self.scope)
File "game/stats.rpy", line 301, in execute
screen minigame_jumping_jacks():
File "game/stats.rpy", line 301, in execute
screen minigame_jumping_jacks():
File "game/stats.rpy", line 341, in execute
hbox:
File "game/stats.rpy", line 344, in execute
if jumping:
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\sl2\slast.py", line 989, in execute
d = t(d)
TypeError: 'unicode' object is not callable

Windows-8-6.2.9200
Ren'Py 7.2.0.424
Bimbo High 0.25e
Fri Jul 12 16:53:50 2019
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
3,138
6,804
When I played the game it broke down at this point
View attachment 343886
I tried @the66 solution

But the game didn't even work
I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/script.rpy", line 169, in script call
call events_run_period from _call_events_run_period
File "game/event_dispatcher.rpy", line 270, in script call
call expression _event from call_expression_event_1
File "game/events.rpy", line 601, in script
show screen minigame_jumping_jacks with dissolve
File "renpy/common/000statements.rpy", line 513, in execute_show_screen
renpy.with_statement(eval(transition_expr))
File "game/stats.rpy", line 301, in execute
screen minigame_jumping_jacks():
File "game/stats.rpy", line 301, in execute
screen minigame_jumping_jacks():
File "game/stats.rpy", line 341, in execute
hbox:
File "game/stats.rpy", line 344, in execute
if jumping:
TypeError: 'unicode' object is not callable

-- Full Traceback ------------------------------------------------------------

Full traceback:
File "game/script.rpy", line 169, in script call
call events_run_period from _call_events_run_period
File "game/event_dispatcher.rpy", line 270, in script call
call expression _event from call_expression_event_1
File "game/events.rpy", line 601, in script
show screen minigame_jumping_jacks with dissolve
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\ast.py", line 1907, in execute
self.call("execute")
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\ast.py", line 1895, in call
return renpy.statements.call(method, parsed, *args, **kwargs)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\statements.py", line 220, in call
return method(parsed, *args, **kwargs)
File "renpy/common/000statements.rpy", line 513, in execute_show_screen
renpy.with_statement(eval(transition_expr))
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\exports.py", line 1572, in with_statement
return renpy.game.interface.do_with(trans, paired, clear=clear)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 2237, in do_with
clear=clear)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 2687, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 3071, in interact_core
root_widget.visit_all(lambda i : i.per_interact())
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 531, in visit_all
d.visit_all(callback, seen)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 531, in visit_all
d.visit_all(callback, seen)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 531, in visit_all
d.visit_all(callback, seen)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 531, in visit_all
d.visit_all(callback, seen)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\screen.py", line 424, in visit_all
callback(self)
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\core.py", line 3071, in <lambda>
root_widget.visit_all(lambda i : i.per_interact())
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\screen.py", line 434, in per_interact
self.update()
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\display\screen.py", line 619, in update
self.screen.function(**self.scope)
File "game/stats.rpy", line 301, in execute
screen minigame_jumping_jacks():
File "game/stats.rpy", line 301, in execute
screen minigame_jumping_jacks():
File "game/stats.rpy", line 341, in execute
hbox:
File "game/stats.rpy", line 344, in execute
if jumping:
File "D:\Downloads\Compressed\RenpyPractice\renpy-7.2.0-sdk\renpy\sl2\slast.py", line 989, in execute
d = t(d)
TypeError: 'unicode' object is not callable

Windows-8-6.2.9200
Ren'Py 7.2.0.424
Bimbo High 0.25e
Fri Jul 12 16:53:50 2019
just make sure, that customzoom and customzoom2 in at (customzoom2 if renpy.variant("touch") else customzoom) are actually atl transform objects and no strings.
 
  • Like
Reactions: jon95

jon95

Member
Game Developer
Sep 29, 2018
95
180
just make sure, that customzoom and customzoom2 in at (customzoom2 if renpy.variant("touch") else customzoom) are actually atl transform objects and no strings.
like this?
Code:
transform customzoom:
    zoom 0.8

transform customzoom2:
    zoom 0.5
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
3,138
6,804
like this?
Code:
transform customzoom:
    zoom 0.8

transform customzoom2:
    zoom 0.5
yup, customzoom and customzoom2 are atl transform objects. use them correctly like
Python:
add "some image":
    at customzoom
and not like
Python:
add "some image":
    at "customzoom"
 

jon95

Member
Game Developer
Sep 29, 2018
95
180
yup, customzoom and customzoom2 are atl transform objects. use them correctly like
Python:
add "some image":
    at customzoom
and not like
Python:
add "some image":
    at "customzoom"
the traceback say that there is problems with
Code:
 action [Hide("kid jumping sport"), Show(raceimagename[b.race]), at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]
ps "tom jumping sport", "j3 jumping sport", "lee jumping sport", "ricardo jumping sport" are images also since they are in the same array how can I make it chose the right one
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
3,138
6,804
ok, my bad. always thought these are screens :oops:. try
Python:
action [Function(renpy.hide ,"kid jumping sport"), Function(renpy.show, raceimagename[b.race]), at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]
. you select the element of the list via b.race.
 
  • Love
Reactions: jon95

anne O'nymous

Well-Known Member
Modder
Respected User
Jun 10, 2017
2,304
2,612
default customzoom_mode = "customzoom" and at [customzoom_mode] don't work this way. just assign the atl transformation object to a variable with $ customzoom_mode = customzoom.
Still it's better to do it by using the default screen statement like mgomez0077 did.
Code:
screen whatever:
     $ varName = something
will add varName in the default scope/store and include it in every save file. This while :
Code:
screen whatever:
     default varName = something
will add varName in the screen scope/store, and forget everything about it once the screen will be hidden. In the end the behavior is the same than variables defined with renpy.dynamic, they will be local to the actual screen.
In addition to this, default will be interpreted when the screen is predicted and displayed, but not when the screen is updated. Which prevent the value to be accidentally reset.

The only limitation here is if you use the use screen statement ; default isn't designed for this.
Code:
screen whatever:
    default var1 = something
    use whatever1

screen whatever1:
    default var2 = somethingElse
[/icode]
Both screens have their own scope/store, which prevent [icode]var1[/icode] to be seen (and so used) in "whatever1". But in the same time, because the [icode]use[/icode] screen statement act like the added screen is part of the screen that use it (so "whatever1" is part of "whatever2"), [icode]var2[/icode] will also be added in the scope of "whatever" and not the one of "whatever1".
In the end, none of the variable are usable from "whatever1".
[/spoiler]

All this lead to your :
[code]
$ raceimagename = ["tom jumping sport", "j3 jumping sport", "lee jumping sport",
    "ricardo jumping sport", ]
being better if it was :
Code:
default raceimagename = ["tom jumping sport", "j3 jumping sport", "lee jumping sport",
    "ricardo jumping sport", ]

ok, my bad. always thought these are screens :oops:.
The function would have been renpy.hide_screen and renpy.show_screen in this case. But well, I also saw them as screen at first, since it's really unusual to just change an image this way.
There's probably a way to do this with add and don't have to rely on function, but my brain isn't in a good enough condition to think about it right now.
 
  • Like
Reactions: jon95

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
3,138
6,804
um, nope. a variable defined in a screen is only valid for this screen no matter what. it's not accessible from outside the screen even if said screen is displayed.
 

anne O'nymous

Well-Known Member
Modder
Respected User
Jun 10, 2017
2,304
2,612
um, nope. a variable defined in a screen is only valid for this screen no matter what. it's not accessible from outside the screen even if said screen is displayed.
Oh... Well, I'll update my notes regarding compatibility ; I should have forgot to verify if it changed at some time.
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
3,138
6,804
hmm, i don't think that there were any changes lately. for instance saving in a choice menu wouldn't be possible, if screenvariables would be accessable outside their scope. both involved standard Ren'Py screens use a variable named i, one as object for the menu choices the other as a simple iterator for save_load slots.
 

anne O'nymous

Well-Known Member
Modder
Respected User
Jun 10, 2017
2,304
2,612
hmm, i don't think that there were any changes lately.
I don't necessarily talk about lately.
For to be effectively useful, my Variable Extended Viewer have to be able to works with as many version of Ren'py as possible. So, I started with what was the last version at this time, the 6.99.12.4. Then, once I had a working code, I tried it with previous versions, correcting the problems as I went, until it the correction implied too much works for the few possible games still available.
It sent me five years back in time and taught me a lot about Ren'py, but if I had to do it again now, I would probably do the opposite, starting with an old version. The number of time backward compatibility have been broke being very low compared to the time where something was added.
This said, perhaps that it's not exactly an effective change in the behavior, but that this part of the code was just broke at one time. I wasn't always rigorous with my notes because it was sometimes more depressive than anything else to do this monkey works.
 

anne O'nymous

Well-Known Member
Modder
Respected User
Jun 10, 2017
2,304
2,612
Hello,
I want to know if there is a way to make this more simple?
Now that I had the time to took a look at the game, and so the context, the way to make this more simple is something totally different. And it will not only make this screen simpler, but the whole game.
You don't need ConditionSwitch for your images, because text interpolation works with the image statement. This mean that instead what you have actually, by example this :
Code:
image side kid surprised sport = ConditionSwitch(
    "b.race == 0", "/tom/tom surprised sport.png",
    "b.race == 1", "/j3/j3 surprised sport.png",
    "b.race == 2", "/lee/lee surprised sport.png",
    "b.race == 3", "/ricardo/ricardo surprised sport.png")
you can just write this :
Code:
image side kid surprised sport = "[b.race]/[b.race] surprised sport.png"
With b.race being either "tom", "j3", "lee" or "ricardo".

It will need a little more works since you'll have to define all MC's images, but in the end it will be less works than what you're actually facing. Oh, and it will also have to make the next version incompatible with actual save, but well it's already the case for this update.

So, reported to the specific question you asked here, firstly, remove "tom jumping sport", "j3 jumping sport", "ricardo jumping sport" and "lee jumping sport" definition, they are now useless. And the code become this :
Code:
image kid jumping sport = "[b.race]/[b.race] jumping sport.png"

image kid jumping anim:
    "[b.race]/[b.race] jumping01.png"
    0.2
    "[b.race]/[b.race] jumping02.png"
    0.1
    "[b.race]/[b.race] jumping03.png"
    0.1
    "[b.race]/[b.race] jumping04.png"
    0.1
    "[b.race]/[b.race] jumping05.png"
    0.2
    "[b.race]/[b.race] jumping04.png"
    0.1
    "[b.race]/[b.race] jumping03.png"
    0.1
    "[b.race]/[b.race] jumping01.png"

screen minigame_jumping_jacks:
    [...] 

    hbox:
        xalign 0.5
        yalign 0.54
        if jumping:
            imagebutton auto "/gui/jump_%s.png":
                xalign 0.5
                action [ Function(renpy.hide,"kid jumping sport"), Function(renpy.show,"kid jumping anim", at_list=[kid_jump]), SetVariable("jj", jj+ 1), SetVariable("b.stamina", b.stamina-1), Play("sfx3", "/sfx/click.mp3"), Play("sfx1", "/sfx/clap.mp3"), SetVariable("jumping", False)]
                at ( customzoom if renpy.variant("touch") else customzoom2 )
        else:
            imagebutton idle "/gui/jump_disabled.png":
                xalign 0.5
                action NullAction()
                at ( customzoom if renpy.variant("touch") else customzoom2 )
            timer 1.0 action SetVariable("jumping", True)

        if jj >= 50:
            timer 0.1 action [Hide("minigame_jumping_jacks", transition=dissolve), Jump("jumping_jacks_win"), SetVariable("jj", 0), SetVariable("cristina.jj", 0)]
 
  • Love
Reactions: jon95