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.
Everything works fine but when I make a step back (rollback) it always change the background music. Is there any way to prevent rollback to change music?
Everything works fine but when I make a step back (rollback) it always change the background music. Is there any way to prevent rollback to change music?
when you roll back, the game will run your code and choose the music at random again, if you want to keep the choice you can run the random code earlier and keep the result in a variable. this way it doesn't change while rollback.
to keep the code from restarting the music, and as an alternative solution: you can use persistent variables.
I haven't tested it, but it seems to me like the in_rollback() function gives you a pretty useful tool to deal with this (if you can check if the game is rolled back before calling your function, it seems like it should do it). That said, I'm not entirely sure I understand how your music function is called so I may be off base.
A game about loneliness, chess, and fighting monsters with magic
Autumnotopia wrote: ↑Mon Sep 16, 2019 11:30 pm
I haven't tested it, but it seems to me like the in_rollback() function gives you a pretty useful tool to deal with this (if you can check if the game is rolled back before calling your function, it seems like it should do it). That said, I'm not entirely sure I understand how your music function is called so I may be off base.
I'm not the OP but I must say thanks a lot for pointing that out. I'm in the middle of making a blackjack game and roll back was causing all sorts of headaches.
This looks like just what I need.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Imperf3kt wrote: ↑Tue Sep 17, 2019 12:37 am
I'm not the OP but I must say thanks a lot for pointing that out. I'm in the middle of making a blackjack game and roll back was causing all sorts of headaches.
This looks like just what I need.
I wrote a blackjack(ish) card game for a client of mine and since it was all in a screen, rollback never became an issue. I suggest ditching the jumping and labels for the games loop and contain it inside a screen.