Rollback and Classes

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
Lonewhale
Newbie
Posts: 15
Joined: Fri May 17, 2019 11:55 pm
Contact:

Rollback and Classes

#1 Post by Lonewhale »

Hello. I ran into a problem that unwinding does not work on objects of a custom class.
Simple example:

Code: Select all

init python:
    class temp_class(object):
        def __init__(self):
            self.a = 0
            
    A = temp_class()
    
label start:
    "At this point a = 0: [A.a]"
    "Here, too, a = 0: [A.a]"   # a == 1!
    $ A.a +=1
    "Now a = 1: [A.a]"          #but if you rollback
What am I doing wrong?
From Belarus with love

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Rollback and Classes

#2 Post by gas »

Old thing.

Code: Select all

init python:
    class temp_class(store.object):
        def __init__(self):
            self.a = 0
default A = temp_class()

label start:
    "At this point a = 0: [A.a]"
    "Here, too, a = 0: [A.a]"
    $ A.a +=1
    "Now a = 1: [A.a]"
It now should work as intended.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

Lonewhale
Newbie
Posts: 15
Joined: Fri May 17, 2019 11:55 pm
Contact:

Re: Rollback and Classes

#3 Post by Lonewhale »

I knew that this is something that has long been known! Thank you very much!
By the way, maybe you know how to make the transformation into text work every frame?

Code: Select all

init python:
    a = "bla-bla-bla"
screen temp_screen:
    text a:
        slow_cps 10
        
start:
    show screen temp_screen
    "Now the conclusion is smooth"
    $ a = "And this text appeared instantly!"
    "Hop!"
In this design, after the text is fully displayed, in the next frames it appears instantly, and not smoothly. While I solved the problem by hiding and showing a screen with text in each frame, but there should be a more correct option
From Belarus with love

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Rollback and Classes

#4 Post by gas »

You already found the best option. Animations that should trigger anew require to restart the screen internal clock, that mean hide/reshow them.
You can try to use a function that update A, hide the screen and reshow it.
But I dunno if that work!

Something like:

Code: Select all

screen temp_screen(message = ""):
    text:
        message # does it work? Who knows...
        slow_cps 10
        
init python:
    def remessage(txt):
        if renpy.get_screen("temp_screen"):
            renpy.hide("temp_screen")
        renpy.show("temp_screen", txt)
        
label example:
     e "Welcome to an example"
     $ remessage("A new slow text!")
     e "Now the text should be animated again... who knows"
     $ remessage("Again for CPS text...")
     e "If that doesn't work, is only natural..."
Try it, but Im not exactly sure.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Rollback and Classes

#5 Post by trooper6 »

Lonewhale wrote: Sun Mar 29, 2020 11:35 am I knew that this is something that has long been known! Thank you very much!
By the way, maybe you know how to make the transformation into text work every frame?

Code: Select all

init python:
    a = "bla-bla-bla"
screen temp_screen:
    text a:
        slow_cps 10
        
start:
    show screen temp_screen
    "Now the conclusion is smooth"
    $ a = "And this text appeared instantly!"
    "Hop!"
In this design, after the text is fully displayed, in the next frames it appears instantly, and not smoothly. While I solved the problem by hiding and showing a screen with text in each frame, but there should be a more correct option
Does that text have to be in a screen? What is the purpose in having it in a screen rather than a text image you show?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Lonewhale
Newbie
Posts: 15
Joined: Fri May 17, 2019 11:55 pm
Contact:

Re: Rollback and Classes

#6 Post by Lonewhale »

gas wrote: Mon Mar 30, 2020 8:57 am You already found the best option...
Thank you very much for the answer, now I can stop unnecessary searches.
trooper6 wrote: Mon Mar 30, 2020 11:24 am
Lonewhale wrote: Sun Mar 29, 2020 11:35 am By the way, maybe you know how to make the transformation into text work every frame?
Does that text have to be in a screen? What is the purpose in having it in a screen rather than a text image you show?
I do not really understand the essence of your remark.
All I need is that in each frame the text would be smoothly displayed on the screen, as in the standard ADV, or NVL, but on my screen. Well, if the best way for this is to restart the screen, ok.
From Belarus with love

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Rollback and Classes

#7 Post by trooper6 »

I’m asking if the text has to be on a screen. There are other ways of showing text that might also do what you want depending on what exactly you are doing.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Lonewhale
Newbie
Posts: 15
Joined: Fri May 17, 2019 11:55 pm
Contact:

Re: Rollback and Classes

#8 Post by Lonewhale »

On the general yes, the text should be on the screen.
In short, then every frame I steal text from the original screen "Sey", and put it on my screen. And I hide the original "Say", giving the elements alpha properties of 0. In the function that places the stolen text on my screen, I also prescribe hiding and displaying the screen, and set the flag with which the desired animation is played. If it’s not very clear, I can throw off the project files, but I don’t think that they will surprise you :)
If you can give a tip on ways to make what I am doing easier, I will all be grateful to you :)
From Belarus with love

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Rollback and Classes

#9 Post by trooper6 »

This seems like a lot of coding. For what seems mostly just cps text in the middle of the screen?

Do you know about NVL mode? That might do what you want much easier. https://www.renpy.org/doc/html/nvl_mode.html
Or just making animated text images you show at the center of the screen like you'd do with any image. https://www.renpy.org/doc/html/text.htm ... splayables
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Lonewhale
Newbie
Posts: 15
Joined: Fri May 17, 2019 11:55 pm
Contact:

Re: Rollback and Classes

#10 Post by Lonewhale »

trooper6 wrote: Wed Apr 01, 2020 1:48 amThis seems like a lot of coding. For what seems mostly just cps text in the middle of the screen?
Oh, my English is bad and I still do not understand what you mean :(
In my idea, the text is not displayed in the middle of the screen. And on different screens, depending on the speaker, plus they should have the option to stay for some time after another character speaks.
If you are interested in why specifically I use smooth text output ... Well, because I really wanted to do this. My plans were to later try to display the movement of the mouth while the text is displayed. No matter how creepy it looks.
trooper6 wrote: Wed Apr 01, 2020 1:48 amDo you know about NVL mode? That might do what you want much easier. https://www.renpy.org/doc/html/nvl_mode.html
At the beginning of development, I tried to use NVL, but died out on an attempt to extract text from it, or altogether modify it to my needs. Therefore, I began to write my screens.
trooper6 wrote: Wed Apr 01, 2020 1:48 amOr just making animated text images you show at the center of the screen like you'd do with any image. https://www.renpy.org/doc/html/text.htm ... splayables
About the text shown as an image. Damn, I came across him when I was training, but managed to completely forget. Hmm .. Although I didn’t manage to set up the smooth output of such a text-picture right away, I’m probably still playing with it, and I’ll just keep it in mind.

The question that interests me now is: Is it possible to get the parameters of the displayed object? For example, find out the sizes shown on the screen of the "fixed" object with a compression parameter. I came across a disappointing thread for 2017, and also did not gain success.
From Belarus with love

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], BBN_VN, Bing [Bot], geoWaffle, Google [Bot]