• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Making Message Shortcuts (Like \\se or \b) [SOLVED]

132
Posts
9
Years
Hi all, I'm trying to add a shortcut that, when typing "\un" in a message box, it plays a certain sound effect and erases the "\un". It should work similar to text like \c[n], which changes text color without you having to call a script. I've been looking through the script sections Messages and DrawText, and tried adding this command (which didn't work):
Code:
elsif control=="un" # achievement sound
      Audio.se_play("Audio/ME/Unlock",75)
elsif control=="f"
      facewindow.dispose if facewindow
      facewindow=PictureWindow.new("Graphics/Pictures/#{param}")
I added "f" for comparison; when including \f[n], it simply adds a face graphic. Similarly, I want to make it so including \un makes a certain sound play. How can I do this? Thx!
 
Last edited:

Poq

144
Posts
6
Years
  • Age 34
  • Seen Aug 28, 2021
Actually, there's already code built in for this.
\se[X] plays the sound effect named X.
The same works with \me[X] except that it's a music effect.
 
132
Posts
9
Years
Actually, there's already code built in for this.
\se[X] plays the sound effect named X.
The same works with \me[X] except that it's a music effect.

Thanks for the reply! I was aware of this code, but I really wanted to learn how to make custom shortcuts to neaten my own workflow. I wanted a shortcut to trigger a certain sound, without having to specify the sound file name within the brackets. This would've just kept things neater, but I suppose I could use \me[x] if I kept the sound file name to, like, one letter.
 

Poq

144
Posts
6
Years
  • Age 34
  • Seen Aug 28, 2021
Okay, well if you do want to add a new control like that, look in the Messages script section for the "show text" controls (there's a heading commented out). A little below that (line 1177 in my copy of 17.2) is a case statement
case control
Below that are a bunch of those controls including the "se" and "me" varieties. I would copy "se" and just specify which audio file it plays.

Hopefully this makes sense.
 
132
Posts
9
Years
See, that's exactly what I was looking at. I copied the
Code:
when "se" # Play SE
          pbSEPlay(pbStringToAudioFile(param))
and put the audio file name where param is, but it didn't play the sound. It's important to note that, in the message, it also didn't remove the " \un ". Must be more to it, hiding somewhere in the script section. It's not too much of an issue, but thanks for the help!
 

Poq

144
Posts
6
Years
  • Age 34
  • Seen Aug 28, 2021
See, that's exactly what I was looking at. I copied the
Code:
when "se" # Play SE
          pbSEPlay(pbStringToAudioFile(param))
and put the audio file name where param is, but it didn't play the sound. It's important to note that, in the message, it also didn't remove the " \un ". Must be more to it, hiding somewhere in the script section. It's not too much of an issue, but thanks for the help!

Okay, I think I know what's missing. Look in the script for this block:
Code:
  while text[/(?:\\([WwFf]|[Ff][Ff]|[Tt][Ss]|[Cc][Ll]|[Mm][Ee]|[Ss][Ee]|[Ww][Tt]|[Ww][Tt][Nn][Pp]|[Cc][Hh])\[([^\]]*)\]|\\([Gg]|[Cc][Nn]|[Ww][Dd]|[Ww][Mm]|[Oo][Pp]|[Cc][Ll]|[Ww][Uu]|[\.]|[\|]|[\!]|[\x5E])())/i]
    textchunks.push($~.pre_match)
    if $~[1]
      controls.push([$~[1].downcase,$~[2],-1])
    else
      controls.push([$~[3].downcase,"",-1])
    end
    text=$~.post_match
  end
I believe this is what handles removing your control from the message. In that long list of letters, you'll want to include your control as [Uu][Nn]|

That should make a difference, but there may still be more to it. This is right at the edge of my RGSS knowledge, so I could easily be missing something.
 
132
Posts
9
Years
Okay, I think I know what's missing. Look in the script for this block:
Code:
  while text[/(?:\\([WwFf]|[Ff][Ff]|[Tt][Ss]|[Cc][Ll]|[Mm][Ee]|[Ss][Ee]|[Ww][Tt]|[Ww][Tt][Nn][Pp]|[Cc][Hh])\[([^\]]*)\]|\\([Gg]|[Cc][Nn]|[Ww][Dd]|[Ww][Mm]|[Oo][Pp]|[Cc][Ll]|[Ww][Uu]|[\.]|[\|]|[\!]|[\x5E])())/i]
    textchunks.push($~.pre_match)
    if $~[1]
      controls.push([$~[1].downcase,$~[2],-1])
    else
      controls.push([$~[3].downcase,"",-1])
    end
    text=$~.post_match
  end
I believe this is what handles removing your control from the message. In that long list of letters, you'll want to include your control as [Uu][Nn]|

That should make a difference, but there may still be more to it. This is right at the edge of my RGSS knowledge, so I could easily be missing something.

That was it! So cool. Thanks!
 
Back
Top