Character callbacks?

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.
Message
Author
derik
Regular
Posts: 57
Joined: Wed Oct 18, 2006 4:56 am
Contact:

Character callbacks?

#1 Post by derik »

I'm squinting my way through the reference files, and I'm curious about the optional callback parameter of the character note.

What kind of function does it call back to? A Python function? A renpy function? (it seems like it could take a renpy function, but to do anything intelligent with the passed values you'd need a python one...)

Specifically, I have a character who makes a call over the radio. I'd like to have an audio crackle play whenever he walks (but not after {w}'s)

Is that possible?

And while I'm posting (see me deviously slip this into the main forum...)
This is the project file of the educational prototype my Bio Systems class did for the College of St Catherines.
http://www.emopanda.com/2davids.zip
It's frustratingly incomplete- we were aiming to have 1 of the 3 'areas' done in addition to the shell/intro sequence. We ended up with that area implemented- but empty of content. Two days more and it would have been done-- how frustrating!

Oh well, it's still fun to look at- this is what happens when you dump more than 200 hours of photoshop into a project.

Our client seemed pleased- he's looking at giving the project files over to a couple of his grad students to finish, since Renpy's structure is considerably more rigid than the usual flash project, this should make it easier for a second team to take up the baton.

Uh- the project's purpose is to serve as a primer on climate change for incoming freshmen who are taking environmental science classes solely because they don't want to take physics or chemistry, and have no previous experience with the subject. ;-)

I wanna thank Tom especially for all his help with my questions. Hopefully he gets a kick out of the project file- it's definitely not the conventional application of the renpy engine.

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

#2 Post by DaFool »

That is so insane! 200 hours photoshopping (by an entire class no less), no kidding!

It's like utsukushii effects x 1000.

User avatar
PyTom
Ren'Py Creator
Posts: 16122
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Character callbacks?

#3 Post by PyTom »

Wow... that's a really good use of Ren'Py's effects programming code. I just upped back up the sound buffer size, since I was getting some sound skipping.

(Of course, I'm not sure I buy climate change, or at least the premise that it's human-caused and something we should actively prevent.)
derik wrote:What kind of function does it call back to? A Python function? A renpy function? (it seems like it could take a renpy function, but to do anything intelligent with the passed values you'd need a python one...)

Specifically, I have a character who makes a call over the radio. I'd like to have an audio crackle play whenever he walks (but not after {w}'s)
It's a python function, that takes a single argument. You could write something like:

Code: Select all

init:
    python:
        def static_cb(event, **kwargs):
            if event == "begin":
                renpy.sound.play('static.ogg', channel=2) 

     $ sj = Character("Staticy Joe, the Electric Hobo", callback=static_cb)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

ShiraiJunichi
Miko-Class Veteran
Posts: 651
Joined: Sat May 21, 2005 12:28 pm
Location: University of Utah
Contact:

#4 Post by ShiraiJunichi »

Wow- that's very impressive. It did seem a bit jumpy sometimes though- like when it would begin a pan or something.

derik
Regular
Posts: 57
Joined: Wed Oct 18, 2006 4:56 am
Contact:

#5 Post by derik »

DaFool wrote:That is so insane! 200 hours photoshopping (by an entire class no less), no kidding!
Nah, class was broken up into small groups. And I did 95% of the PS work for mine.
DaFool wrote:It's like utsukushii effects x 1000.
You know, I've never seen utsukushii effects. I think the only link I ever found for it had expired.

I'm actually rather self-conscious about the code, because I never bothered to clean up the pauses with touchbacks to skip you ahead if you skipped, so it's possible to throw some of the sequences off.
ShiraiJunichi wrote:Wow- that's very impressive. It did seem a bit jumpy sometimes though- like when it would begin a pan or something.
Four simultaneous panning elements with alpha (over 2000 pixels wide I think) plus particles might have been a bit much to ask of the software...

derik
Regular
Posts: 57
Joined: Wed Oct 18, 2006 4:56 am
Contact:

Re: Character callbacks?

#6 Post by derik »

PyTom wrote:Wow... that's a really good use of Ren'Py's effects programming code. I just upped back up the sound buffer size, since I was getting some sound skipping.
Oh, was that what was cauaing it? I assumed it was because I had all mp3's. (couldn't quite get the wav settings figured out to work.)

Do you have an ogg converter you recommend? (I know nothing about ogg format.)
PyTom wrote:(Of course, I'm not sure I buy climate change, or at least the premise that it's human-caused and something we should actively prevent.)
Only 2/3 of the carbon dumped into the atmosphere by manmade processes gets scrubbed out again. The net result has been (IIRC) a 5% increase in carbon in the atmosphere.

You can sell me on the idea that the earth goes through hot/cold cycles as part of it's rotation- but I really don't believe the carbon cycle is supposed to fluctuate like that. 5% increase in a system that was at equilibrium... is bad.

(The project included us doing all our own research, I did deforestation for carbon binding, reading like 40 different articles and perspectives and synthesizing what I felt was 'really' happening.)
PyTom wrote:
derik wrote:What kind of function does it call back to? A Python function? A renpy function? (it seems like it could take a renpy function, but to do anything intelligent with the passed values you'd need a python one...)

Specifically, I have a character who makes a call over the radio. I'd like to have an audio crackle play whenever he walks (but not after {w}'s)
It's a python function, that takes a single argument. You could write something like:

Code: Select all

init:
    python:
        def static_cb(event, **kwargs):
            if event == "begin":
                renpy.sound.play('static.ogg', channel=2) 

     $ sj = Character("Staticy Joe, the Electric Hobo", callback=static_cb)
...that's loosk simple enough. Wait-- what's a 'kwarg'?

monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

#7 Post by monele »

...that's loosk simple enough. Wait-- what's a 'kwarg'?
I'm not sure but it's behind you and looks menacing o_o;...

Um, more seriously, I think it stands for KeyWord Argument. This means you should be able to add named arguments such as "something=value".

*hasn't seen the project yet*

User avatar
PyTom
Ren'Py Creator
Posts: 16122
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Character callbacks?

#8 Post by PyTom »

derik wrote:Oh, was that what was cauaing it? I assumed it was because I had all mp3's. (couldn't quite get the wav settings figured out to work.)
You can grab the code to fix it from:

http://www.renpy.org/wiki/renpy/releases/5.6.6
Do you have an ogg converter you recommend? (I know nothing about ogg format.)
I tend to use the command-line oggenc, and I hear oggdrop is fairly good. One thing is that oggs can generally be encoded at fairly low quality settings, and still sound good... 1 or 2 is probably okay.
Only 2/3 of the carbon dumped into the atmosphere by manmade processes gets scrubbed out again. The net result has been (IIRC) a 5% increase in carbon in the atmosphere.
The thing is, CO2 has increased from 0.0313% to 0.0367% between 1960 and 2005. I show that as a 17% increase, but the absolute amount is fairly small.
You can sell me on the idea that the earth goes through hot/cold cycles as part of it's rotation- but I really don't believe the carbon cycle is supposed to fluctuate like that. 5% increase in a system that was at equilibrium... is bad.
I'm not sure where you get the 5% from. You really need to give a time period on that. I'm showing 17% over 45 years, or about .4% increase a year.

The thing is, it's not clear it's worth doing anything about. The temperature record is a statistical mess (see the Wegman report), so we don't have a good idea of temperature over time, or the amount of the change attributable to human causes.

It's also not clear that acting drastically now is the right response... A better approach might be to put money into projects like nuclear fusion (ITER) and pebble-bed reactors, and use those to lower the carbon output.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

derik
Regular
Posts: 57
Joined: Wed Oct 18, 2006 4:56 am
Contact:

Re: Character callbacks?

#9 Post by derik »

PyTom wrote:
You can sell me on the idea that the earth goes through hot/cold cycles as part of it's rotation- but I really don't believe the carbon cycle is supposed to fluctuate like that. 5% increase in a system that was at equilibrium... is bad.
I'm not sure where you get the 5% from. You really need to give a time period on that. I'm showing 17% over 45 years, or about .4% increase a year.

The thing is, it's not clear it's worth doing anything about. The temperature record is a statistical mess (see the Wegman report), so we don't have a good idea of temperature over time, or the amount of the change attributable to human causes.

It's also not clear that acting drastically now is the right response... A better approach might be to put money into projects like nuclear fusion (ITER) and pebble-bed reactors, and use those to lower the carbon output.
*checks his notes now that he's home.* OOhs, 5 years, not 5%, I knew there was a 5 in there somewhere.

Here's my raw notes, I got basically the same picture from 4 different sources that went back to the numbers, so this is just the agregate.
Carbon in the atmosphere increased by 15 gigatonnes between 1994 and 2002, about 1.5 ppm per year. Total atmospheric carbon load was 765 gigatons.
Atmospheric carbon is increasing at 1.6gt per year, 20-25% of human carbon emissions.
Atmospheric carbon load increased by 1% every 5 years (or so)
Natural transfers of carbon dioxide are ~20 times greater than manmade ones.
The total amount of carbon in the atmosphere is increasing, to the tune of about 1% every five years, and it's not being scrubbed out again.

The system was at equilibrium before man started throwing carbon into the atmosphere, if 20 units of carbon went up, it could scrub 20 units out again. But the margin of capacity in the cleaning cycle was only about 3%. So when suddenly 21 units of carbon were going into the atmosphere- only 20.8 units were begin scrubbed out, and that .2 stays, every year.

(That's leaving out how trees are one of the main carbon-binders, and how we're actually increasing over all amount of carbon in circulation by digging up and burning fossil fuels which has been in long-term storage.)

That the ATMOSPHERE is changing there can be no question- the real question is-- how much difference does it make?

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: Character callbacks?

#10 Post by Jake »

Leaving aside my opinion on climate change,
derik wrote:
Carbon in the atmosphere increased by 15 gigatonnes between 1994 and 2002, about 1.5 ppm per year. Total atmospheric carbon load was 765 gigatons.
Do you really mean that, or should they both read 'gigatonnes' or both read 'gigatons'?
Server error: user 'Jake' not found

derik
Regular
Posts: 57
Joined: Wed Oct 18, 2006 4:56 am
Contact:

Re: Character callbacks?

#11 Post by derik »

Jake wrote:Leaving aside my opinion on climate change,
derik wrote:
Carbon in the atmosphere increased by 15 gigatonnes between 1994 and 2002, about 1.5 ppm per year. Total atmospheric carbon load was 765 gigatons.
Do you really mean that, or should they both read 'gigatonnes' or both read 'gigatons'?
Probably the first one is wrong- these are my hand-types rough notes, which are full of spelling errors. (Is gigatonnes actually a word? Does it mean metric tons or something?)

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: Character callbacks?

#12 Post by Jake »

derik wrote:(Is gigatonnes actually a word? Does it mean metric tons or something?)
Yeah - a 'tonne' is a metric unit equal to one thousand kilograms; a 'ton' is an Imperial unit which is apparently equal to just over 907 kilograms.

Since a lot of science is done in SI [metric] units (since SI units are a lot friendlier to science than Imperial is) it's entirely plausible that your sources used 'gigatonnes' at some point, though.

(I'd have thought that it wouldn't be a good idea to give a metric unit a similar name to an existing Imperial one, since it would be easily confused... and mass already has the kilogram, after all...)
Server error: user 'Jake' not found

derik
Regular
Posts: 57
Joined: Wed Oct 18, 2006 4:56 am
Contact:

Re: Character callbacks?

#13 Post by derik »

Jake wrote:
derik wrote:(Is gigatonnes actually a word? Does it mean metric tons or something?)
Yeah - a 'tonne' is a metric unit equal to one thousand kilograms; a 'ton' is an Imperial unit which is apparently equal to just over 907 kilograms.
That sounds unnecessarily confusing. The Metric System must be stopped, no matter the cost.

I recommend we steal all the Standard Kilograms- Tom can hit the ISK while he's in France. There's only about 80 of them worldwide, surely there's enough Renpy adherents to do one-each.

That will spell the downfall of international weights and measures, and the Metric System's tyrannical grip on the world.

I mean, lets face it... for all its rationalist propoganda- the metricicists have just replaced one set of arbitrary measures with another. Meters instead of feet, centimeters instead of inches. Kilometer, Meter, Centimeter and Millimeter. Four Inches is ten centimeters- not a decimeter. And when is the last time you heard someone give a size in decameters? (A term my spellcheck doesn't even recognize!) completely unused- even as measurements are rounded off to the nearest ten.

And while I'm not entirely certain, I have the sneaking suspicion that the length of a meter may actually CHANGE near a black hole.
Good old English Measures for me- let the British have their precious metric system, no matter how many satellites it costs us!

NetGenSuperstar
Regular
Posts: 113
Joined: Sun Oct 08, 2006 1:29 am
Location: BEHIND YOU!!!
Contact:

Re: Character callbacks?

#14 Post by NetGenSuperstar »

derik wrote:That sounds unnecessarily confusing. The US measurement System must be stopped, no matter the cost.
Corrected for truth. :D

User avatar
PyTom
Ren'Py Creator
Posts: 16122
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#15 Post by PyTom »

I actually think the US system is more elegant, since it's based on powers of two, rather than powers of ten. Give me a gallon measure, and I can make you a quart measure... It's much harder to make deciliters from a liter measure.

(I will admit that linear measure is screwed up. I think nautical miles is the only really elegant unit in that department.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: No registered users