[SOLVED] How to deal with screen prediction (side effects)?

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
FroGlenn
Regular
Posts: 53
Joined: Sun Feb 25, 2018 2:07 pm
Contact:

[SOLVED] How to deal with screen prediction (side effects)?

#1 Post by FroGlenn »

Hi. I made a little minigame for my renpy game, where I have two screens:

1) A card album screen with cards that you can collect and complete

2) A screen with a button that draws one random card

The problem is: every time I open one of the sreens one card is picked without the player clicking the button. If you keep switching screens, more cards are picked until you have all of then without drawing it one single time...

I think this effect is caused by the screen prediction that is well documented in the Screen page, because my screns have side effects (and screens should not have them...) but how can I deal with it in this case? There is a way to cancel the predict function, and if not, how can I make my minigame?

This minigame uses persistent variables, cause I want it to be not linked with the VN gameplay.

I tried to create a label with the function and only the results being displayed in the screen, but when I use the action Call("draw_card") the menu is closed after the return and the screen with the results do not show. I tried to call in new context, but this way the screen prediction occurs the same way as the code was in the screen itself :(

Thank you in advance.
Last edited by FroGlenn on Thu Aug 09, 2018 4:31 pm, edited 1 time in total.

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: How to deal with screen prediction (side effects)?

#2 Post by trooper6 »

I really can’t say without seeing your code but having a button that effect a data structure that is shown in another screen is doable...depending on how you are doing it.

on another point, I really don’t think you want persistent data. Persistent data is for when you want data to carry over to a brand new game. For example if a card is destroyed in one game and you note itwith regular data, a new person could start a new game and still be able to use that card (until it is destroyed in their game). If you use persistent data to note the card is destroyed, no one can use that card again even if they start a brand new fresh game.
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

FroGlenn
Regular
Posts: 53
Joined: Sun Feb 25, 2018 2:07 pm
Contact:

Re: How to deal with screen prediction (side effects)?

#3 Post by FroGlenn »

I think I did it.

This post helped me see it...

If I did it right, its easier than I thought.

Like I said, call a label that will set the variables and just call screen result after the calculation.

This way prediction wont touch it and the flow of the game will just continue as it should.

If I did something wrong and somene can point it, I would love to know.

Thx again.

FroGlenn
Regular
Posts: 53
Joined: Sun Feb 25, 2018 2:07 pm
Contact:

Re: How to deal with screen prediction (side effects)?

#4 Post by FroGlenn »

trooper6 wrote: Thu Aug 09, 2018 12:12 pm I really can’t say without seeing your code but having a button that effect a data structure that is shown in another screen is doable...depending on how you are doing it.

on another point, I really don’t think you want persistent data. Persistent data is for when you want data to carry over to a brand new game. For example if a card is destroyed in one game and you note itwith regular data, a new person could start a new game and still be able to use that card (until it is destroyed in their game). If you use persistent data to note the card is destroyed, no one can use that card again even if they start a brand new fresh game.
Thx for your reply.

And thx for your warning about persistent data. How should I deal with this case then? I want the cards being there for the player in a way that the "game loop", I mean, the VN stuff and the cards dont mess with each other.

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: [SOLVED] How to deal with screen prediction (side effects)?

#5 Post by trooper6 »

Why would they mess with each other? They don't automatically mess with each other unless you tell them to.
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

FroGlenn
Regular
Posts: 53
Joined: Sun Feb 25, 2018 2:07 pm
Contact:

Re: [SOLVED] How to deal with screen prediction (side effects)?

#6 Post by FroGlenn »

trooper6 wrote: Thu Aug 09, 2018 5:55 pm Why would they mess with each other? They don't automatically mess with each other unless you tell them to.
I mean. How can I save that player got one card outside of the visual novel loop.

If he draws a card and starts another gameplay he will need to get the card again, doesnt he?

Is there a way to save a variable outside of the game loop without using persistent data?

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: [SOLVED] How to deal with screen prediction (side effects)?

#7 Post by trooper6 »

Persistent data is not the answer to your problem. It is hard for me to give you the right answer, because I have no idea what your code is like or what exactly you are trying to achieve.

I also don’t quite know what you mean my visual novel loop...what loop?
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

FroGlenn
Regular
Posts: 53
Joined: Sun Feb 25, 2018 2:07 pm
Contact:

Re: [SOLVED] How to deal with screen prediction (side effects)?

#8 Post by FroGlenn »

trooper6 wrote: Thu Aug 09, 2018 9:59 pm Persistent data is not the answer to your problem. It is hard for me to give you the right answer, because I have no idea what your code is like or what exactly you are trying to achieve.

I also don’t quite know what you mean my visual novel loop...what loop?
@trooper6 Thx for the time dealing with my case.

When we talk about Renpy, we think about visual novels. But I have one side-game where you can draw random cards to complete an image album.

Everytime someone draws a random card, the game change the variable to true, like persistent.card1 = True, this way, the game knows the player picked that card.

This system is not linked, by design, to the visual novel, we can say the main game. It need to happens outside the main game in a way that the game cannot touch the card album, I mean, saving/loading/rollback cant chage what happens to the album.

I want the player to be able to play several gameplays (to get all the endings for example) and the cards will be there like a side-game.

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: [SOLVED] How to deal with screen prediction (side effects)?

#9 Post by trooper6 »

If you want the card picked to remain true even with a brand new game, then you do indeed want persistent variables. So you have no problem there. And it looks like, from your title, that you have solved your screen issue. So everything is solved for you. Yay!
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

Post Reply

Who is online

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