Trigger sound effects within a text window

cuby

Perpetual Toil
Veteran
Joined
Jun 20, 2015
Messages
77
Reaction score
17
First Language
English
Primarily Uses
RMMV
Hi all,

I'm looking for a very specific piece of functionality that I haven't been able to find a plugin for, or figure out a workaround on my own.

I'm using Yanfly's message core, which I know many of us find indispensable for so many reasons. One thing it doesn't allow us to do within gameMessage, is trigger a sound effect.

There does exist the functionality to hit enter within a show text in order to advance, using \!. What I'd like to do is for an additional feature -- whether within YEP or otherwise -- to trigger a sound effect while remaining inside the text window.

Grateful as always for any advice, leads, or help. Also absolutely willing to compensate, though I'm unsure if this is the correct forum for compensated requests.

Thanks in any case!!! :LZScheeze::LZSproud::LZScheeze:
 

cuby

Perpetual Toil
Veteran
Joined
Jun 20, 2015
Messages
77
Reaction score
17
First Language
English
Primarily Uses
RMMV
One option:
Okey doke, I've read over the plugin a bunch, and I believe I can follow how it works. (I'm one of those dilettantes who can follow code reasonably well, and actually create it reasonably terribly). If it's okay with you I'd love to request a tiny bit more handholding in this case :LZSangel:

So in the case of playing a SE, the script you provide is:

var se = {};
se.name = 'Bell1';
se.volume = 20;
se.pitch = 100;
se.pan = 0;
AudioManager.playSe(se);

Seems simple enough. My question then is, where exactly am I defining the escape code? Like let's say I want A\[x] to be my escape code to play a sound effect, and I want to run the above script to play the Bell1 SE with those volume/pitch/pan parameters. Where exactly in the event am I running the above script, and how exactly would I be defining the escape char and pointing to the above script?

Thank you so much for your guidance! I'll be experimenting to try and figure it out on my own in the meantime :LZSyum:
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,853
Reaction score
1,316
First Language
EN
Primarily Uses
RMMZ
It's OK, this one is kinda advanced! :kaothx:

All the definitions are done in the plugin parameters in the Plugin Manager. This particular example is a "process" code, because it happens when the message text reaches that point. Double-click the Process Escape Codes parameter, then double-click an empty row to add a new one.

Now you should see four values:
  • Code: type in A.
    This is what the game uses to recognise the escape code. It's like the V in \V[x].

  • Arguments:
    This is a list of possible inputs. \V[x] has one input: the variable ID (an integer).

    1. If you only want to play one type of SE then no arguments are needed.
      You can use it in a message as \A (no brackets needed with no arguments).

    2. Otherwise, you could, for example, have two inputs specifying the SE name and volume.
      In that case you'll need to double-click to add two new entries to the Arguments list:
      • Choose "Text" for the first one (name);
      • Choose "Integer" for the second one (volume).
      Example use in a message: \A[Bell1, 20] (i.e. play Bell1 SE at 20% volume).

    Note that your choice here will affect how the actual script part looks.

  • Delimiters: you can leave this one as [].
    These are just the brackets used to enclose the arguments. :kaoswt:

  • Replacer: the actual script part! :kaoback:
    As mentioned in the Arguments section, this may vary if you've included inputs...

    1. With zero arguments, it looks just like the example:
      JavaScript:
      var se = {};
      se.name = 'Bell1';
      se.volume = 20;
      se.pitch = 100;
      se.pan = 0;
      AudioManager.playSe(se);
    2. With two arguments (name and volume), it might look like this:
      JavaScript:
      var se = {};
      se.name = arguments[1];
      se.volume = parseInt(arguments[2], 10);
      se.pitch = 100;
      se.pan = 0;
      AudioManager.playSe(se);
    Hope that makes sense, and if you want something different, just let me know! :kaopride:
 

cuby

Perpetual Toil
Veteran
Joined
Jun 20, 2015
Messages
77
Reaction score
17
First Language
English
Primarily Uses
RMMV
Ohhh I think I have a better idea of how this works. I had no idea these were defined in the plugin manager's parameters.

Now that I have an inkling into the functionality of the plugin, it seems to me like for my use case, it makes the most sense to trigger CE's. I'll tell ya why -- what I'm trying to do is trigger voice snippets in the middle of text msgs. I'm using the "wait for player entry" \! escape code in Yanfly, so when the player hits enter/space, the text continues, and ideally an accompanying voice SE.

Since I'll be needing different SE's every time out -- based on how I'm understanding how the plugin works -- it would seem non-ideal to start defining endless SE's since I'll be using different SE's each and every time. Makes a bit more sense to call a CE and manage things that way.

However! I've run into some questions. I'ma take some baby steps here -- first off, what I'm seeing doesn't quite square with what you describe. Here is what I see when I double click on the parameters in plugin manager. First, just to be sure, here's the Gen Settings dialog:

cae_plugin.png

But when I double click on the process escape codes parameter, I only get the single line to enter the escape codes. I'm not using the most up-to-date RPGM (I'm on 1.4.1 to ensure compatibility with some other key plugins), might that make a difference? It seems like by your description, I ought to be presented with multiple rows here, but I've only got the one:

cae_plugin2.png

Given what I'm looking at here, and keeping in mind that calling a different CE in each gameMessage appears to be the best use of the plugin, how might you proceed?

So grateful for your generous attitude Caethyril. You really are the best -- thank you so, so much :wub
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,853
Reaction score
1,316
First Language
EN
Primarily Uses
RMMZ
Oh, I see! v1.5.0 introduced a revamped Plugin Manager with a bunch of new options, see the screenshot in this thread for an example:
My plugin makes use of lists of structs, so it's very inaccessible to people using older versions of the editor. :kaoswt2:

Not to worry, though! You just want a "call common event" thing, right? Try copy+pasting this in to the Process Escape Codes text box:
JavaScript:
["{\"Code\":\"ce\",\"Arguments\":\"[\\\"Integer\\\"]\",\"Delimiters\":\"[]\",\"Replacer\":\"\\\"var ev = $dataCommonEvents[parseInt(arguments[1], 10)];\\\\nif (ev) {\\\\n  var pt = SceneManager._scene instanceof Scene_Map ?\\\\n           $gameMap._interpreter : $gameTroop._interpreter;\\\\n  var id = pt.isOnCurrentMap() ? pt.eventId() : 0;\\\\n  pt.setupChild(ev.list, id);\\\\n}\\\"\"}"]
This defines a single "process" code for calling a common event mid-text: \CE[n], where n is the ID of the common event to run. Example use in Show Text:
Code:
Welcome! \ce[1]\|Whoa, what was that?
This might not work as expected if used in a Parallel-trigger event, but otherwise should be OK. (I wouldn't recommend using Show Text in parallel anyway.) :kaophew:

Edit @cuby: actually I just re-read your summary of what you're trying to do and this may be a better option (copy+paste directly into the empty Process Escape Codes text box):
JavaScript:
["{\"Code\":\"se\",\"Arguments\":\"[\\\"Text\\\",\\\"Integer\\\"]\",\"Delimiters\":\"[]\",\"Replacer\":\"\\\"var se = {};\\\\nse.name = arguments[1];\\\\nse.volume = parseInt(arguments[2], 10);\\\\nse.pitch = 100;\\\\nse.pan = 0;\\\\nAudioManager.playSe(se);\\\"\"}"]
Then in a Show Text command you can do something like this:
Code:
\se[Bob1, 20]Welcome to the inn!\!
\se[Bob2, 30]Here for a room?
I.e. play SE "Bob1" at 20% volume, show "Welcome to the inn!", wait for player input, play SE "Bob2" at 30% volume, then show "Here for a room?". That way there's no need to define some kind of complicated system of common events. :)

(Also, an aside: \! is a default RPG Maker escape code; you can hover over the Show Text entry box in the editor to see all the default codes.)
 
Last edited:

cuby

Perpetual Toil
Veteran
Joined
Jun 20, 2015
Messages
77
Reaction score
17
First Language
English
Primarily Uses
RMMV
Not to worry, though! You just want a "call common event" thing, right? Try copy+pasting this in to the Process Escape Codes text box:
JavaScript:
["{\"Code\":\"ce\",\"Arguments\":\"[\\\"Integer\\\"]\",\"Delimiters\":\"[]\",\"Replacer\":\"\\\"var ev = $dataCommonEvents[parseInt(arguments[1], 10)];\\\\nif (ev) {\\\\n  var pt = SceneManager._scene instanceof Scene_Map ?\\\\n           $gameMap._interpreter : $gameTroop._interpreter;\\\\n  var id = pt.isOnCurrentMap() ? pt.eventId() : 0;\\\\n  pt.setupChild(ev.list, id);\\\\n}\\\"\"}"]
@caethyril not only does this work, it works BEAUTIFULLY. I am beyond floored.

This was a functionality that had me banging my head against a wall on and off for monnnnttthhhss. I had already made plans to work around it with all sorts of time-consuming bodges and sub-optimal half-solutions. And here you are with a gorgeous solution that even takes into account my old version of MV. Seriously, thank you so much, I'm so grateful for the time you've taken to help. You totally rock.

Please mark as not only solved, but solved spectacularly :LZSkiss::LZSkiss::LZSkiss::LZSkiss::LZSkiss:
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I'm hoping to get a call October 1. They should be fully open by then.


With this, all demo dungeon graphics are done.
Eventually I need to make animations...send help.
OcRam demo project is now available at https://ocram-codes.net !!!
mzBaseBody.png added!

Ami
--- Mushroom ---

F.Knight: We runs out the food!
Hero: Anything could eat in this place?
F.Archer: It's a bunch of Mushroom over there. I wonder it's safe to eat.
F.Knight: No worries,we have to fill our inside no matter what it is.
(Hero & F.Knight Eat The Mushroom,After 10 Seconds They Collapse With Foam)

Forum statistics

Threads
103,446
Messages
999,368
Members
134,985
Latest member
REEEEEOOOOOOOOO
Top