Displayable Offsets Repeating on Rollback (CDS Problem)

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
dovedozen
Newbie
Posts: 6
Joined: Thu Mar 17, 2022 9:33 am
Contact:

Displayable Offsets Repeating on Rollback (CDS Problem)

#1 Post by dovedozen » Sat Apr 09, 2022 3:29 pm

UPDATE FOR POSTERITY:
I opened an issue on the GitHub regarding this problem & Ren'Py Tom figured it out! This small tweak to renpy/exports.py fixed it.
( Consists of an added list() around the existing line renpy.game.context().scene_lists.at_list[layer].get(tag, None) )
VERY excited to spam little sparkle animations, etc. all over my game with wild abandon and very few characters typed, now that it's working. Big huge thanks to Ocelot for the sanity check & Tom for being the backbone of society.


I'm having goofy little problems with creator-defined statements again, & would love to get a second set of eyes on this one!

I wrote a CDS which shows a displayable using its post_execute function (so: if the statement is written right before a line of dialogue, when that line of dialogue is reached the displayable will be shown.)

EG, the code below would show displayable_name in a location chosen by cds' post_execute function, based on CHARACTER_A's image tag.

Code: Select all

cds displayable_name
CHARACTER_A "Bottom text!"
This works as expected when clicking through the game normally, but I'm finding that some of the ATL used to define the transform which positions the displayable isn't playing nicely with rollback.

Code: Select all

transform right_side:
    yanchor 0.0
    ypos 100
    xoffset 150
Since xoffset is relative, when I click through to the statement following the one associated with the CDS, then rollback, the displayable is redrawn an additional 150px to the right. I can chase it completely off the screen this way if I roll forward and back a few times.

I've confirmed that the following code doesn't have this problem:

Code: Select all

show character_b:
    xoffset 150
(If there are two lines of dialogue after this show statement, and I click through to the second, then rollback to the first, the xoffset is not repeated (which makes sense!).)
...But I'm not sure what else to test to get any meaningful troubleshooting done.

It seems like something about my CDS' implementation isn't working quite right with rollback.

I'm wondering whether this might be because post_execute is supposed to execute "as part of the next statement", whereas a normal "show" statement might accomplish "not drawing the displayable to the screen until the next interaction happens" in a different way? Like this, where the --- separates one statement from the next:

1. REN'PY'S INBUILT THING, WHICH ROLLBACK KNOWS ABOUT
show statement [interacts with some other part of ren'py]
---
say statement [checks some other part of ren'py for things to show]

2. MY NOVEL THING, WHICH ROLLBACK MAY OR MAY NOT UNDERSTAND
cds statement
---
post_execute [directly uses renpy.show(something)]
say statement

Has anyone encountered something like this before? Does this explanation seem plausible?

If my options are either to figure out how show and say do this, then replicate it, or to hard-code a bunch of offset-less positions for my post_execute function to use, then make sure it knows which one to pick in any given situation, I'm honestly not sure which would take longer, so it would definitely help to get an outside opinion or two on the whole situation before I get too deep into either one! (& of course, if there's a secret third option I'm not seeing, let me know?)
Last edited by dovedozen on Sat Apr 16, 2022 3:54 pm, edited 1 time in total.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1882
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Displayable Offsets Repeating on Rollback (CDS Problem)

#2 Post by Ocelot » Sat Apr 09, 2022 3:41 pm

It does look like a possible bug.

You can report it at https://github.com/renpy/renpy/issues/
< < insert Rick Cook quote here > >

jeffster
Regular
Posts: 123
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Displayable Offsets Repeating on Rollback (CDS Problem)

#3 Post by jeffster » Sat Apr 09, 2022 4:41 pm

If the problem is about the transform iheriting some previous properties... Maybe this could help:
https://www.renpy.org/doc/html/atl.html ... transforms

dovedozen
Newbie
Posts: 6
Joined: Thu Mar 17, 2022 9:33 am
Contact:

Re: Displayable Offsets Repeating on Rollback (CDS Problem)

#4 Post by dovedozen » Sat Apr 09, 2022 9:41 pm

Ocelot wrote:
Sat Apr 09, 2022 3:41 pm
It does look like a possible bug.
Cannot BELIEVE this didn't even occur to me as a possibility, omg. Thanks; I'll see about opening an issue!
jeffster wrote:
Sat Apr 09, 2022 4:41 pm
If the problem is about the transform iheriting some previous properties... Maybe this could help:
https://www.renpy.org/doc/html/atl.html ... transforms
I did think that it could be something like that, but doing the same thing with the show statement manually really does work. I've tested it a few different ways. It's always possible that I'm missing something, but reading + rethinking the documentation wasn't helping much anymore, so..!
(Also, if it is a problem with replacement/inheritance, the only workaround I can think of is to hard-code the positions, to be honest! Thank you, though. There's seriously a lot to learn when it comes to displayables...)

jeffster
Regular
Posts: 123
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Displayable Offsets Repeating on Rollback (CDS Problem)

#5 Post by jeffster » Sun Apr 10, 2022 12:03 am

dovedozen wrote:
Sat Apr 09, 2022 9:41 pm
jeffster wrote:
Sat Apr 09, 2022 4:41 pm
If the problem is about the transform iheriting some previous properties... Maybe this could help:
https://www.renpy.org/doc/html/atl.html ... transforms
I did think that it could be something like that, but doing the same thing with the show statement manually really does work. I've tested it a few different ways. It's always possible that I'm missing something, but reading + rethinking the documentation wasn't helping much anymore, so..!
(Also, if it is a problem with replacement/inheritance, the only workaround I can think of is to hard-code the positions, to be honest! Thank you, though. There's seriously a lot to learn when it comes to displayables...)
I'm not really convinced. As the documentation says,
The position properties (xpos, ypos, xanchor, and yanchor), have a special rule for inheritance - a value set in the child will override a value set in the parent. This is because a displayable may have only one position, and a position that is actively set takes precedence. These properties may be set in multiple ways - for example, xalign sets xpos and xanchor.

Finally, when a show statement does not include an at clause, the same displayables are used, so no inheritence is necessary. To prevent inheritance, show and then hide the displayable.
So you can probably use "xanchor -150" instead of "xoffset 150". Or show and then hide the displayable if the game is in rollback.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1882
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Displayable Offsets Repeating on Rollback (CDS Problem)

#6 Post by Ocelot » Sun Apr 10, 2022 2:43 am

jeffster wrote:
Sun Apr 10, 2022 12:03 am
I'm not really convinced. As the documentation says,
The problem not in xoffset applying several times, but in rollback not reverting changes. You can do the same with conditionally setting either xpos and ypos and finding out that after rollback both are set.
< < insert Rick Cook quote here > >

jeffster
Regular
Posts: 123
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Displayable Offsets Repeating on Rollback (CDS Problem)

#7 Post by jeffster » Sun Apr 10, 2022 12:53 pm

Ocelot wrote:
Sun Apr 10, 2022 2:43 am
jeffster wrote:
Sun Apr 10, 2022 12:03 am
I'm not really convinced. As the documentation says,
The problem not in xoffset applying several times, but in rollback not reverting changes. You can do the same with conditionally setting either xpos and ypos and finding out that after rollback both are set.
I was thinking that rollback tries to apply the previous transform but due to inheritance that transform does not revert to its original position.

About "conditionally setting either xpos and ypos and finding out that after rollback both are set", I don't really understand what you mean. Could you give a code example?

I tried to set different xpos in the same transform and the rollback worked properly:

Code: Select all

image test_text = ParameterizedText(yalign = 0.5, size = 64)
transform test_roll(i):
    pos (100 * i, 0)

label start:
    show test_text "AAA" at test_roll(0)
    "0"
    show test_text "AAA" at test_roll(1)
    "1"
    show test_text "AAA" at test_roll(2)
    "2"

dovedozen
Newbie
Posts: 6
Joined: Thu Mar 17, 2022 9:33 am
Contact:

Re: Displayable Offsets Repeating on Rollback (CDS Problem)

#8 Post by dovedozen » Sun Apr 10, 2022 1:15 pm

jeffster wrote:
Sun Apr 10, 2022 12:53 pm
I tried to set different xpos in the same transform and the rollback worked properly:
Don't forget that I only had this problem with creator-defined statements! Using "show" in the way that ren'py supports out of the box works just fine for me, too.

I do think that your earlier post about using anchor and pos together as a workaround is interesting, though; I'll definitely try that later and see if it'll work for the time being. It would definitely be faster than the alternatives I already had in mind.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]