RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Play SE On Balloon Pop-Up

0 Members and 1 Guest are viewing this topic.

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
Play SE On Balloon Pop-Up
Version: 1.0
Author: DiamondandPlatinum3
Date: July 31, 2012



Planned Future Versions

  • You Tell Me :)
Description

This script allows you to play an SE (Sound Effect) when a balloon icon pops-up above someones head.

Features

  • Can set an individual SE to play depending on which balloon is displayed.
Screenshots

You cannot screenshot audio playing, I'm afraid :-[


Instructions

It's completely plug and play.
All you need to do is copy the script and place it under materials but above main in your script editor.

Then you go to the editable region and change the appropriate settings to suit your needs.


Script

Get it from here

Credit


  • DP3 / DiamondandPlatinum3



Support


Post in this thread or PM me.

Known Compatibility Issues

Any scripts that rewrite the start_balloon method might clash with this one.
Don't worry though, I think it's pretty unlikely that you'll find many scripts that do things with the balloons.

Demo


A demo is unnecessary for a script such as this.

Author's Notes

Make sure that your Custom SE files are located in the SE Folder before using this script. RTP SE can still be used even if they are not in your SE Folder ;)

Terms of Use


If you can find a use for it, this script is free to use in non-commercial games. If you want to use this script in a commercial game, please understand that I expect a free copy (that's means you PM me and let me know that you plan on using it for a commercial game).
« Last Edit: December 11, 2013, 12:26:18 PM by D&P3 »
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Looks good! The only thing that I would change is that I would move the variable definitions outside of the start_balloon method and I would make them class variables or else move them outside the class altogether. That would (a) be easier on memory since the value of the variables is the same for every instance of Sprite_Character; and (b) it would also make it easier to alias the start_balloon method if you ever needed to in some other script. Those aren't major benefits though.

You might also want to make the names of the variables a little more unique.
« Last Edit: July 31, 2012, 12:30:10 PM by modern algebra »

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
In the original script I had it inside of a module, but on one of my other scripts Pacman suggested that I use the variables in that script as local variables instead of instance variables :o

Spoiler for original script:
Code: [Select]
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#             Play SE On Balloon Pop-Up
#             Version: 1.0
#             Author: DiamondandPlatinum3
#             Date: July 2, 2012
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#
#    This script allows you to play an SE (Sound Effect) when a ballon icon
#    pops-up above someones head.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#------------------------------------------------------------------------------
#  Instructions:

#     -  All you have to do is go into the editable region and change the
#        appropriate settings to suit your needs. This includes which SE plays
#        depending on the balloon icon that is being shown.
#
#     -  If you do not wish for a SE to play on any specific balloon icon,
#        simply set the value to nil.
#
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

module DP3_BalloonSE_Options
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#                                                        -=
#                 Editable Region        ////            ==
#                                                        =-
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  SE_Volume          = 80           #  Volume of the SE
  SE_Pitch           = 100          #  Pitch of the SE
 
  Exclamation_SE     = "Raise1"     # SE played with Exclamation Balloon
  Question_SE        = "Confuse"    # SE played with Question Balloon
  Music_Note_SE      = "Sound1"     # SE played with Music Note Balloon
  Heart_SE           = "Recovery"   # SE played with Heart Balloon
  Anger_SE           = "Buzzer1"    # SE played with Anger Balloon
  Sweat_SE           = "Down"       # SE played with Sweat Balloon
  Cobweb_SE          = "Sand"       # SE played with Cobweb Balloon
  Silence_SE         = "Stare"      # SE played with Silence Balloon
  Lightbulb_SE       = "Bell"       # SE played with Lightbulb Balloon
  Zzz_SE             = nil          # SE played with Zzz Balloon
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
end # of Editable Region
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#---------------------------------------------------------
# No touchie past here unless you know what you are
# doing. Failure to heed this warning could cause your
# computer to yell and scream at you.
#
# Edit at your own risk.
#--------------------------------------------------------



class Sprite_Character < Sprite_Base
 
  alias dp3_balloon_sfx_play_9huf start_balloon
 
  def start_balloon
    #Find out which balloon is being used and play the SE appropriately.
    if @balloon_id == 1
      RPG::SE.new(DP3_BalloonSE_Options::Exclamation_SE, DP3_BalloonSE_Options::SE_Volume,DP3_BalloonSE_Options::SE_Pitch).play if DP3_BalloonSE_Options::Exclamation_SE != nil
    elsif @balloon_id == 2
      RPG::SE.new(DP3_BalloonSE_Options::Question_SE, DP3_BalloonSE_Options::SE_Volume,DP3_BalloonSE_Options::SE_Pitch).play if DP3_BalloonSE_Options::Question_SE != nil
    elsif @balloon_id == 3
      RPG::SE.new(DP3_BalloonSE_Options::Music_Note_SE, DP3_BalloonSE_Options::SE_Volume,DP3_BalloonSE_Options::SE_Pitch).play if DP3_BalloonSE_Options::Music_Note_SE != nil
    elsif @balloon_id == 4
      RPG::SE.new(DP3_BalloonSE_Options::Heart_SE, DP3_BalloonSE_Options::SE_Volume,DP3_BalloonSE_Options::SE_Pitch).play if DP3_BalloonSE_Options::Heart_SE != nil
    elsif @balloon_id == 5
      RPG::SE.new(DP3_BalloonSE_Options::Anger_SE, DP3_BalloonSE_Options::SE_Volume,DP3_BalloonSE_Options::SE_Pitch).play if DP3_BalloonSE_Options::Anger_SE != nil
    elsif @balloon_id == 6
      RPG::SE.new(DP3_BalloonSE_Options::Sweat_SE, DP3_BalloonSE_Options::SE_Volume,DP3_BalloonSE_Options::SE_Pitch).play if DP3_BalloonSE_Options::Sweat_SE != nil
    elsif @balloon_id == 7
      RPG::SE.new(DP3_BalloonSE_Options::Cobweb_SE, DP3_BalloonSE_Options::SE_Volume,DP3_BalloonSE_Options::SE_Pitch).play if DP3_BalloonSE_Options::Cobweb_SE != nil
    elsif @balloon_id == 8
      RPG::SE.new(DP3_BalloonSE_Options::Silence_SE, DP3_BalloonSE_Options::SE_Volume,DP3_BalloonSE_Options::SE_Pitch).play if DP3_BalloonSE_Options::Silence_SE != nil
    elsif @balloon_id == 9
      RPG::SE.new(DP3_BalloonSE_Options::Lightbulb_SE, DP3_BalloonSE_Options::SE_Volume,DP3_BalloonSE_Options::SE_Pitch).play if DP3_BalloonSE_Options::Lightbulb_SE != nil
    elsif @balloon_id == 10
      RPG::SE.new(DP3_BalloonSE_Options::Zzz_SE, DP3_BalloonSE_Options::SE_Volume,DP3_BalloonSE_Options::SE_Pitch).play if DP3_BalloonSE_Options::Zzz_SE != nil
    end
 
    dp3_balloon_sfx_play_9huf
   
  end # of function
end # of class

Any suggestions on when I should use modules and when I should use locals?


(Original script was for VX, was just porting it over to VXA cause I thought it might be useful for guilds; Only I found out that it was completely compatible (save for a few sound files that VXA seems to have changed)).
« Last Edit: July 31, 2012, 12:51:12 PM by D&P3 »
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
First, your post demonstrated a little confusion with terminology regarding variables and constants, in that you refer to constants in a module as instance variables and instance variables as local. The following tutorial isn't great at explaining when to use each, but it should help with the terminology: http://www.techotopia.com/index.php/Ruby_Variable_Scope#What_is_Variable_Scope.3F

With regard to your question about modules, when people use them as a place to configure their scripts, it is generally to create a unique namespace. So you might want to do that if you have a lot of constants to set and they have similar names to what other people might use in their own scripts. It's mostly just a scripting preference whether you house your configuration inside a module. It can make things a lot neater.1

Anyway, I wasn't saying that you should put them in a module necessarily; I just don't think you should use instance variables to hold configuration unless you would ever want the SE played to change depending on which instance of the class is calling the method. In other words, if you want one sprite's Sweat Balloon to make one sound and you want another sprite's Sweat Balloon to make a different sound, then you would use instance variables. Otherwise you are wasting memory by having every instance of a class hold the same values.

With few exceptions, constants are what you want to use for configuration. I suspect that what Pacman meant when he said to localize them was not to make them instance variables, but simply to house the constants in the Sprite_Character class, like so:

Code: [Select]
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#             Play SE On Balloon Pop-Up
#             Version: 1.0
#             Author: DiamondandPlatinum3
#             Date: July 2, 2012
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#
#    This script allows you to play an SE (Sound Effect) when a ballon icon
#    pops-up above someones head.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#------------------------------------------------------------------------------
#  Instructions:

#     -  All you have to do is go into the editable region and change the
#        appropriate settings to suit your needs. This includes which SE plays
#        depending on the balloon icon that is being shown.
#
#     -  If you do not wish for a SE to play on any specific balloon icon,
#        simply set the value to nil.
#
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

class Sprite_Character < Sprite_Base

#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#                                                        -=
#                 Editable Region        ////            ==
#                                                        =-
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  SE_Volume          = 80           #  Volume of the SE
  SE_Pitch           = 100          #  Pitch of the SE
 
  Exclamation_SE     = "Raise1"     # SE played with Exclamation Balloon
  Question_SE        = "Confuse"    # SE played with Question Balloon
  Music_Note_SE      = "Sound1"     # SE played with Music Note Balloon
  Heart_SE           = "Recovery"   # SE played with Heart Balloon
  Anger_SE           = "Buzzer1"    # SE played with Anger Balloon
  Sweat_SE           = "Down"       # SE played with Sweat Balloon
  Cobweb_SE          = "Sand"       # SE played with Cobweb Balloon
  Silence_SE         = "Stare"      # SE played with Silence Balloon
  Lightbulb_SE       = "Bell"       # SE played with Lightbulb Balloon
  Zzz_SE             = nil          # SE played with Zzz Balloon
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#---------------------------------------------------------
# No touchie past here unless you know what you are
# doing. Failure to heed this warning could cause your
# computer to yell and scream at you.
#
# Edit at your own risk.
#--------------------------------------------------------
  alias dp3_balloon_sfx_play_9huf start_balloon
 
  def start_balloon
    #Find out which balloon is being used and play the SE appropriately.
    if @balloon_id == 1
      RPG::SE.new(Exclamation_SE, SE_Volume,SE_Pitch).play if Exclamation_SE != nil
    elsif @balloon_id == 2
      RPG::SE.new(Question_SE, SE_Volume,SE_Pitch).play if Question_SE != nil
    elsif @balloon_id == 3
      RPG::SE.new(Music_Note_SE, SE_Volume,SE_Pitch).play if Music_Note_SE != nil
    elsif @balloon_id == 4
      RPG::SE.new(Heart_SE, SE_Volume,SE_Pitch).play if Heart_SE != nil
    elsif @balloon_id == 5
      RPG::SE.new(Anger_SE, SE_Volume,SE_Pitch).play if Anger_SE != nil
    elsif @balloon_id == 6
      RPG::SE.new(Sweat_SE, SE_Volume,SE_Pitch).play if Sweat_SE != nil
    elsif @balloon_id == 7
      RPG::SE.new(Cobweb_SE, SE_Volume,SE_Pitch).play if Cobweb_SE != nil
    elsif @balloon_id == 8
      RPG::SE.new(Silence_SE, SE_Volume,SE_Pitch).play if Silence_SE != nil
    elsif @balloon_id == 9
      RPG::SE.new(Lightbulb_SE, SE_Volume,SE_Pitch).play if Lightbulb_SE != nil
    elsif @balloon_id == 10
      RPG::SE.new(Zzz_SE, SE_Volume,SE_Pitch).play if Zzz_SE != nil
    end
 
    dp3_balloon_sfx_play_9huf
   
  end # of function
end # of class


1  Modules have more important uses too, such as multiple inheritance, but that is not related to your question.
« Last Edit: July 31, 2012, 01:31:33 PM by modern algebra »

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
Ah ok, that makes sense :)
I think I'll stick with a module for this script so that people can easily read it and edit what they need to, I'll also fix that other script up (seems I misunderstood Pacman ;9).


Yeah I got the terminology wrong, sorry about that :-[ a lot of things coding related seems to have blown over my head lately.


As for your comment about multiple inheritance...
is this what you mean?

Code: [Select]
module DP3
  #Base code here (if necessary)
  module Sprite
    #code here
  end
  module Battle
    #code here
  end
end

@something = DP3::Sprite::Something  # obviously won't work as it is now


As always, thanks for your mentoring Modern. I truly appreciate it :)
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
No, what I mean by multiple inheritance is that you can mix modules in with classes. Like this:

Code: [Select]
module D
  def talk5
    p "blablablablabla"
  end
  def talk4
    p "blablablabla"
  end
end
module C
  def talk3
    p "blablabla"
  end
end
class B
  def talk2
    p "blabla"
  end
end
class A < B
  include C
  include D
  def talk1
    p "bla"
  end
end

a = A.new
a.talk1 # "bla"
a.talk2 # "blabla"
a.talk3 # "blablabla"
a.talk4 # "blablablabla"
a.talk5 # "blablablablabla"

In other words, the methods in the module become available to a class into which it is mixed.
« Last Edit: July 31, 2012, 01:53:32 PM by modern algebra »

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
Awesome, I think I get it :D
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

**
Rep:
Level 65
Oh! this script will make my life easier with less tedious eventing. Thank you for posting this!!!

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
Most welcome you are :)
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

**
Rep:
Level 86
Deviant Designer
Very useful, thanks. :)