- Jun 14, 2018
- 1,611
- 2,258
Okay. I know programming (ish). I don't know Python/RenPy especially well.
So there's something odd going on with the call / return stack in the game I'm trying to update/fix.
I think the original author is making a basic mistake, but I don't know RenPy well enough to properly diagnose it.
The author has discovered "call / return"... and seems to love it.
A completely linear story has recent chapters which feature it all over the place.
Except, some testing I just did - ends up with the game ending (normally) and then returning back to previous point in the code (a called label)... executing it a second time... and THEN ending.
Hence my assumption about a basic programming mistake.
Question #1.
My previous programming experience says it's probably a mismatched return stack - but I don't know the console/debug command to list the outstanding returns.
Looking through the code, the only thing I can see him doing that looks "off" to me is a combination of these two (coding mistakes)?:
Note, this is just my example. The real code is similar enough to get the point of the issue that may or may not be there. Obviously the original isn't quite this dumb.
Question #2.
Can you code conditional "return" statements?
and/or have multiple "return" statements within a single label?
Question #3.
Is it okay to jump from one label to another and then expect the "return" to honor the original call?
It's the sort of thing my original tutor would have had a fit at... but maybe Python/RenPy is fine with this sort of stuff...
I figure one or both of these coding fragments is responsible for my odd call/return behavior. But then again... maybe I'm completely barking up the wrong tree.
So there's something odd going on with the call / return stack in the game I'm trying to update/fix.
I think the original author is making a basic mistake, but I don't know RenPy well enough to properly diagnose it.
The author has discovered "call / return"... and seems to love it.
A completely linear story has recent chapters which feature it all over the place.
Except, some testing I just did - ends up with the game ending (normally) and then returning back to previous point in the code (a called label)... executing it a second time... and THEN ending.
Hence my assumption about a basic programming mistake.
Question #1.
My previous programming experience says it's probably a mismatched return stack - but I don't know the console/debug command to list the outstanding returns.
Looking through the code, the only thing I can see him doing that looks "off" to me is a combination of these two (coding mistakes)?:
Code:
label start:
call lb_my_subroutine
call lb_other_subroutine
return
label lb_my_subroutine:
if var1 == True:
return
pc "I said something clever"
return
label lb_other_subroutine:
if var1 == True:
jump lb_sub2_label1
jump lb_sub2_label2
label lb_sub2_label1:
pc "this is subroutine 2, exit #1"
return
label lb_sub2_label2:
pc "this is subroutine 2, exit #2"
return
Question #2.
Can you code conditional "return" statements?
and/or have multiple "return" statements within a single label?
Question #3.
Is it okay to jump from one label to another and then expect the "return" to honor the original call?
It's the sort of thing my original tutor would have had a fit at... but maybe Python/RenPy is fine with this sort of stuff...
I figure one or both of these coding fragments is responsible for my odd call/return behavior. But then again... maybe I'm completely barking up the wrong tree.