Ren'Py Simulator with real-time updating of variables / screens

Evildad

Member
Jan 7, 2019
113
219
I have another question about Renpy.
If I have understood the principle correctly, the current image is updated with every click and everything is executed until the next action is expected.

You don't have permission to view the spoiler content. Log in or register now.

With Java I had a project in school where I built a small browser game where the resource variables are updated in second ticks.
Now I wonder if renpy is suitable for something like that? For example a brothel simulator. (Of course not in school)

I built a very simple "loop" for testing where I always jump back and forth in the labels. Of course, this is not in the inventor's sense, but it would be very interesting to know if there is a sensible possibility.
The main problem in this case is that every click executes the calculation again and the variable is updated.

You don't have permission to view the spoiler content. Log in or register now.


So:
renpy suitable for this? Yes / No / Maybe
If, does anyone have a tip how the structure should look like and if in this case _skipping = False or config.allow_skipping = False is suitable?

I hope I haven't overlooked something again that is written very thickly somewhere in the documentation or is actually totally logical... :rolleyes:
 

crabsinthekitchen

Well-Known Member
Apr 28, 2020
1,565
9,078
You want something that changes with time without extra clicks? might be what you're looking for

something like this would update the variable as long as you're showing the screen
Python:
init python:
    def chop_wood():
        wood += 10
        

screen chop_wood_timer():
    timer 1.0 action Function("chop_wood") repeat True
 

Evildad

Member
Jan 7, 2019
113
219
You want something that changes with time without extra clicks? might be what you're looking for

something like this would update the variable as long as you're showing the screen
Python:
init python:
    def chop_wood():
        wood += 10
       

screen chop_wood_timer():
    timer 1.0 action Function("chop_wood") repeat True
I also tried to control an action instruction with a timer. However, with the repeat statement I always had a syntax error that I could not locate.

I have to compare where the typing error is.

Many thanks for this!
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
[...] a small browser game where the resource variables are updated in second ticks.
Now I wonder if renpy is suitable for something like that? [...]

So:
renpy suitable for this? Yes / No / Maybe

I'd say "maybe".
In so much as it's possible, but depending on what you have planned... only by bypassing RenPy completely and using the underlying python and python libraries.
screens with timers, might solve it - if it's as simple as you are describing.

But updating text at 1 second intervals implies some other actions/interactions are also going on within that 1 second... and that sounds more like minigame territory.

RenPy's strength is to deliver a visual novel (effectively a slideshow with subtitles), with some point and click elements.
If that's not the core part of your game... then perhaps you should be using an engine other than RenPy.
Based on what you've said... I don't know. It's a judgement call you'd have to make yourself... I'm just offering an outside perspective.

With that said, I've seen RenPy play in Realtime, using pygame.
See : .

In that case, from what little I can understand of it, it's creating the game screen as a creator-defined displayable and hooking into the render processing and processing things like mouse presses using event hooks.

So real-time interactions are possible, but definitely not RenPy's strong point.
 

Evildad

Member
Jan 7, 2019
113
219
Thanks for the help.
I have already tried a few things. The variant with the time-controlled screen only half works. It works, but the more calculations have to be carried out, the more drastic the delays become. For testing, I had built in an algorithm to check whether the number of priems is correct or not. This has already triggered a 3-second delay with simple numbers.

On Friday, my lecturer joined me and wanted to write a render event "quickly" with Python and Pygame. He also failed!
So I said goodbye to the idea and will make it round-based.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
[...] but the more calculations have to be carried out, the more drastic the delays become.

One vague recollection is that screen contents are redrawn very, very frequently.
If you're recalculating stuff each tick, it might be what's introducing the lag.
Honestly, I'm not sure how the logic works beyond using it for simple progress bars.

But thinking about the Pong style solution... depending on your calculation, you might want to avoid recalculating each value during each render event.

While the Pong example does it for very different reasons, it does track the elapsed time.
I'm thinking if you went that route, you might want to make the first check of the render event to be whether 1 second has elapsed or not.
If not, immediately return without doing any other calculation.
(Imagine 144 FPS, depending on when you do the calculations - you risk repeating the same calculation 144 more times than you need... Though in fairness, a modern PC should laugh off such trivial workload during a render tick).

Hmmm... not sure where I'm going with this... Except to say to check that you aren't invoking your code way more often than you think you are. Maybe add a variable where you simply do +1. After 20 seconds, check if it's 20... or 761,309. ;-)
 

DuniX

Well-Known Member
Dec 20, 2016
1,236
826
Renpy it's best you consider it like a turn based game in how it works.
But like was said you can implement a simple update function with Timer.
With Python this isn't necessarily bad even if you are using Renpy less as intended.

But if you want something more realtime and dynamic then that then you need something like Unity.