Return won't end game, causes crash or loop [SOLVED]

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.
Message
Author
User avatar
illuminate001
Veteran
Posts: 412
Joined: Thu Jul 02, 2009 1:46 pm
Completed: DSGR, Let's MEAT Adam, Sexy Litter, Bara Boarders
Projects: Secret Project
Organization: Soulsoft Electronic Arts
Tumblr: soulsoftea
itch: soulsoftea
Location: Orlando, FL
Contact:

Return won't end game, causes crash or loop [SOLVED]

#1 Post by illuminate001 »

Hi guys,

I'd appreciate some help here. Im using menu: and should the player select the wrong choice, there's abit of dialog and then a Return statement. This should cause the game to end and bring the player back to the Main Menu.

Problem is the Return statement causes the game to attempt to loop back to a screen I called previously (which I thought I had hid or removed) before crashing out.

Here is the crashdump:

Code: Select all

[code]
I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 7078, in script
    call screen pick_partner1
  File "renpy/common/000statements.rpy", line 471, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "renpy/common/00action_data.rpy", line 50, in get_selected
    return getattr(self.object, self.field) == self.value
AttributeError: 'StoreModule' object has no attribute 'picked_lucky'

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

Full traceback:
  File "game/script.rpy", line 7078, in script
    call screen pick_partner1
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\ast.py", line 1706, in execute
    self.call("execute")
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\ast.py", line 1724, in call
    return renpy.statements.call(method, parsed, *args, **kwargs)
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\statements.py", line 145, in call
    return method(parsed, *args, **kwargs)
  File "renpy/common/000statements.rpy", line 471, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\exports.py", line 2521, in call_screen
    rv = renpy.ui.interact(mouse="screen", type="screen", roll_forward=roll_forward)
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\ui.py", line 285, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\display\core.py", line 2492, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\display\core.py", line 2759, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\display\core.py", line 482, in visit_all
    d.visit_all(callback)
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\display\core.py", line 482, in visit_all
    d.visit_all(callback)
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\display\core.py", line 482, in visit_all
    d.visit_all(callback)
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\display\screen.py", line 403, in visit_all
    self.child.visit_all(callback)
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\display\core.py", line 482, in visit_all
    d.visit_all(callback)
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\display\core.py", line 484, in visit_all
    callback(self)
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\display\core.py", line 2759, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\display\behavior.py", line 788, in per_interact
    if self.is_selected():
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\display\behavior.py", line 778, in is_selected
    return is_selected(self.action)
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\display\behavior.py", line 356, in is_selected
    return any(is_selected(i) for i in action)
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\display\behavior.py", line 356, in <genexpr>
    return any(is_selected(i) for i in action)
  File "C:\Users\John John\Desktop\John\Games\renpy\renpy\display\behavior.py", line 359, in is_selected
    return action.get_selected()
  File "renpy/common/00action_data.rpy", line 50, in get_selected
    return getattr(self.object, self.field) == self.value
AttributeError: 'StoreModule' object has no attribute 'picked_lucky'

Windows-8-6.2.9200
Ren'Py 6.99.12.2.2029
LetsMeatAdam 0.0
[/code]
Last edited by illuminate001 on Thu Mar 30, 2017 12:05 pm, edited 1 time in total.
ImageImage
ImageImage

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Return won't end game, causes crash or loop

#2 Post by Alex »

Check if you've set the default value for "picked_lucky" variable.

User avatar
illuminate001
Veteran
Posts: 412
Joined: Thu Jul 02, 2009 1:46 pm
Completed: DSGR, Let's MEAT Adam, Sexy Litter, Bara Boarders
Projects: Secret Project
Organization: Soulsoft Electronic Arts
Tumblr: soulsoftea
itch: soulsoftea
Location: Orlando, FL
Contact:

Re: Return won't end game, causes crash or loop

#3 Post by illuminate001 »

Hi Alex! I believe I have...it's set in the code right before I define the screen which happens to be the one that the game, after hitting a Return, wants to loops back to:

Code: Select all

    scene bg pickpartner
    with dissolve
    default picked_bart = False
    default picked_lucky = False
    default picked_pierce = False
I'm starting to think there's something wrong with the screen itself and I'm calling it improperly causing some weird loop that results in a crash. I posted the full screen code below and perhaps someone will see where I went wrong?

Code: Select all

    scene bg pickpartner
    with dissolve
    default picked_bart = False
    default picked_lucky = False
    default picked_pierce = False

    screen pick_partner1():

        imagebutton:
            idle "gui/main_bart_idle.png"
            hover "gui/main_bart_hover.png"
            action [ Hide("pick_partner1"), Show("pick_partner1_b"), SetVariable("picked_bart", True) ]
            #clicked [ SetVariable("picked_bart", True) ]
            xpos 335 ypos 370
            xanchor 0 yanchor 0

        imagebutton:
            idle "gui/main_lucky_idle.png"
            hover "gui/main_lucky_hover.png"
            action [ Hide("pick_partner1"), Show("pick_partner1_l"), SetVariable("picked_lucky", True) ]
            #clicked [ SetVariable("picked_lucky", True) ]
            xpos 750 ypos 370
            xanchor 0 yanchor 0

        imagebutton:
            idle "gui/main_pierce_idle.png"
            hover "gui/main_pierce_hover.png"
            action [ Hide("pick_partner1"), Show("pick_partner1_p"), SetVariable("picked_pierce", True) ]
            #clicked [ SetVariable("picked_pierce", True) ]
            xpos 1165 ypos 370
            xanchor 0 yanchor 0

    call screen pick_partner1

    screen pick_partner1_b():

        imagebutton:
            idle "gui/main_bart_hover.png"
            hover "gui/main_bart_hover.png"
            xpos 335 ypos 370
            xanchor 0 yanchor 0

        imagebutton:
            idle im.Grayscale("gui/main_lucky_idle.png") 
            hover im.Grayscale("gui/main_lucky_idle.png")
            xpos 750 ypos 370
            xanchor 0 yanchor 0

        imagebutton:
            idle im.Grayscale("gui/main_pierce_hover.png") 
            hover im.Grayscale("gui/main_pierce_hover.png")
            xpos 1165 ypos 370
            xanchor 0 yanchor 0

        imagebutton:
            idle "gui/main_lucky_idle.png"
            hover "gui/main_lucky_hover.png"
            action Hide("pick_partner1_b"), Jump("lucky_left")
            xpos 750 ypos 680
            xanchor 0 yanchor 0

        imagebutton:
            idle "gui/main_pierce_idle.png"
            hover "gui/main_pierce_hover.png"
            action Hide("pick_partner1_b"), Jump("pierce_left")
            xpos 1165 ypos 680
            xanchor 0 yanchor 0

    screen pick_partner1_l():

        imagebutton:
            idle "gui/main_lucky_hover.png"
            hover "gui/main_lucky_hover.png"
            xpos 750 ypos 370
            xanchor 0 yanchor 0

        imagebutton:
            idle im.Grayscale("gui/main_bart_idle.png") 
            hover im.Grayscale("gui/main_bart_idle.png")
            xpos 335 ypos 370
            xanchor 0 yanchor 0

        imagebutton:
            idle im.Grayscale("gui/main_pierce_idle.png") 
            hover im.Grayscale("gui/main_pierce_idle.png")
            xpos 1165 ypos 370
            xanchor 0 yanchor 0

        imagebutton:
            idle "gui/main_bart_idle.png"
            hover "gui/main_bart_hover.png"
            action Hide("pick_partner1_l"), Jump("bart_left")
            xpos 335 ypos 680
            xanchor 0 yanchor 0

        imagebutton:
            idle "gui/main_pierce_idle.png"
            hover "gui/main_pierce_hover.png"
            action Hide("pick_partner1_l"), Jump("pierce_left")
            xpos 1165 ypos 680
            xanchor 0 yanchor 0

    screen pick_partner1_p():

        imagebutton:
            idle "gui/main_pierce_hover.png"
            hover "gui/main_pierce_hover.png"
            xpos 1165 ypos 370
            xanchor 0 yanchor 0

        imagebutton:
            idle im.Grayscale("gui/main_lucky_idle.png")
            hover im.Grayscale("gui/main_lucky_idle.png")
            xpos 750 ypos 370
            xanchor 0 yanchor 0

        imagebutton:
            idle im.Grayscale("gui/main_bart_idle.png") 
            hover im.Grayscale("gui/main_bart_idle.png")
            xpos 335 ypos 370
            xanchor 0 yanchor 0

        imagebutton:
            idle "gui/main_bart_idle.png"
            hover "gui/main_bart_hover.png"
            action Hide("pick_partner1_p"), Jump("bart_left")
            xpos 335 ypos 680
            xanchor 0 yanchor 0

        imagebutton:
            idle "gui/main_lucky_idle.png"
            hover "gui/main_lucky_hover.png"
            action Hide("pick_partner1_p"), Jump("lucky_left")
            xpos 750 ypos 680
            xanchor 0 yanchor 0
ImageImage
ImageImage

User avatar
Scribbles
Miko-Class Veteran
Posts: 636
Joined: Wed Sep 21, 2016 4:15 pm
Completed: Pinewood Island, As We Know It
Projects: In Blood
Organization: Jaime Scribbles Games
Deviantart: breakfastdoodles
itch: scribbles
Location: Ohio
Contact:

Re: Return won't end game, causes crash or loop

#4 Post by Scribbles »

I had issues with return not working when I had jumps inside of call labels. so like:

Code: Select all


"blah blah"

call label_1

label label_1:
"stuff"
jump label_2

label label_2:
return #<- it would then return to the line after call label_1 because it never returned after it was initially called.

could it be something like that? Always return within the label you call, and never use jump to avoid that issue is what I found helps lol
Image - Image -Image

User avatar
illuminate001
Veteran
Posts: 412
Joined: Thu Jul 02, 2009 1:46 pm
Completed: DSGR, Let's MEAT Adam, Sexy Litter, Bara Boarders
Projects: Secret Project
Organization: Soulsoft Electronic Arts
Tumblr: soulsoftea
itch: soulsoftea
Location: Orlando, FL
Contact:

Re: Return won't end game, causes crash or loop

#5 Post by illuminate001 »

Hey Scribbles! Good to see ya again! :P

Ooh! You know what, that sounds like that could be the issue here...I have been using TONS of jumps inside of call labels lately. Hmmm...

Ok I'm going to see if I can fix this and then I'll post an update. I'm tired since I've been scripting all day so I may post the update tomorrow ish. Thanks again!
ImageImage
ImageImage

User avatar
Scribbles
Miko-Class Veteran
Posts: 636
Joined: Wed Sep 21, 2016 4:15 pm
Completed: Pinewood Island, As We Know It
Projects: In Blood
Organization: Jaime Scribbles Games
Deviantart: breakfastdoodles
itch: scribbles
Location: Ohio
Contact:

Re: Return won't end game, causes crash or loop

#6 Post by Scribbles »

illuminate001 wrote:Hey Scribbles! Good to see ya again! :P

Ooh! You know what, that sounds like that could be the issue here...I have been using TONS of jumps inside of call labels lately. Hmmm...

Ok I'm going to see if I can fix this and then I'll post an update. I'm tired since I've been scripting all day so I may post the update tomorrow ish. Thanks again!
I've used jumps to, but as long as they all eventually end at common label, and then it returns back to the original code it should be ok. I think. Maybe. good luck!
Image - Image -Image

User avatar
illuminate001
Veteran
Posts: 412
Joined: Thu Jul 02, 2009 1:46 pm
Completed: DSGR, Let's MEAT Adam, Sexy Litter, Bara Boarders
Projects: Secret Project
Organization: Soulsoft Electronic Arts
Tumblr: soulsoftea
itch: soulsoftea
Location: Orlando, FL
Contact:

Re: Return won't end game, causes crash or loop

#7 Post by illuminate001 »

Scribbles wrote:I've used jumps to, but as long as they all eventually end at common label, and then it returns back to the original code it should be ok. I think. Maybe. good luck!
Hey Scribbles, goodmorning! So I'm not sure what you mean by "eventually end at common label". What is "Common label"?. Also, what do you mean by returns back to original code? Good news is after I started cleaning up the code a bit I was able to get it to not crash on Return, but now it still loops and just before that same call screen function.

Also instead of reworking a bunch of code only to find it didn't work I did a test and removed the "call" function. So instead of:

Code: Select all

call screen pick_partner1
I tried...

Code: Select all

show screen pick_partner1
So now there definitely wouldn't be any jumps within call labels. Unfortunately, it still loops so it must be a different issue... :| Also I can't avoid using all the Jumps because clicking these buttons picks a character to be your partner, then jumps you to a label containing your story interaction with that character.

Ugh this issue is so very frustrating...
ImageImage
ImageImage

User avatar
Scribbles
Miko-Class Veteran
Posts: 636
Joined: Wed Sep 21, 2016 4:15 pm
Completed: Pinewood Island, As We Know It
Projects: In Blood
Organization: Jaime Scribbles Games
Deviantart: breakfastdoodles
itch: scribbles
Location: Ohio
Contact:

Re: Return won't end game, causes crash or loop

#8 Post by Scribbles »

Oh, i just meant a common label like:

Code: Select all


"Stuff"
call label_you_call
"you chose: [option]" #would display whatever number the player selected
return #would end the game (HOPEFULLY!)

label label_you_call:
     "Stuff Happens."
     menu:
          "Option 1":
                   $ option = 1
                   jump label_you_call_over
          "Option 2":
                   $ option = 2
                   jump label_you_call_over

label label_you_call_over: #this would be the common label I meant, where all of the jumps end up eventually
     return #returns back to the line after the call
I'm still really new to code so I'm not sure how else to help I'm afraid :( Hopefully someone else comes along with a solution!
Image - Image -Image

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Return won't end game, causes crash or loop

#9 Post by trooper6 »

I'm at an airport on my iPhone, so I can't be super detailed. However, looking at your code in your second post, it looks like you have organizational problems.

It looks like you have your default variable declarations and your screen definitions inside of a label (because they are all indented).

Those things are not part of a label, they are independent of the labels, so they should be placed outside of a label.

You want:

Code: Select all

default lucky = False

screen backpack():
    text "Blah blah"

label start:
    "blah blah"
Start by fixing that part first.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
illuminate001
Veteran
Posts: 412
Joined: Thu Jul 02, 2009 1:46 pm
Completed: DSGR, Let's MEAT Adam, Sexy Litter, Bara Boarders
Projects: Secret Project
Organization: Soulsoft Electronic Arts
Tumblr: soulsoftea
itch: soulsoftea
Location: Orlando, FL
Contact:

Re: Return won't end game, causes crash or loop

#10 Post by illuminate001 »

@Scribbles - Ok I tried your suggestion and made all the jumps go to one label that results in a return. Once again it doesnt work. :cry: It still loops. I think it has something to do with my organization of code and possibly how I use/misuse calls?

@Trooper6 - Hey there! I tried to fix the organization by taking any variables and declaring them at the top of my script even before the game starts (ie. label start). I also did the same for defining screens. So now no variables or screen definitions of any kind are within labels. Same issue, still looping. =(
ImageImage
ImageImage

User avatar
indoneko
Miko-Class Veteran
Posts: 528
Joined: Sat Sep 03, 2016 4:00 am
Contact:

Re: Return won't end game, causes crash or loop

#11 Post by indoneko »

Perhaps you can attach the full script here? (trim it first to minimum lines needed to replicate the problem)
My avatar is courtesy of Mellanthe

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Return won't end game, causes crash or loop

#12 Post by trooper6 »

I have done "choose people" screens before, and I'm looking at your code more carefully.

Could you explain what exactly you want to happen here with this section of code? It might help me figure out a way to fix it.

This is what I'm seeing in outline form.

0. You have three variables, picked_bart, picked_lucky, picked_pierce. This looks like it is about deciding who your partner is going to be.
1. You call your first screen pick_partner1. On this screen you pick one of the three people. When you pick a person, it changes that person's variable to True, then sends you to another screen.
2. On this next screen, you pick another person. Picking this second person does not change any variables at all, it just sends you to a label (bart_left, pierce_left, lucky_left).

So what is the point of the second screen? What is the point of the bart, pierce, lucky_left labels? What do they do?
I suspect that you can probably just have one screen to do what you want, if you adjust how you deal with your variables a bit. I just don't quite know what exactly you want to happen?

Is the player choosing two people to be partners? Or what?
Let's say the player chooses Lucky then Bart. So we get the picked_lucky variable to be True. What does choosing Bart second mean practically? What does not choosing Pierce mean practically. Let me know what you are actually trying to do here?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
illuminate001
Veteran
Posts: 412
Joined: Thu Jul 02, 2009 1:46 pm
Completed: DSGR, Let's MEAT Adam, Sexy Litter, Bara Boarders
Projects: Secret Project
Organization: Soulsoft Electronic Arts
Tumblr: soulsoftea
itch: soulsoftea
Location: Orlando, FL
Contact:

Re: Return won't end game, causes crash or loop

#13 Post by illuminate001 »

@Indoneko - Hi Indoneko! I decided to post a link to the entire script only because as as I'm cleaning/tightening the code up...I discovered there's 2 (very distinct) points in the entire game(code) where things loop back to. So I believe it's an endemic problem with how I'm coding/structure. :cry: I know it's a lot to look at and I'm terribly sorry, but I think I'm at my capacity of being able to solve this issue.

SCRIPT
https://paste.ofcode.org/DqPdE7QUTGhfktesTqxxyv

Right now I'm trying to figure out what these 2 points of looping have in common code-wise. They both seem to be after the results of menus that are called via screens. I've put in comments just look for "WEIRD LOOPING" and you'll see the points where the game loops back to. Also there's some temp shit in there to test if Return works, so in the last menu all actions lead to the label "death".



@Trooper6 - Hey Troop, thanks so much for your help I really appreciate it!
Image
The point of the 1st screen is to pick your partner for the next Puzzle Room. Doing so then opens a "2nd screen" which hides your partner as an option to leave behind and only shows the remaining 2 as options to leave behind.

In this case let's say you picked Lucky as your partner and chose to leave behind Bart. Storywise, Lucky would accompany you into the next room while Bart would be left behind (in this case die) and then Pierce would continue on living/existing in the story but just not as your partner this round.

The labels "lucky_left", "bart_left"etc. jumps you to that label in code where you see the result (the story drama) of what happens after leaving Lucky behind or Bart etc.
ImageImage
ImageImage

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Return won't end game, causes crash or loop

#14 Post by trooper6 »

Okay, I'm currently at work and won't be at home until much later tonight, but I have an idea how to solve your screen problem. I'll edit this post once I get in and have a chance to muck about. I don't think it'll be a difficult fix at all. At least for this part. I haven't looked at your other code. But maybe showing you how I fix that will help with other things!
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Return won't end game, causes crash or loop

#15 Post by philat »

trooper6 would probably explain this better (and nicer! ;) ) so I apologize in advance, but I'm bored at work today so I'm taking a stab at this. Ahem.

I haven't looked at the whole thing, but basically it seems like you don't return from the called screen. You show Hide(), Show(), and SetVariable() but don't Return(). Mind you, I'm not entirely sure this is the root of the problem -- because the effect called screens have on the flow has never been entirely clear to me and I haven't looked further down the line to see what happens after you jump, but it's easily fixable and if it works, great! :P

I took the liberty of rewriting the script a bit for optimization's sake; if nothing else, I think it should help you get more familiar with renpy screens.

Goals: Not having three different variants of the same screen, not showing/hiding between the two stages of the screen since it makes the logic more confusing, and not Jump()ing directly from the screen -- not that there's anything wrong with it, but my personal philosophy is that especially if you're newer to renpy, it makes keeping track of the flow simpler if you return to renpy script for the flow control parts instead of doing it from within screens.

Code: Select all

default picked = None # instead of picked_bart, picked_lucky, etc., I have one picked and one left variable.
default left = None

screen pick_partner():

    hbox: # this is where you pick who to take
        ypos 370
        # seems easier to determine xpos through spacing and align (I mean, you don't have to, it's just simpler)
        
        imagebutton:
            idle "gui/main_bart_idle.png"
            hover "gui/main_bart_hover.png"
            selected_idle "gui/main_bart_hover.png" 
            insensitive im.Grayscale("gui/main_bart_idle.png") 
            # selected_idle and insensitive are documented in the imagebutton documentation and will make your life easier
            action [ SensitiveIf(picked==None), SetVariable("picked", "bart") ] # SensitiveIf is also documented under screen actions if you want to learn more

        imagebutton:
            idle "gui/main_lucky_idle.png"
            hover "gui/main_lucky_hover.png"
            selected_idle "gui/main_lucky_hover.png"
            insensitive im.Grayscale("gui/main_lucky_idle.png") 
            action [ SensitiveIf(picked==None), SetVariable("picked", "lucky") ]

        imagebutton:
            idle "gui/main_pierce_idle.png"
            hover "gui/main_pierce_hover.png"
            selected_idle "gui/main_pierce_hover.png"
            insensitive im.Grayscale("gui/main_pierce_idle.png") 
            action [ SensitiveIf(picked==None), SetVariable("picked", "pierce") ]

    if picked: # once picked has a value other than None, the hbox below will show up so you can choose who to leave. Until then, it's hidden.
        hbox:
            ypos 680
            # same as above -- I put it in an hbox because I don't want to deal with xpos numbers, but feel free to change

            imagebutton:
                idle "gui/main_bart_idle.png"
                hover "gui/main_bart_hover.png"
                selected_idle "gui/main_bart_hover.png"
                insensitive im.Grayscale("gui/main_bart_idle.png") 
                action [ SensitiveIf(picked!="bart"), SetVariable("left", "bart"), Return() ] 
                # is sensitive only if picked is not "bart" -- i.e., you can't choose to both take and leave bart. 
                # Also returns from the called screen -- you can also do this with Show and Hide and modal if you'd prefer.

            imagebutton:
                idle "gui/main_lucky_idle.png"
                hover "gui/main_lucky_hover.png"
                selected_idle "gui/main_lucky_hover.png"
                insensitive im.Grayscale("gui/main_lucky_idle.png") 
                action [ SensitiveIf(picked!="lucky"), SetVariable("left", "lucky"), Return() ]

            imagebutton:
                idle "gui/main_pierce_idle.png"
                hover "gui/main_pierce_hover.png"
                selected_idle "gui/main_pierce_hover.png"
                insensitive im.Grayscale("gui/main_pierce_idle.png") 
                action [ SensitiveIf(picked!="pierce"), SetVariable("left", "pierce"), Return() ]

label picky:
    scene bg pickpartner
    with dissolve

    call screen pick_partner()

    jump expression left + "_left" # jumps to bart_left / lucky_left / pierce_left depending on the value of the variable left

    # return <- this return does nothing and I'm not sure why it's there. Once you jump to the next label, you shouldn't be coming back here at all

In the area of general tips, indenting labels is frowned upon -- technically, it may not matter as much because the compiler will fix that for you (same with having screens declared inside labels), but it makes reading the script more difficult and having multiple levels of indentation can easily lead to more errors than otherwise.

Post Reply

Who is online

Users browsing this forum: No registered users