Hiding back button in UI

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.
Post Reply
Message
Author
User avatar
monkeykg
Regular
Posts: 48
Joined: Mon Jan 01, 2018 6:36 pm
Projects: DATE KNIGHT
Tumblr: monkeywiki
Contact:

Hiding back button in UI

#1 Post by monkeykg »

A lot of the code resources i'm finding are pretty outdated and unreliable. how would one go about hiding JUST the back button? (And + possible an option for it to only be hidden in distributions like how developer mode being set to auto only disables it in distributions?? Not sure if thats an option if not i could work around it but.)
edit: alternatively, is there a way to make the back button have a limit of how many lines of dialogue it can go back on? I want people to be able to have the opportunity to go back and read something if they accidentally clicked too fast but i want to avoid letting people go a huge way back and choose a different route.

Code: Select all

 textbutton _("Back") action Rollback()

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Hiding back button in UI

#2 Post by Milkymalk »

You can use if-blocks in screens:

Code: Select all

if showbackbutton:
    textbutton _("Back") action Rollback()
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Hiding back button in UI

#3 Post by Remix »

You likely want fixed rollback...
A setting whereby:
They can rollback as normal, just if they go past a choice menu they cannot choose a different option...

This doesn't actually work, even though I thought it would...

Code: Select all

label start:
    python:
        if not config.developer:
            renpy.fix_rollback()
    "Game starts here... rollback allowed... different choices in rollback disabled for non developer mode"
A workaround that does work by setting the toggle on every line basically...

Code: Select all

init python:
    def set_rollback(*args, **kwargs):
        renpy.game.log.rollback_is_fixed = True 

    config.all_character_callbacks.append( set_rollback )

label start:    
    "Start - if you rollback to here it will reset btw"
    "Pre-menu"
    menu:
        "1":
            "yay"
        "2":
            "umm"
    "End"

    return
Still unsure why we cannot just set " renpy.game.log.rollback_is_fixed = True " once and have it run throughout the whole game... Maybe have a play around
P.S. You could add the " if not config.developer: " conditional in the function if you want
Frameworks & Scriptlets:

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Hiding back button in UI

#4 Post by Remix »

Ren'py 6.99.13+ way using mode_callbacks (better)

Code: Select all

init python:
    def set_rollback_after_menu(mode, old_modes):
        if len(old_modes) \
        and old_modes[0] in ['menu', 'nvl_menu']:
            renpy.game.log.rollback_is_fixed = True 

    if not config.developer: # only do if not developer
        config.mode_callbacks.append( set_rollback_after_menu )

label start:    
    "Start - if you rollback to here it will reset btw"
    "Pre-menu"
    menu:
        "1":
            "yay"
        "2":
            "umm"
    "End"

    return
Frameworks & Scriptlets:

User avatar
monkeykg
Regular
Posts: 48
Joined: Mon Jan 01, 2018 6:36 pm
Projects: DATE KNIGHT
Tumblr: monkeywiki
Contact:

Re: Hiding back button in UI

#5 Post by monkeykg »

Ahh thank you for the help, I think i'd just prefer hiding it all together, though.

Code: Select all

if showbackbutton:
    textbutton _("Back") action Rollback()
this code gives me an error, though.

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/screens.rpy", line 99: expected statement.
    textbutton _("Back") action Rollback()
                ^

Ren'Py Version: Ren'Py 6.99.14.1.3218
Sat Feb 24 19:54:45 2018

irredeemable
Regular
Posts: 78
Joined: Thu Feb 08, 2018 7:57 am
Contact:

Re: Hiding back button in UI

#6 Post by irredeemable »

Given the line number I'm guessing you added that line somewhere outside of the actual screen. If you just want to disable the button, find the line textbutton_("Back") action Rollback() in screens.rpy, under screen quick_menu(): and change it to add the if statement:

Code: Select all

if config.developer:
   textbutton_("Back") action Rollback()
This will not prevent rollback though, as the player would still be able to use other bindings (e.g. the mousewheel) to rollback. As has been mentioned you should use fixed rollback for important choices if you don't want players to rollback and choose a different option.

User avatar
monkeykg
Regular
Posts: 48
Joined: Mon Jan 01, 2018 6:36 pm
Projects: DATE KNIGHT
Tumblr: monkeywiki
Contact:

Re: Hiding back button in UI

#7 Post by monkeykg »

Oh dear lord renpy did not like that (Just testing the hide button code)

https://prnt.sc/ijg13q

Code: Select all

 if config.developer:
            textbutton _("Back") action Rollback()
            textbutton _("History") action ShowMenu('history')
            textbutton _("Skip") action Skip() alternate Skip(fast=True, confirm=True)
            textbutton _("Auto") action Preference("auto-forward", "toggle")
            textbutton _("Save") action ShowMenu('save')
            textbutton _("Q.Save") action QuickSave()
            textbutton _("Q.Load") action QuickLoad()
            textbutton _("Prefs") action ShowMenu('preferences')

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Hiding back button in UI

#8 Post by Remix »

irredeemable wrote: Sat Feb 24, 2018 10:17 pm This will not prevent rollback though, as the player would still be able to use other bindings (e.g. the mousewheel) to rollback. As has been mentioned you should use fixed rollback for important choices if you don't want players to rollback and choose a different option.
Just remember (as stated) that hiding or disabling the button does not alter the facility...

Rollback = button click OR page up keypress OR mousewheel up OR hover left side of window (mostly android iirc) OR ...

Anyway:

Code: Select all

            if config.developer:
                textbutton _("Back") action Rollback() # indented = only this item is conditional
            textbutton _("History") action ShowMenu('history')
            textbutton _("Skip") action Skip() alternate Skip(fast=True, confirm=True)
            textbutton _("Auto") action Preference("auto-forward", "toggle")
            # etc
Frameworks & Scriptlets:

User avatar
monkeykg
Regular
Posts: 48
Joined: Mon Jan 01, 2018 6:36 pm
Projects: DATE KNIGHT
Tumblr: monkeywiki
Contact:

Re: Hiding back button in UI

#9 Post by monkeykg »

Ah ... thank you, sorry for the frustration! 😭

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]