The PokéCommunity Forums Fan Games Game Development Pokémon Essentials
Scripting Question Making Message Shortcuts (Like \\se or \b) [SOLVED]

Pokémon Essentials All questions and discussion about Pokémon Essentials, the Pokémon game kit for RPG Maker XP, go in here. Also contains links to the latest downloads and the Essentials Wiki.

Reply
 
Thread Tools
  #1    
Old October 8th, 2018 (10:48 AM). Edited 4 Weeks Ago by Woah.
Woah Woah is offline
     
    Join Date: Aug 2014
    Location: New Brunswick
    Gender: Male
    Nature: Mild
    Posts: 95
    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!
    __________________

    Reply With Quote
      #2    
    Old October 9th, 2018 (6:09 AM).
    Poq's Avatar
    Poq Poq is online now
       
      Join Date: Aug 2017
      Posts: 40
      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.
      Reply With Quote
        #3    
      Old October 9th, 2018 (2:49 PM).
      Woah Woah is offline
         
        Join Date: Aug 2014
        Location: New Brunswick
        Gender: Male
        Nature: Mild
        Posts: 95
        Quote:
        Originally Posted by Poq View Post
        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.
        Reply With Quote
          #4    
        Old October 9th, 2018 (4:01 PM).
        Poq's Avatar
        Poq Poq is online now
           
          Join Date: Aug 2017
          Posts: 40
          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.
          Reply With Quote
            #5    
          Old 4 Weeks Ago (8:49 AM).
          Woah Woah is offline
             
            Join Date: Aug 2014
            Location: New Brunswick
            Gender: Male
            Nature: Mild
            Posts: 95
            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!
            Reply With Quote
              #6    
            Old 4 Weeks Ago (11:37 AM).
            Poq's Avatar
            Poq Poq is online now
               
              Join Date: Aug 2017
              Posts: 40
              Quote:
              Originally Posted by Woah View Post
              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.
              Reply With Quote
                #7    
              Old 4 Weeks Ago (9:38 AM).
              Woah Woah is offline
                 
                Join Date: Aug 2014
                Location: New Brunswick
                Gender: Male
                Nature: Mild
                Posts: 95
                Quote:
                Originally Posted by Poq View Post
                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!
                __________________

                Reply With Quote
                  #8    
                Old 4 Weeks Ago (9:57 AM).
                Poq's Avatar
                Poq Poq is online now
                   
                  Join Date: Aug 2017
                  Posts: 40
                  Quote:
                  Originally Posted by Woah View Post
                  That was it! So cool. Thanks!
                  Terrific! I'm glad we figured it out.
                  Reply With Quote
                  Reply

                  Quick Reply

                  Join the conversation!

                  Create an account to post a reply in this thread, participate in other discussions, and more!

                  Create a PokéCommunity Account
                  Thread Tools

                  Posting Rules
                  You may not post new threads
                  You may not post replies
                  You may not post attachments
                  You may not edit your posts

                  BB code is On
                  Smilies are On
                  [IMG] code is On
                  HTML code is Off

                  Forum Jump


                  All times are GMT -8. The time now is 4:11 AM.