How to simulate RenPy's text code style, to do more things..

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
ISAWHIM
Veteran
Posts: 318
Joined: Sun Nov 06, 2016 5:34 pm
Contact:

How to simulate RenPy's text code style, to do more things..

#1 Post by ISAWHIM »

What I am trying to do is create a similar "just type and go", style of function (or something), that works similar to how RenPy works.

Eg...

RenPy code/script

Code: Select all

name "Some text to say"
However, I want it to do other things, after each typed line of text. (Well, after some lines of text.)

For instance, increment time, check values for changes due to incremented time, display specific displayables when text contains certain things... Without having to type "call SomeFunction(stuff)" over and over, when it isn't needed.

EG, if a line of text is greater than, say 40 characters... It auto-increments time by 1-min, ignoring shorter text and without compounding uber-long text as multiple minutes. Also, if the text contains the word "ItemName", it displays the item in question.

I am fine with using something like this...

Code: Select all

$ Name("Say this", MyOptionalThingsToDoIfNeeded)
# This would go to my custom function, inserting the text into the normal "name" displayable, but then also do whatever other code I wanted it to do along with it.
However, I am not sure if there is a better way to do that?

I will also be doing something similar for "show ThisImage" and "show ThisScreen"... etc.

Is there some way to just attach a function to the default processor functions, like appending it? So it will pre/post process my functions before/after the RenPy display of the function? (In other languages, it is often called a callback operation/function. Or an overloading/hijacking.)

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: How to simulate RenPy's text code style, to do more thin

#2 Post by trooper6 »

There are a couple of options for you (as usual). And the different options are in the documentation.

You'll want to make your own function ultimately. You can make a function that includes the renpy.say statement and then use that for all of your say statements, or you could use a character callback.

Statement equivalents are documented here: https://www.renpy.org/doc/html/statemen ... lents.html
Character Callbacks are documented here: https://www.renpy.org/doc/html/character_callbacks.html

I'd recommend a character callback.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
ISAWHIM
Veteran
Posts: 318
Joined: Sun Nov 06, 2016 5:34 pm
Contact:

Re: How to simulate RenPy's text code style, to do more thin

#3 Post by ISAWHIM »

Perfect!

That is exactly what I was looking for. (The callback one, like you said. I am most familiar with.) Yes, this will be in my own function, in python code-blocks.

Since there was no way of avoiding python, I am force-feeding python lessons down my throat. (The long way to get to my brain.)

However, for RenPy learning, I am still at a "where do I find what I am looking for", and "what am I looking for", and "does this exist", and "what do they call this", disadvantage.

I saw the other one too... I just didn't comprehend what "**kwargs" was... a custom thing, an example thing, a required thing...

I assume it is like "self", some super.function class injection that just envelopes all "other" arguments into one keyword. (Sounds good in my head. :P) The double ** makes me think it is some super.function.
Last edited by ISAWHIM on Sun Mar 05, 2017 5:38 pm, edited 1 time in total.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: How to simulate RenPy's text code style, to do more thin

#4 Post by trooper6 »

Have you taken the free Basic Python course from Codeacademy.com that I'm pretty sure has been recommended to you before? Many of your Python specific questions (which **kwargs is) will be answered there.

Also, as this is a code question, this should be in the Questions thread, not the Creator Discussion thread.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
ISAWHIM
Veteran
Posts: 318
Joined: Sun Nov 06, 2016 5:34 pm
Contact:

Re: How to simulate RenPy's text code style, to do more thin

#5 Post by ISAWHIM »

trooper6 wrote:Have you taken the free Basic Python course from Codeacademy.com that I'm pretty sure has been recommended to you before? Many of your Python specific questions (which **kwargs is) will be answered there.
I am focusing on python at the moment, since I do not plan on using much actual RenPy code, except where needed. However, I will be watching those too. Youtube, at the moment, is still flooded with RenPy code from pre 6.99.11, which is adding to the confusion. (Telling me to do things that don't have to be done, or things that just don't work anymore.)

NOTE: Just signed-up... at Codeacademy.com. Only has the Python class... Is that what you were talking about? I thought you were pointing me to a RenPy class. :P

Knowing everything about a car doesn't tell you how to actually drive it. :P

On the opposite spectrum... Knowing how to drive a car, doesn't qualify you to race them, or repair them, or build them. :P

My brain can only absorb so much in one week!

But, again, thanks.

It is more helpful to tackle small hurdles than it is to attempt to jump right over a mountain. (Okay, enough with the fortune-cookie banter.)

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: How to simulate RenPy's text code style, to do more thin

#6 Post by trooper6 »

Yes. I was recommending the Basic Python course.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Post Reply

Who is online

Users browsing this forum: Google [Bot]