Renpy game loop with return statement

ayerkgzhkx

New Member
Jun 22, 2020
6
0
I have functional image map and hud. However the main game loop seems to be broken due to adding return stements.
What ever I do the game ends and I a not able to make the main game loop to work

Code:
label start:
    e "Hello"
    label alabel:
        e "Hello alabel"

    label zlabel:
        e "Hello zlabel"

        $ count =1
        jump cityMap
        $ count = count + 1
        $ renpy.notify(count)

        $ renpy.pause(9999999999)
        `textbutton "Menu" action cqmAction style "openButton"`

jump zlabel

jump alabel


screen cityMap(n_map):
    add "CityMap"   

    imagebutton auto "./menu/citymap_mc_house_%s.png":
        focus_mask "citymap_mc_house_idle"
        action Jump("mcHouse")
    imagebutton auto "./menu/citymap_b1_%s.png":
        focus_mask "citymap_b1_idle"
        action Notify ("mcHouse")
    imagebutton auto "./menu/citymap_b2_%s.png":
        focus_mask "citymap_b2_idle"
        action Notify ("mcHouse")
    imagebutton auto "./menu/citymap_b3_%s.png":
        focus_mask "citymap_b3_idle"
        action Notify ("mcHouse")
    imagebutton auto "./menu/underconstruction_%s.png":
        focus_mask "underconstruction_idle"
        action Notify ("Under Construction to greedy perv. Wait !!")
    use hud("CityMap")



screen hud(n_map):
    
    imagebutton auto "./menu/hud_inventory_mask_%s.png":
        focus_mask "hud_inventory_mask_idle"
        action Call ("hud_inventory_mask")

    imagebutton auto "./menu/hud_memo_mask_%s.png":
        focus_mask "hud_memo_mask_idle"
        action Jump ("hud_memo_mask")

    if phoneNotification ==True:
        imagebutton auto "./menu/hud_phone_mask_notify_%s.png":
            focus_mask "hud_phone_mask_notify_idle"
            action Jump("hud_phone_mask"
    else:
        imagebutton auto "./menu/hud_phone_mask_%s.png":
            focus_mask "hud_phone_mask_idle"
            action Jump("hud_phone_mask"

    if n_map!="CityMap":
        imagebutton auto "./menu/hud_map_mask_%s.png":
            focus_mask "hud_map_mask_idle"
            action Jump ("cityMap")
    else:
        imagebutton auto "./menu/hud_mcroom_%s.png":
            focus_mask "hud_mcroom_idle"
            action Notify ("hud_mcroom")



label hud_inventory_mask:
    $ renpy.notify("Bag Clicked !!")
    $ renpy.pause(9999999999)

label hud_map_mask:
    $ renpy.notify("map Clicked !!")
    $ renpy.pause(9999999999)
    jump Chapter1
return

label hud_memo_mask:
    $ renpy.notify("memo Clicked !!")
    $ renpy.pause(9999999999)

    `textbutton "Menu" action cqmAction style "openButton"`
 
    return
label hud_phone_mask:

    $ renpy.notify("phone Clicked !!")
    $ phoneNotification=False
    jump phoneEngine

    return

label phone_discussion_test_end:
    $ renpy.notify("Calling Chapter1")
    jump Chapter1
    return
 

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,092
3,337
I hope that the weird formatting, and the thing with the backticks was due to your frustration in trying to fix the error, because there is no way that would work.

Regardless, as peterppp said, the issue is how you show your map screen.

Code:
    jump cityMap
should be
Code:
    call screen cityMap()
But even then some stuff is a bit wonky (like jumping out of the screen, this is dangerous unless you know what you are doing). You should consider this following design instead:
Code:
label start:
    e "yo we started"
    jump main_loop

label main_loop:
    e "main loop yo"

    # before entering your main UI screen, you can put all your game logic here (time of day, special event activations etc)

    # "call screen" not "show screen" or "jump"
    call screen cityMap()  

    # this is the main "router". it uses the magic "_return" global value that is set by the Return("xxx") action on your buttons
    if _return == "mcHouse":
        jump mcHouse
    elif _return == "anotherLocation":
        jump anotherLocation

    # (etc etc for other map locations)

    end

screen cityMap(n_map):
    add "CityMap"

    imagebutton auto "./menu/citymap_mc_house_%s.png":
        focus_mask "citymap_mc_house_idle"
        action Return("mcHouse")   # note this is RETURN not JUMP

label mcHouse:
    e "you molest your mother/sister"
    jump main_loop
NOTE: this was written just in the comments, not using renpy environment, i have not tested it and there may be syntax errors. use at your own risk, dawg
 
Last edited:
  • Like
Reactions: peterppp

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,111
14,790