Need help understanding what I've done wrong

Ok so I've been attempting to learn RGSS3 and scripting in ace and for the most part have been doing pretty good until now... I have been following diamondandplatinum3's scripting tutorials and have written a few scripts with what I've learned but in an attempt to follow him and script the latest script I have run into an odd problem that I can't seem to figure out.

Here is the script:

module BalloonFX

  

Event_Switch_ID = 10

    

  Exclamation  = ["Raise1", 80, 100]

  Question     = ["Confuse", 80, 100]

  Music_Note   = ["Sound1", 80, 100]

  Heart        = ["Recovery", 80, 100]

  Anger        = ["Buzzer1", 80, 100]

  Sweat        = ["Fall", 80, 100]

  Cobweb       = ["Sand", 80, 100]

  Silence      = ["Silence", 80, 100]

  Lightbulb    = ["Stare", 80, 100]

  Zzz          = ["Sleep", 80, 100]

end

 

class Sprite_Character < Sprite_Base

  #--------------------------------------------------------------------------

  # * Start Balloon Icon Display

  #--------------------------------------------------------------------------

alias leum_balloonsoundfx_spritecharacter_start_balloon_swf5    start_balloon  

  def start_balloon

p(@balloon_id)

    unless $game_switches[balloonFX::Event_Switch_ID]    

case @balloon_id

  when 1

    RPG::SE.new(*BalloonFX::Exclamation).play   if BalloonFX::Exclamation[0]

  when 2

    RPG::SE.new(*BalloonFX::Question).play      if BalloonFX::Question[0]

  when 3

    RPG::SE.new(*BalloonFX::Music_Note).play    if BalloonFX::Music_Note[0]

  when 4

    RPG::SE.new(*BalloonFX::Heart).play         if BalloonFX::Heart[0]

  when 5

    RPG::SE.new(*BalloonFX::Anger).play         if BalloonFX::Anger[0]

  when 6

    RPG::SE.new(*BalloonFX::Sweat).play         if BalloonFX::Sweat[0]

  when 7

    RPG::SE.new(*BalloonFX::Cobweb).play        if BalloonFX::Cobweb[0]

  when 8

    RPG::SE.new(*BalloonFX::Silence).play       if BalloonFX::Silence[0]

  when 9

    RPG::SE.new(*BalloonFX::Lightbulb).play     if BalloonFX::Lightbulb[0]

  when 10

    RPG::SE.new(*BalloonFX::Zzz).play           if BalloonFX::Zzz[0]

    end

    leum_balloonsoundfx_spritecharacter_start_balloon_swf5

    end

  end  

end
It works as intended and plays sounds when the balloons pop up above the target character's head and in the console it counts the balloons from 1 to 10 and shows the graphics. This is what I want it to do when the event trigger is off.

 

When the event trigger is triggered in the game, however, and is turned on and you talk to the target character again it will repeatedly spam the first balloon so quickly that you do not see any graphics pop up above the event character's head (not what is intended), no sound will play (which is intended), and in the console you see only "1" (the first balloon's id) being spammed at an incredible rate as if there's a loop in place (not what is intended), but I'm not seeing the loop.

 

Any help would be greatly appreciated as I'm pretty confused on what exactly is happening... also how do I take screenshots to show further what I'm talking about? and I hope this was pretty clear as to what is going on and what I want the code to do.

 

Thanks in advance,

Leum.
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.
well since it's combined with an event, better show the event too?


btw, I think it loops because it tries to show the balloon, and since when the trigger is on, it doesn't proceed to making the balloon, it runs into some kinda problem...


I have run into a looping problem before too when I tried to remove everything inside the Scene_Map's menu calling method so I wouldn't wonder if it turns out to be the same case... most probably, the balloon making method is running in a loop until it senses that the balloon is actually made...
sorry I didn't realize I was in the wrong forum. How do I show the event, just copy the event code? or better yet how do I take a screeny to show the events themselves and their code?
take a screenie of course... though I think it's a problem with you modifying the way balloons are handled...
So is the goal to play a sound effect for a balloon when a particular switch is on? If that's the only purpose, I think the issue is that the call of the alias'd method is inside the unless statement and thus a balloon is never properly started when the sound effects are off.
yeah, which then causes a looping problem with the method that creates the balloon...


I suggest looking at how the original method does things, and try to just make it return a nil balloon when the switch is on
here's the screenies

Any idea how to fix this to work properly? the tutorial doesn't explain what's went wrong or why or how to fix it.

Thanks,

Leum.

Screenshot (1).png

Screenshot (2).png
as I said above:

I suggest looking at how the original method does things, and try to just make it return a nil balloon when the switch is on
oh, that makes sense and you were right, I moved the aliased method call to one end lower and it fixed the issue entirely, thank you for explaining that it made a lot of sense... thanks for helping me fix this 🙂

Leum.
Also, if you want to not use the aliased method, better just overwrite it... there's no point aliasing it if you're not gonna call it anyway... though you need to be careful, as like what you experienced shows, changing the way things go can be troublesome.... 🙂
I may be calling it in the future, it's why I did it that way but ty so much.

🙂 leum
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/need-help-understanding-what-ive-done-wrong.20877/