What is an "interaction"?

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
User avatar
zmook
Regular
Posts: 170
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

What is an "interaction"?

#1 Post by zmook » Tue Feb 16, 2021 1:01 pm

The Ren'py docs refer a lot to "interactions" but if it's ever defined I can't find it. Is there a canonical description somewhere of what is an interaction, what can start one, what can end one, and what is or is not allowed to happen during one?

(If you think it's obvious, please consider that a pause is apparently an interaction, and that 'calling' a screen seems to be an interaction, but 'showing' is not. The documentation around these things leaves a lot unsaid.)

The closest I can find to an implicit definition of "interaction" is the Modes page (https://www.renpy.org/doc/html/modes.html) which lists some modes that "corresponding to built-in interactions," but: is that all of them? It says "Other modes can be entered by calling the renpy.mode function", but I don't know what those modes might be. Is "being in an interaction" the same as "being in a mode"?

That list of modes looks rather comprehensive. When (if ever) is renpy *not* in an interaction? There must be some times, because there's a "can't start an interaction while in an interaction" error.
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

User avatar
RicharDann
Veteran
Posts: 271
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: What is an "interaction"?

#2 Post by RicharDann » Tue Feb 16, 2021 2:02 pm

I don't know the exact internal specifics for this, but as far as I understand it (hope I'm not wrong), an interaction occurs any time Ren'Py is waiting for input from the player. Clicking on a Menu button, advancing the dialogue text by clicking or pressing enter, anytime the player has to "interact" with the program. Now, in some cases, an interaction causes a context to be created, like when you pause or call a screen, when this happens, the game stops its normal flow and enters a loop where it waits for player input, and until that input is processed, no other interaction can occur within this context.

Dialogue, that is, say and nvl modes don't do this because they're part of the main game loop that's started when a new game is started or a save is loaded, and when you use show screen, it doesn't create a context, just displays ui elements, even if the player can click on buttons on a shown screen, that's what causes the interaction, not showing the screen itself. When you call a screen, show a menu, etc., anything that effectively pauses the main loop, that's another layer of interaction. At this point, you can't start yet another interaction until that second loop is finished, unless you create a new context manually.

Hope that made sense.
Last edited by RicharDann on Tue Feb 16, 2021 2:26 pm, edited 1 time in total.
The most important step is always the next one.

cheonbyeol
Regular
Posts: 37
Joined: Thu Feb 04, 2021 9:04 am
Contact:

Re: What is an "interaction"?

#3 Post by cheonbyeol » Tue Feb 16, 2021 2:25 pm

Sorry to butt in, here because I am also very confused about interactions.
Thank you for the info, RicharDann! It does help, but also brings up more questions. I realized I also don't know what's a "context" :')

User avatar
RicharDann
Veteran
Posts: 271
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: What is an "interaction"?

#4 Post by RicharDann » Tue Feb 16, 2021 3:05 pm

DISCLAIMER: I'm not 100% sure about this, as I haven't been able to find relevant documentation.

I edited my first post a bit to clarify the wording, but in this case, a context is sort of like a mode, a particular state the program enters depending if you're calling a screen, invoking a pause or starting any other kind of interaction. A new context is created and saved within each new interaction. Think of it like a label, a container of sorts for the code being run, that you'll eventually return from.

Picture it like this:
As soon as you run a Ren'Py game, the first thing that usually appears is the main menu. At this point we have entered our first context, a screen context (since we're currently in a screen). When you start a New Game by clicking on the corresponding button, the main menu screen is exited and we jump to label start, within the script, at this point a second context is created, and we move from the previous screen context to this new context, the main loop (I don't know how it's actually called, but let's pretend it is).
The game proceeds as you click anywhere on the screen, advancing dialogue, and at some point, you decide to enter the Preferences screen, either via the quick menu or by right clicking on the screen then choosing it from that menu. This stops the game flow and creates yet another context. This is what Ren'Py call an interaction. You can't call yet another menu or screen from here, or you'll get an error, though you can show other screens, just not call them. The navigation menu that opens when you right click on the game (the one with Save, Load, Quit, etc.) does this.
When you right click on the screen to return to the main loop, the current context is removed/erased, and you return to the previous main loop context. When another screen is called, a new context is created, then exited, and basically this repeats until you close the game.

So a context is basically like a game state. I believe Ren'Py uses context to determine how things will be processed (depending for example if we're in a screen or a pause), or for things like rollback, to make sure everything is just the way it was back when you decide to roll back to a ceirtain point.
The most important step is always the next one.

cheonbyeol
Regular
Posts: 37
Joined: Thu Feb 04, 2021 9:04 am
Contact:

Re: What is an "interaction"?

#5 Post by cheonbyeol » Tue Feb 16, 2021 3:52 pm

Ah, I think I get it. Thanks a ton <3

User avatar
gas
Miko-Class Veteran
Posts: 838
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: What is an "interaction"?

#6 Post by gas » Tue Feb 16, 2021 9:47 pm

Hello!
To be exactly precise, but just for academic as probably nothing change at your level, the INTERACTION is the time renpy spend to elaborate something between an user input and the next request of an user input.

Is not the user interaction, is the Renpy one (so, probably "reaction" could have been a better name).
You click, renpy interact (elaborate like adding diplayables, moving layers and so on) and wait again for an input.

If you restart an interaction, that mean renpy redo whatever stay between the previous user input and the next one to come. So it also execute the previous code, if any, when invoked.

Ah, also note that by interaction renpy mean to reach the next statement, so for example callng a screen with 200 buttons you have to press is NOT an interaction, as everything happen inside the screen itself.

Code: Select all

e "hello!"
# < - here happen the interaction
call screen 1000clicks
# < - here happen the interaction
e "ok, done"
As said, is just academic as from the normal use of renpy and from the final user points of view there's nothing that force you to know this.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
zmook
Regular
Posts: 170
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: What is an "interaction"?

#7 Post by zmook » Tue Feb 16, 2021 11:51 pm

gas wrote:
Tue Feb 16, 2021 9:47 pm
Hello!
To be exactly precise, but just for academic as probably nothing change at your level, the INTERACTION is the time renpy spend to elaborate something between an user input and the next request of an user input.

Is not the user interaction, is the Renpy one (so, probably "reaction" could have been a better name).
You click, renpy interact (elaborate like adding diplayables, moving layers and so on) and wait again for an input.
Thank you!

(This stuff becomes relevant if you're, for instance, trying to display a sequence of messages on the screen (not dialog), and you don't want to accidentally trigger "interaction inside interaction" errors.)

Thinking of the "interaction" as "the time between a click and when Renpy starts looking for the next click" is helpful. That certain helps make sense of restart_interaction. Does that mean, though, that (e.g.) an indefinite pause is a 'mode' but not an 'interaction'? I may be over-interpreting the line in the docs that says "The following are the modes corresponding to built-in interactions."
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

cheonbyeol
Regular
Posts: 37
Joined: Thu Feb 04, 2021 9:04 am
Contact:

Re: What is an "interaction"?

#8 Post by cheonbyeol » Wed Feb 17, 2021 9:49 am

gas wrote:
Tue Feb 16, 2021 9:47 pm
Ah, also note that by interaction renpy mean to reach the next statement, so for example callng a screen with 200 buttons you have to press is NOT an interaction, as everything happen inside the screen itself.
This is the part that really throws me off. What is happening exactly? Because inside the screen, the user is still clicking and doing various stuff, maybe being shown other screens etc. But, in the background, renpy kind of has everything "predicted" and it's not in an "interaction" mode...?

I ran into this several times, not being able to do thing with Ren'Py that intuitively sounded doable to me -- as a beginner coder.
For example, how do you get a screen to refresh, because other screens have changed some variables, but all in menu context?
Or, you show a screen with ShowTransient, which is in screen language so you can only use that in a screen, and opens a screen that should close by the end of the current interaction-- but are you even in an interaction while in a screen?

Maybe it's my intuition that's wrong, but would be nice to have more explanation on some of these concepts in the Documentation, so I don't try to "misuse" Ren'Py. I feel like some of these intermediate steps are what's missing from there--- the QuickStart is amazing, and there are also some deep parts documented that completely go over my head, but how does one cross the bridge between those levels? I often see advanced people correcting new people about the use of define or default, don't remember seeing that in the Docs. I also struggled a lot finding the correct syntax for defining a function, a dictionary, etc. Wow, I'm really going off-topic, sorry for the rant...

User avatar
zmook
Regular
Posts: 170
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: What is an "interaction"?

#9 Post by zmook » Wed Feb 17, 2021 2:01 pm

cheonbyeol wrote:
Wed Feb 17, 2021 9:49 am
Maybe it's my intuition that's wrong, but would be nice to have more explanation on some of these concepts in the Documentation, so I don't try to "misuse" Ren'Py. I feel like some of these intermediate steps are what's missing from there--- the QuickStart is amazing, and there are also some deep parts documented that completely go over my head, but how does one cross the bridge between those levels? I often see advanced people correcting new people about the use of define or default, don't remember seeing that in the Docs. I also struggled a lot finding the correct syntax for defining a function, a dictionary, etc. Wow, I'm really going off-topic, sorry for the rant...
I know exactly what you mean about the jump between "awesome intro tutorial" and "dense technical docs" with some missing intermediate-level definition of concepts in between. Now, good documentation is hard! I totally get how this happens. I've come to recognize that searching this board has to be considered part of the ren'py docs. But it's too bad the doc wiki is locked down -- that is kind of an obvious missing step to be able to collect and organize answers that are scattered across thousands of random topics here. I guess it was abused; it's just too bad.

Replying to a couple of specific things you have there:

* fyi, 'define' and 'default' are explained and distinguished here: https://www.renpy.org/doc/html/python.h ... -statement

* Syntax for functions, dictionaries, etc, is just standard python, no? There are hundreds of sources to document and/or teach that part.

Just for example, another thing--beyond interactions--that seems important and whose documentation is fragmented in snippets all over the place, is renpy.store, and especially the possibility of there being multiple stores. I'm pretty sure I don't have a handle on what that really means, yet.
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

cheonbyeol
Regular
Posts: 37
Joined: Thu Feb 04, 2021 9:04 am
Contact:

Re: What is an "interaction"?

#10 Post by cheonbyeol » Wed Feb 17, 2021 4:26 pm

zmook wrote:
Wed Feb 17, 2021 2:01 pm
I know exactly what you mean about the jump between "awesome intro tutorial" and "dense technical docs" with some missing intermediate-level definition of concepts in between. Now, good documentation is hard! I totally get how this happens. I've come to recognize that searching this board has to be considered part of the ren'py docs. But it's too bad the doc wiki is locked down -- that is kind of an obvious missing step to be able to collect and organize answers that are scattered across thousands of random topics here. I guess it was abused; it's just too bad.
...I never even knew a wiki existed, since I jumped into Ren'Py a couple weeks ago. That's a pity. The forums are great, even if a little chaotic (and it doesn't help I keep getting timeout errors when I go beyond page of any search), and the Discord is nice too.
* Syntax for functions, dictionaries, etc, is just standard python, no? There are hundreds of sources to document and/or teach that part.
Mmm, yes, I guess? Though I wasn't entirely sure where in Ren'Py I should place those Python blocks, if there was some special syntax of calling functions in script and/or screens, etc. Maybe that's just me. Eventually got it with trial and error.

Just for example, another thing--beyond interactions--that seems important and whose documentation is fragmented in snippets all over the place, is renpy.store, and especially the possibility of there being multiple stores. I'm pretty sure I don't have a handle on what that really means, yet.
Uhhum. All I know about the store is that it contains game progress in a specific structure that supports rollback and saves. :'D More things to learn down the line.
The thing is, I understand maintaining the documentation is a huge undertaking, and I'm grateful for the amount we have. And there's the community to help fill the gaps. So I guess it's fine? In my (admittedly very limited) experience, any kind of programming is going to involve more headscratching than aha moments.

User avatar
zmook
Regular
Posts: 170
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: What is an "interaction"?

#11 Post by zmook » Wed Feb 17, 2021 6:58 pm

cheonbyeol wrote:
Wed Feb 17, 2021 4:26 pm
...I never even knew a wiki existed, since I jumped into Ren'Py a couple weeks ago. That's a pity. The forums are great, even if a little chaotic (and it doesn't help I keep getting timeout errors when I go beyond page of any search), and the Discord is nice too.
FWIW, google search is faster and more effective than the forum built-in search. There *are* lots of answers out there.
* Syntax for functions, dictionaries, etc, is just standard python, no? There are hundreds of sources to document and/or teach that part.
Mmm, yes, I guess? Though I wasn't entirely sure where in Ren'Py I should place those Python blocks, if there was some special syntax of calling functions in script and/or screens, etc. Maybe that's just me. Eventually got it with trial and error.
Yeah, the biggest thing missing from the docs is examples.
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

User avatar
zmook
Regular
Posts: 170
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: What is an "interaction"?

#12 Post by zmook » Thu Feb 25, 2021 10:53 am

Is this (implicitly) the definition of an interaction? "An interaction is when ui.interact() is called"?
ui.interact(roll_forward=None, mouse='default')
Causes an interaction with the user, and returns the result of that interaction. This causes Ren'Py to redraw the screen and begin processing input events. When a displayable returns a value in response to an event, that value is returned from ui.interact, and the interaction ends.

This function is rarely called directly. It is usually called by other parts of Ren'Py, including the say statement, menu statement, with statement, pause statement, call screen, renpy.input(), among many other functions. However, it can be called directly if necessary.

When an interaction ends, the transient layer and all screens shown with transient=True are cleared from the scene lists.
https://www.renpy.org/doc/html/screen_p ... i.interact
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 718
Joined: Fri Jul 12, 2019 5:21 am
Projects: The Button Man
Organization: NILA
Github: hell-oh-world
Location: Philippines
Contact:

Re: What is an "interaction"?

#13 Post by hell_oh_world » Thu Feb 25, 2021 9:03 pm


User avatar
zmook
Regular
Posts: 170
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: What is an "interaction"?

#14 Post by zmook » Fri Feb 26, 2021 12:09 am

hell_oh_world wrote:
Thu Feb 25, 2021 9:03 pm
https://patreon.renpy.org/interaction.html Under the Hood: Interactions
oh my god yes, that is the explanation I've been searching for! Thank you. Somehow Google does not know that page exists.

So the short answer is, yes, an interaction is what happens when ui.interact() is called.
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

Post Reply

Who is online

Users browsing this forum: Corynth, strayerror