Create and Fuck your AI Cum Slut -70% OFF
x

Ren'Py [Solved]Adding repeatable events

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,228
3,239
how to adding repeatable events into my game

so when go to certain location and time

I want to trigger event/dialog at random

where do I start from I have search for it but can't find anything about


this my code that I have so far

warning it's long

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

Winterfire

Conversation Conqueror
Respected User
Game Developer
Sep 27, 2018
6,101
8,838
Your code is too messy, but I can give you an external example of how you could easily implement repeatable events:

Python:
default timmyLove = 0

label main:
    if timmyLove >= 0 and timmyLove < 10:
        jump timmyEvent1
    else:
        jump timmyEventEnd
       
       
label timmyEvent1:
    timmy "Hi"
    timmyLove++
    jump main
   
lebel timmyEventEnd:
    timmy "This is the end, bye"
    return

This is the documentation:
Using call would be better, whose documentaiton is just under jump.
The docs also have a few basic samples.
 

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,228
3,239
Your code is too messy, but I can give you an external example of how you could easily implement repeatable events:

Python:
default timmyLove = 0

label main:
    if timmyLove >= 0 and timmyLove < 10:
        jump timmyEvent1
    else:
        jump timmyEventEnd
     
     
label timmyEvent1:
    timmy "Hi"
    timmyLove++
    jump main
 
lebel timmyEventEnd:
    timmy "This is the end, bye"
    return

This is the documentation:
Using call would be better, whose documentaiton is just under jump.
The docs also have a few basic samples.
thanks for help

it works but it won't work if it's inside loop it will continue popup
 
Last edited:

<Code/>

Newbie
Feb 27, 2020
69
76
You can use a simple if statement to handle events, but as your game increases in size, they become harder and harder to manage. I would use an event system instead. The downside being that your events will be more abstract, since they are triggered by the event manager, when entering a location.

Python:
init python:
    event_meet_fisherman = Event(
        id="meet_fisherman",
        desc="Meet the old fisherman",
        trigger=location_trigger("harbor"),
        action="meet_fisherman",
    )
    event_manager.add(event_meet_fisherman)

label harbor:

    # you need this part, to check for events, it should be before the scene, so it doesn't load an unneeded bg image.
    # you could make a python function that does the same thing, to write less code.
    python:
        player_location = "harbor"
        event = event_manager.has_event()
        if event is not None:
            event.trigger()

    # if there are no events, continue to the location
    scene bg harbor
    ...

label meet_fisherman:
    $ event_manager.remove("meet_fisherman")
    "An old fisherman approaches you..."
    # do scene, give player choices, etc.
    return
And then I would likely have the event and the label for the event in the same part of a .rpy file, so they would be easy to manage.
 

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,228
3,239
init python: event_meet_fisherman = Event( id="meet_fisherman", desc="Meet the old fisherman", trigger=location_trigger("harbor"), action="meet_fisherman", ) event_manager.add(event_meet_fisherman) label harbor: # you need this part, to check for events, it should be before the scene, so it doesn't load an unneeded bg image. # you could make a python function that does the same thing, to write less code. python: player_location = "harbor" event = event_manager.has_event() if event is not None: event.trigger() # if there are no events, continue to the location scene bg harbor ... label meet_fisherman: $ event_manager.remove("meet_fisherman") "An old fisherman approaches you..." # do scene, give player choices, etc. return

Code:
I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/test.rpy", line 1, in script
    init python:
  File "game/test.rpy", line 2, in <module>
    event_meet_fisherman = Event(
                           ^^^^^ 
NameError: name 'Event' is not defined

-- Full Traceback ------------------------------------------------------------

Traceback (most recent call last):
  File "game/test.rpy", line 1, in script
    init python:
  File "renpy/ast.py", line 1187, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "renpy/python.py", line 1260, in py_exec_bytecode
    exec(bytecode, globals, locals)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "game/test.rpy", line 2, in <module>
    event_meet_fisherman = Event(
                           ^^^^^ 
NameError: name 'Event' is not defined

Windows-11-10.0.26100-SP0 AMD64
Ren'Py 8.4.0.25071206
Nude Town alpha 0.001
Fri Aug 15 06:11:14 2025
 

<Code/>

Newbie
Feb 27, 2020
69
76
Code:
I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/test.rpy", line 1, in script
    init python:
  File "game/test.rpy", line 2, in <module>
    event_meet_fisherman = Event(
                           ^^^^^
NameError: name 'Event' is not defined

-- Full Traceback ------------------------------------------------------------

Traceback (most recent call last):
  File "game/test.rpy", line 1, in script
    init python:
  File "renpy/ast.py", line 1187, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "renpy/python.py", line 1260, in py_exec_bytecode
    exec(bytecode, globals, locals)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "game/test.rpy", line 2, in <module>
    event_meet_fisherman = Event(
                           ^^^^^
NameError: name 'Event' is not defined

Windows-11-10.0.26100-SP0 AMD64
Ren'Py 8.4.0.25071206
Nude Town alpha 0.001
Fri Aug 15 06:11:14 2025
The error is caused because you would need to make your own Event and Event manager class. If you need one, I can make it for you, and you can just place the events rpy file into your game to use it.
 
  • Like
Reactions: rayminator

rayminator

Engaged Member
Respected User
Sep 26, 2018
3,228
3,239
The error is caused because you would need to make your own Event and Event manager class. If you need one, I can make it for you, and you can just place the events rpy file into your game to use it.
that would be great

hope find out other way to it