[Solved] Returning to Previous Line Using Call

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
amesyflo
Newbie
Posts: 4
Joined: Tue Sep 10, 2019 4:48 pm
Contact:

[Solved] Returning to Previous Line Using Call

#1 Post by amesyflo »

Hi All!

I was wondering if its possible to use the call function to return to the line you were on when you called, rather than the one after it?

I'm currently working on a system where you can press a button to gain further information at certain points in a conversation. After playing the additional information label, I'd like to return to the line that was on screen when the player clicked the button, rather than the line after it.

I saw in the documentation that there's a 'from clause' that can move to a label, though I'm not sure if that would be of any help to me or if its for just for handling saved games.

Anyone got any ideas on how to handle this? My button, press function and example of use below. The press_statement there is a global variable (gross, I know :P) that is changed whenever a line of dialogue that can be successfully pressed is on screen.

Thanks! :)

Code: Select all

textbutton _("Press") action If(can_press, Function(press), None)

Code: Select all

init python:
    def press():
        if press_statement:
            renpy.call(press_statement)
        else:
            renpy.call("generic_press")

Code: Select all

   
#enable abilty to press character, define specific press dialogue found in custom_labels_press.rpy
$ can_press = True
$ press_statement = "in_lab"

 #dialouge
 j "I don't know what you're talking about."

 #keep press enabled but default it to the generic press dialogue
 $ press_statement = None
 $ correct_item = jay_access
 
Last edited by amesyflo on Thu Sep 12, 2019 3:07 pm, edited 1 time in total.

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Returning to Previous Line Using Call

#2 Post by RicharDann »

Your idea of using 'from clause' is worth a shot, I think, in python I believe you can pass from_current as a keyword argument to renpy.call():

Code: Select all

renpy.call("generic_press", from_current=True)
This way it would return to the same line instead of the next one. Not completely sure since I can't test right now, but it may be a start.
The most important step is always the next one.

amesyflo
Newbie
Posts: 4
Joined: Tue Sep 10, 2019 4:48 pm
Contact:

Re: Returning to Previous Line Using Call

#3 Post by amesyflo »

That works perfectly, thankyou so much! :D

Post Reply

Who is online

Users browsing this forum: No registered users