Mousewheel up rollback to screens

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
pistach
Newbie
Posts: 22
Joined: Tue Mar 05, 2019 9:25 am
Contact:

Mousewheel up rollback to screens

#1 Post by pistach » Mon Apr 20, 2020 5:39 pm

Is it possible to allow players to rollback using mouse-wheel to labels that had only screens without dialogues.
I have seen other games where rolling back carries you from one location to another (and not just to the last dialogue) but couldn't find how they did it.

Archon
Newbie
Posts: 4
Joined: Tue Apr 21, 2020 8:28 am
Contact:

Re: Mousewheel up rollback to screens

#2 Post by Archon » Tue Apr 21, 2020 8:43 am

I have the same question. I'm using a navigation system with jumps to labels via navigation screen (ui.interact() allows "to stay" in a room(label)). So how can I rollback not to the last dialogue, but to previous room.

I was trying to see how others do it. I found in one game in the end of each label this type of code:

Code: Select all

$ result = renpy.imagemap("kitchen.webp", "kitchen.webp", [
                        (0, 0, 0, 0, "kitchen.webp")
                        ])
Does it mean that the label will not collapse but will wait till "result" will get an action from imagemap? I guess it's rollback friendly approach, but how can I do it with imagebuttons?

User avatar
pistach
Newbie
Posts: 22
Joined: Tue Mar 05, 2019 9:25 am
Contact:

Re: Mousewheel up rollback to screens

#3 Post by pistach » Tue Apr 21, 2020 4:22 pm

I tried

Code: Select all

$ renpy.checkpoint()
in the label, and before the screen is called, and it seems to work.

Archon
Newbie
Posts: 4
Joined: Tue Apr 21, 2020 8:28 am
Contact:

Re: Mousewheel up rollback to screens

#4 Post by Archon » Wed Apr 22, 2020 2:31 am

Thank you, It' a decent solution and It's working for me but without a rollforward. In documentaion about renpy.checkpoint():
Most Ren'Py statements automatically support rollback and roll forward. If you call ui.interact() directly, you'll need to add support for rollback and roll-forward yourself. This can be done using the following structure:

Code: Select all

# This is None if we're not rolling back, or else the value that was
# passed to checkpoint last time if we're rolling forward.
roll_forward = renpy.roll_forward_info()

# Set up the screen here...

# Interact with the user.
rv = ui.interact(roll_forward=roll_forward)

# Store the result of the interaction.
renpy.checkpoint(rv)
It's important that your game does not interact with the user after renpy.checkpoint has been called. (If you do, the user may not be able to rollback.)
This is not working for some reason (not a stable rollback, no rollforward and sometimes calling an error "roll_forward is not defined"). Maybe the reason is that the game is interact with the user. Currently I'm using this structure:

Code: Select all

$ renpy.checkpoint()
#some scene with it's own screen (imagebutton or imagemap)
#navigation screen
#$ ui.interact()
Maybe it's a good enough solution. Seems noone can help us :?

User avatar
Tayruu
Regular
Posts: 129
Joined: Sat Jul 05, 2014 7:57 pm

Re: Mousewheel up rollback to screens

#5 Post by Tayruu » Fri Apr 24, 2020 4:01 am

I'm not sure how much this might help, but I have this code for calling the history screen with the mousewheel instead of rollback.

Code: Select all

    # Override Keymap
    def readback_catcher():
        if _game_menu_screen != None:
            ui.add(renpy.Keymap(rollback=[Stop("text"), renpy.curried_call_in_new_context("call_subscreen", screen="text_history")]))
        else:
            pass
    config.overlay_functions.append(readback_catcher) 
Replacing the code in rollback=[] is what you probably want to perform you own functions. If you want your rollback itself to rollback through locations, instead of say, calling a location screen, then I wouldn't know what to suggest, sorry. Maybe it's a start?

Archon
Newbie
Posts: 4
Joined: Tue Apr 21, 2020 8:28 am
Contact:

Re: Mousewheel up rollback to screens

#6 Post by Archon » Fri Apr 24, 2020 12:47 pm

Thank you, I'll think about it. Maybe I just overthinking things though. Perfect is the enemy of the good.:)

Archon
Newbie
Posts: 4
Joined: Tue Apr 21, 2020 8:28 am
Contact:

Re: Mousewheel up rollback to screens

#7 Post by Archon » Sat May 02, 2020 11:29 am

Ok, if anyone will read this topic, I've found a better way to write the code (it's more simple, clear and let you rollback/rollforward). I'm doing this:

Code: Select all

label factory:
	if clock.time_of_day[0]=="noon":  # set a scene depending on the daytime
		scene factory with fade  # show bg
		show screen factory_chars  # show a screen with a character(s) you want to interact with in the scene (use imagebutton)
	elif clock.time_of_day[0]=="evening":
		pass  # do here the same as above
	call screen home_navigation  # that's simple :) just _call_ the screen (a row of small pics of rooms in my case) and it stops the script till you jump out the label
	return

Post Reply

Who is online

Users browsing this forum: Google [Bot]