• To improve security, we will soon start forcing password resets for any account that uses a weak password on the next login. If you have a weak password or a defunct email, please update it now to prevent future disruption.

Ren'Py Renpy sandbox help

SweetGames

Newbie
Jan 1, 2023
26
3
hello the navigation system works great, but there is one thing that bothers me.

when i click on the map from home, the travelUI shows all the buttons


Python:
screen travelUI():

    imagebutton:
        xalign 0.51 yalign 0.61 idle "images/citybuttons/home_idle.png" hover "images/citybuttons/home_hover.png"
        # While be not sensitive (so not clickable) if there's no travel value, from the
        # current location to "home" ; what mean that it's where we are.
        sensitive not travelTime[currentLocation]["home"] is None
        # A screen to select how to move, passing it the expected destination.
        if currentLocation == "home":
            action Jump("homeHub")
        else:
            action ShowMenu("moveScreen", "home")

    imagebutton:
        xalign 0.65 yalign 0.40 idle "images/citybuttons/park_idle.png" hover "images/citybuttons/park_hover.png"
        sensitive not travelTime[currentLocation]["park"] is None
        if currentLocation == "park":
            action Jump("parkHub")
        else:
            action ShowMenu("moveScreen", "park")

For example, I select the park and the movescreen appears

However, all buttons of the travelUI only disappear the first time.

if i now go to the park and back to the map, for example, i can click on every button of the travelUI and they do not disappear
.

I have tried the

Python:
else:
    action ShowMenu("moveScreen", "park")
[/CODE]

to change to show but then i get a str error. i have also tried

action [Show("traveilUI"), Show("("moveScreen", "park")] but then the same error occurs only if I use ShowMenu at the end the error does not occur. but the traveilui is not visible.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,202
14,939
hello the navigation system works great, but there is one thing that bothers me.
Well, let's see...


when i click on the map from home, the travelUI shows all the buttons
It's what the if statement is for, to discriminate accordingly to the context. Here, to define what is to show and what isn't to show.

You just need to define the shown button accordingly to the location(s) where they are relevant. Something like:
Python:
screen travelUI():

    [...]

    if currentLocation in [ "whatever", "whateverElse" ]:
        imagebutton:
            [...]
        imagebutton:
            [...]
    elif currentLocation == "someOtherLocation":
        imagebutton:
            [...]
        imagebutton:
            [...]
    [...]
Note that here I defined the button by blocks, assuming that there's locations that are only relevant when in a room at home, by example, while others are only relevant when here or there.
But it's perfectly possible to define this button by button, to have each location only available from the adjacent locations by example.


Python:
        # While be not sensitive (so not clickable) if there's no travel value, from the
        # current location to "home" ; what mean that it's where we are.
        sensitive not travelTime[currentLocation]["home"] is None
        # A screen to select how to move, passing it the expected destination.
        if currentLocation == "home":
            action Jump("homeHub")
        else:
            action ShowMenu("moveScreen", "home")
Hmm... It kind of looks like the comment lines say that it's impossible to click on the button if it correspond to the current location.
Therefore, the if is totally useless, because the action property will only be processed if you click on the button ; I'm almost sure that it's said in the doc.

As for the ShowMenu screen action, it do not do what you think, and absolutely not have its place here ; this too I'm almost sure that it's said in the doc.


For example, I select the park and the movescreen appears

However, all buttons of the travelUI only disappear the first time.
Why should they disappear ? I'm almost sure that the doc say that a shown screen is displayed until it is explicitly hidden.
For once that there's a screen that should be hidden...

And, I know, you said it, the buttons disappear the first time...
It's because you use ShowMenu. But like you have absolutely no idea what this screen action do, you also don't understand the behavior you witness, not see why it's relatively obvious that Ren'Py behave that way.
You totally changed the game state, passing Ren'Py in game menus context (load, save, etc.), instead of keeping it in game context. It's the reason why they disappear the first time, because there's no reason to show the content of the game when you are in a game menu. And it's the reason why they don't disappear after that, because you never leaved the game menu...
Congratulation, you totally broke Ren'Py. It's something I don't witness often.



All your errors are purely logical, and just thinking about what you want to do would solve them.

There's a reason why a programmer write an average of 50 lines of code by day. It's an average, it include the days he stayed in front of his computer, looking at his code and thinking about what he want to do next and how he can do it. Then, once he found the answers, he can perfectly write 200 lines in one day, because now he know what he's doing.

But, well, as an anonymous once said, "weeks of coding can save you hours of planning". I get it, you pass your free time trying to blindly guess what should be done, to the point that you don't have time to at least browse the doc, nor even read the comment lines you copy/past, therefore you also don't have time to think.
Yet, the fact is that programming is before everything else thinking ; especially with Ren'Py that is relatively versatile. Knowledge only come in second, and grow through the application of the solutions you came with. Even the few broken equivalent for call screen come from a deep thinking ; they searched how to force the game to stay at this screen, and found a logical, but broken as I said, way to do it.

But, what I'm saying doesn't matters. It's your code game, you do what you want, and do it with the seriousness, or lack of, you want...


Just an advice, there's not this many people here able to answer nearly all Ren'Py coding issue. Try to not tires them, who know, you can still need their help in the future.
 
  • Haha
Reactions: peterppp