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.
I'm building a roulette and I'm trying to generate a random number. My problem right now is that if I scroll back then I know what number is going to be.
This is my code right now. Is there a way to generate different number even if I scroll back, cuz the other solution would be to stop the scroll, which I don't really want, but if there is no other way, I'll do it.
Is there a way to roll this number upon the start of the game and then store it until needed, instead of rolling when it is needed? That way the player would scroll back in the dialogue (which is what I assume you mean, I'm not great at code) and still have the same number presented, because they would have to start a new game to get a new number.
The Ren’py random system is specifically designed to be repeatable in that manner. What you could do would be to use the underlying Python random library directly, rather than the Ren’py version.
By the way, you can't stop players from er... kind of cheating. If your random number would be different after rollback, then player will be able to rollback until (s)he wins. And if you'll block the rollback function, player could save game before making stake and restore the game in case of lose...))
Alex makes a very good point. Another option could be to disable rollback, saving and loading, but ONLY during roulette or random element sections, and re-enable them once the casino label or screen is exited. If you do this make sure to warn the players beforehand so they know exactly how it works.
The player still could save before entering the casino, but at least it would be 'less' cheap and it would require more effort (shutting down or exiting the casino label, then reloading previous save, etc.)
Last edited by RicharDann on Tue Feb 25, 2020 3:17 pm, edited 1 time in total.
Alex wrote: ↑Tue Feb 25, 2020 1:53 pm
By the way, you can't stop players from er... kind of cheating. If your random number would be different after rollback, then player will be able to rollback until (s)he wins. And if you'll block the rollback function, player could save game before making stake and restore the game in case of lose...))
Shit. I didn't think this through. You're right. This roulette is just going to ruin my money system.
RicharDann wrote: ↑Tue Feb 25, 2020 2:45 pm
Alex makes a very good point. Another option could be to disable rollback, saving and loading, but ONLY during roulette or random element sections, and re-enable them once the casino label or screen is exited. If you do this make sure to warn the players beforehand so they know exactly how it works.
The player still could save before entering the casino, but at least it would be 'less' cheap and it would require more effort (shutting down or exiting the casino label, then reloading previous save, etc.)
Yeah, but still this will ruin the gameplay and the other ways of making money would be pointless. I need to find a way to rig the roulette. Or maybe put a limit of money you can win.
As I now think about it more carefully, disabling the ability to save and load the game is not a very user-friendly thing to do.
It is technically possible to make the save and load buttons insensitive (unclickable) with some boolean variables for example, but many will find it annoying.
A clever player will always find ways to cheat, and fighting against Ren'Py's handy features is probably not a good idea. Most likely it's better to try and restrict rollback when necessary using the functions found in the page Imperf3kt mentioned.
RicharDann wrote: ↑Wed Feb 26, 2020 11:53 am
As I now think about it more carefully, disabling the ability to save and load the game is not a very user-friendly thing to do.
It is technically possible to make the save and load buttons insensitive (unclickable) with some boolean variables for example, but many will find it annoying.
A clever player will always find ways to cheat, and fighting against Ren'Py's handy features is probably not a good idea. Most likely it's better to try and restrict rollback when necessary using the functions found in the page Imperf3kt mentioned.
Well in that case I guess the best solution would be to limit the amount of earnings you can win at roulette. Thank you for your help.
Assuming the "cheat" is changing a decision made prior to the random call, another option (depending on how linear the game is) could be to go back to RenPy's rollback-compatible random and combine it with fixed rollback[1], which would allow rollback but not changing the decision/bet already made. If the game is sufficiently linear this may be a solution, however if your game is more open a savvy player could likely still route around it.
strayerror wrote: ↑Sat Feb 29, 2020 11:03 am
Assuming the "cheat" is changing a decision made prior to the random call, another option (depending on how linear the game is) could be to go back to RenPy's rollback-compatible random and combine it with fixed rollback[1], which would allow rollback but not changing the decision/bet already made. If the game is sufficiently linear this may be a solution, however if your game is more open a savvy player could likely still route around it.