Main Menu
  • Welcome to The RPG Maker Resource Kit.

[VXA] Hover Alerts

Started by modern algebra, October 17, 2012, 01:54:21 AM

0 Members and 3 Guests are viewing this topic.

Mewgull

I ran into an error when trying to create a hover alert during a common event when drawing a variable in the 'name'

This is what I wrote in the comment:
\hover_alert[-1] { name = "+ #{$game_variables[18]}QP";
icon = 8673; effect = :rise_and_fade; }

This is the error I'm getting:

Script 'MAHoverAlers' line 286: SyntaxError occurred.

unexpected $end, expecting '}'
name = "+ #{$game_variables[18]

Yin

If you do compatibility fixes, I seem to have found one when using galv's region effects. When you have a hover alert over the player and walk over a region effected by the script, the hover alert constantly update for every tile walked on until you get off of a region effect tile.

My specific error is: I get an item (Auto gain hover alert) and as I'm walking away and enter a region effect tile, the alert keeps displaying over and over again until I stop walking or until I get off of the region effect terrain.

Kalacious

found an issue - or maybe I am doing it wrong. I set up a parallel event to make sure that the hove appears over event 2, it appears over its self instead. see demo

modern algebra

Sorry for the delay in responding. I've been away. If any of you still need help:

@Mewgull - It's because of the "#{$game_variables[18]}". The } is messing it up. I should have predicted that and fixed it, but you can do the same thing with:

name = "+ " + $game_variables[18].to_s + "QP";

@Yin - Can you recreate the error in a demo and share it with me?

@Kalacious - You can only set it to another event by that means with an interpreted code, not an automatic one at the top of the page.

Yin

Sure, here you go:
http://www.sendspace.com/file/ddblgc

Just get the glowy object and walk on the regions. The alert will keep repeating itself until you stop walking and let it finish. (Those are also MY default settings. I have not tried it with the default settings of the script.)

modern algebra

Everytime you walk on an event-generating region, galv's script disposes every character sprite and recreates it. This causes the error you detected since the hover sprite is dependent on the existence of the character to whom it is attached; when the character is disposed, so is the hover sprite.

To fix it, I needed to change that mass disposal feature of galv's script and replace it with one that only recreates the character in issue, but I am not entirely sure how that will interact with other scripts or whether it might cause problems down the line. On the plus side, however, it is less resource-intensive and will probably cause less lag in maps with many events.

Anyway, here is the patch:


#==============================================================================
#    Hover Alerts + galv's Region Effects
#    Compatibility Patch
#    Version: 1.0
#    Authors: modern algebra (rmrk.net) & galv
#    Date: 5 October 2013
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This patch fixes an error between my Hover Alerts script and galv's Region
#   Effects script. Without it, a hover alert will constantly refresh when
#   walking through an event-generating region.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Insert this script into the Script Editor (F11) in a new slot, somewhere
#   below galv's Region Effects script but still above Main.
#==============================================================================

#==============================================================================
# ** Spriteset_Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - gre_refresh_event
#==============================================================================

class Spriteset_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Refresh Event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def gre_refresh_event(id)
    # Find any existing event with the same ID
    esi = @character_sprites.find_index {|sprite| sprite &&
      sprite.is_a?(Sprite_Character) && sprite.character.is_a?(Game_Event) &&
      sprite.character.gre_event_id == id }
    if esi
      # Dispose Existing Event
      @character_sprites[esi].dispose if !@character_sprites[esi].disposed?
      @character_sprites.delete_at(esi)
    else
      esi = $game_map.events.values.size - 1
    end
    # Refresh new region event
    @character_sprites.insert(esi, Sprite_Character.new(@viewport1, $game_map.events[id]))
  end
end

#==============================================================================
# ** Game_Event
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - gre_event_id
#==============================================================================

class Game_Event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Event ID
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def gre_event_id
    @id # Get Event ID
  end
end

#==============================================================================
# ** Game_Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    overwritten method - region_effect
#==============================================================================

class Game_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Region Effect
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def region_event(dx, dy, event_id, map_id)
    # Retrieve event from the spawn map
    map_id = @map_id if map_id == 0
    event = generated_region_event($data_spawn_map, event_id)
    # Generate ID
    new_id = @effect_var.length < Region_Effects::MAX_EFFECTS ?
      (@events.keys.max.nil? ? 1 : @events.keys.max + 1) : @effect_var.shift
    @effect_var.push(new_id)
    # Create new Event
    @events[new_id] = Game_Event.new(@map_id, event)
    @events[new_id].moveto(dx, dy)
    SceneManager.scene.spriteset.gre_refresh_event(new_id) # Refresh Event
  end
end


Place it below galv's script but still above Main.

Yin

Quote from: modern algebra on October 05, 2013, 01:15:34 PM
Everytime you walk on an event-generating region, galv's script disposes every character sprite and recreates it. This causes the error you detected since the hover sprite is dependent on the existence of the character to whom it is attached; when the character is disposed, so is the hover sprite.

To fix it, I needed to change that mass disposal feature of galv's script and replace it with one that only recreates the character in issue, but I am not entirely sure how that will interact with other scripts or whether it might cause problems down the line. On the plus side, however, it is less resource-intensive and will probably cause less lag in maps with many events.

Anyway, here is the patch:


#==============================================================================
#    Hover Alerts + galv's Region Effects
#    Compatibility Patch
#    Version: 1.0
#    Authors: modern algebra (rmrk.net) & galv
#    Date: 5 October 2013
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This patch fixes an error between my Hover Alerts script and galv's Region
#   Effects script. Without it, a hover alert will constantly refresh when
#   walking through an event-generating region.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Insert this script into the Script Editor (F11) in a new slot, somewhere
#   below galv's Region Effects script but still above Main.
#==============================================================================

#==============================================================================
# ** Spriteset_Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - gre_refresh_event
#==============================================================================

class Spriteset_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Refresh Event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def gre_refresh_event(id)
    # Find any existing event with the same ID
    esi = @character_sprites.find_index {|sprite| sprite &&
      sprite.is_a?(Sprite_Character) && sprite.character.is_a?(Game_Event) &&
      sprite.character.gre_event_id == id }
    if esi
      # Dispose Existing Event
      @character_sprites[esi].dispose if !@character_sprites[esi].disposed?
      @character_sprites.delete_at(esi)
    else
      esi = $game_map.events.values.size - 1
    end
    # Refresh new region event
    @character_sprites.insert(esi, Sprite_Character.new(@viewport1, $game_map.events[id]))
  end
end

#==============================================================================
# ** Game_Event
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - gre_event_id
#==============================================================================

class Game_Event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Event ID
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def gre_event_id
    @id # Get Event ID
  end
end

#==============================================================================
# ** Game_Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    overwritten method - region_effect
#==============================================================================

class Game_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Region Effect
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def region_event(dx, dy, event_id, map_id)
    # Retrieve event from the spawn map
    map_id = @map_id if map_id == 0
    event = generated_region_event($data_spawn_map, event_id)
    # Generate ID
    new_id = @effect_var.length < Region_Effects::MAX_EFFECTS ?
      (@events.keys.max.nil? ? 1 : @events.keys.max + 1) : @effect_var.shift
    @effect_var.push(new_id)
    # Create new Event
    @events[new_id] = Game_Event.new(@map_id, event)
    @events[new_id].moveto(dx, dy)
    SceneManager.scene.spriteset.gre_refresh_event(new_id) # Refresh Event
  end
end


Place it below galv's script but still above Main.

Thanks MA, your patch fixed 2 of my problems that I was having with the region effects script! Including the one effecting hover alerts.  :ghost: :dino: :discosect:

modern algebra

You're welcome! What was the other problem you were having?

Yin

I was using a smooth scrolling script but it would also jump the screen when walking on a region effect, just like with hover alerts. I removed it because it destroyed my eyes to see my game jumping like that lol, but decided to retry it again with the patch and now it works fine!

modern algebra


Teko

When the hover is on auto (first comment on page), there is no way to show the picture above other event? (or the char on my case).

I'd like to use this scrip to show an exclamation over the char evertime he passes near a chest, box with an item or to show a picture to press A when he passes near a button. That was the only scrip I found that is close to this.

modern algebra

I received the following private message:

Quote from: REDACTED date=1399252209
Hello, I am using your code for Hover Alerts, and at one point in my game, the player has to talk to a guard before he can pass through a gate. The guard charges him 500 gold to unlock the gate.  Once that happens, the "-500 gold" comes over the players head as an alert then the game crashes.  The error is:  Script 'Hover Alerts' line 265: NoMethodError occurred. undefined method 'empty?' for nil:NilClass

I tried turning off this kind of hover alert, but when i set the auto gain value to 0, it doesn't get turned off.
If you can solve my predicament, then you will have my thanks!

I responded:

Quote from: modern algebra date=1399258812
In the future, please report errors in the script topic itself. That way, other people could potentially step in when I'm away or too busy to help. As well, it is helpful for other users of the script, since the chances are good that you aren't the only person who has received this error.

Anyway, it's likely an incompatibility of some sort, in the sense that another script has changed the order in which certain methods could be predicted to run. It might be fixable simply by changing the position of this script in the editor.

However, it could also probably be fixed by replacing line 265, which should currently be this:


      @hover_alert = @hover_alert_queue.empty? ? nil : @hover_alert_queue.shift


with this:


      @hover_alert = (@hover_alert_queue.nil? || @hover_alert_queue.empty?) ? nil : @hover_alert_queue.shift


hen1

Hey, I pasted the script into the script editor and made sure everything is right, the only problem is I dont know how to use the script, is there a button for the hover alerts or do I insert emotions like [:)] ???
Unfortunately it doesn't say on this thread so... any help would be good.  :pacman:

modern algebra

Hi hen1, I am not great at explaining how to use my script, but I put the instructions for it in the header of the script from lines 21-142. There are also instructions relating to configuration from lines 158-196.

If you have any specific questions after reading that, then I can try to clarify. However, I am not sure I could do much better a job simply trying to explain it in general than I did in the script itself.

Kiyoshi

Script 'Hover Alerts' line 751: NoMethodError occurred.
undefined method 'hover_alert' for #<Game_Enemy:0x8d1a760>


There is no chance to get this compatible with GTBS, is it?

Yin

#65
Hi again MA. I was wondering if there was a way to add code into the Hover alert comment call (or if there is a way to call an alert to auto display through script call, that would be even better). I tried to add a conditional for a popup that automatically shows. But it conflicts with the "has to be the first command" rule. Instead of having 2 different pages that do the exact same thing except for the initial hover display, I was wondering it I could add some code to check if something is true or not.
Maybe an eval or condition argument that can change the "name" argument?


I just activated it from a different event. That works out fine.

modern algebra

Glad to hear it. Sorry that I didn't respond right away. I moved a couple weeks ago and only got my internet today.

parafusion

I could be wrong but I think the :fade_bounce function is not working properly. Right now, it is working exactly like the :fade function.

      when :bounce then @effect_y += (@effect_time > 16 ? -0.5 : 0.5)
      when :fade_bounce then self.opacity += (@effect_time > 16 ? -8 : 8)   
      # Temporary Effects
      when :fade then self.opacity = 16*@effect_time if @effect_time < 16
      when :rise_and_fade


The original script doesn't seem to be telling the script to run the bouncing function. I added the bouncing function manually and it seems to be working now.

      when :bounce then @effect_y += (@effect_time > 16 ? -0.5 : 0.5)
      when :fade_bounce then self.opacity += (@effect_time > 16 ? -8 : 8)
        @effect_y += (@effect_time > 16 ? -0.5 : 0.5)
     
      # Temporary Effects
      when :fade then self.opacity = 16*@effect_time if @effect_time < 16
      when :rise_and_fade


With that being said, I have 0 experience in coding and I don't really know if it was some other things interfering with the script. Sorry if I am wrong  ;)

modern algebra

Sorry, I can see how that would be confusing. By :fade_bounce, I didn't mean that it would fade and bounce, just that it would start fully transparent, fade in then fade out. Whereas :fade starts out at fully opaque and just fades out. But certainly, if you're looking for it to fade and bounce then your code seems like it would work.

parafusion

Ohhh, okay. Sorry, my mistake.  :( I always seem to jump the gun like that...


modern algebra

Not at all. I'm glad you raised it with me and took the initiative to try and find a solution.

Chaos17

Quote from: Yin on October 17, 2012, 03:02:21 AM
Another nice script MA. Would this be able to be used with a proximity effect? Like if you are 2 tiles away then it will fade in and any further than that, it will fade back out? Or if you are one tile away, it will only show if you are facing the direction of the event?

That's too bad, I was looking for an option like this with this script.
Anyway, good jon on this script.

8)

modern algebra

Quote from: Chaos17 on September 15, 2014, 10:20:26 AM
Quote from: Yin on October 17, 2012, 03:02:21 AM
Another nice script MA. Would this be able to be used with a proximity effect? Like if you are 2 tiles away then it will fade in and any further than that, it will fade back out? Or if you are one tile away, it will only show if you are facing the direction of the event?

That's too bad, I was looking for an option like this with this script.
Anyway, good jon on this script.

8)

Why is that too bad? That feature was added to this script shortly after Yin requested it.

Markal Games

Quote from: The Frontera on December 15, 2012, 03:16:18 PM
Epic script Modern Algebra!
I have a suggestion for a thing I need for my project...
I noticed that if the graphic of the event is set to none, the icon is shown in place of the event [1]
If there's graphic, the icon is shown over the event. [2]
Is there a way to be able to show the icon ON the event even if set the graphic? (like in [1], but this time there's graphic exactly below it)
Thanks in advance

I've been thoroughly enjoying this script, but I second a need for this feature if at all possible!  Any way you could implement it?

Kyuukon

Very useful script :D!

I have a little problem: I tried changing the z value of the hover graphic in the line 472,
self.z = 500
but for some reason it won't go up from 200 (contrary to the Fix Pictures script). Is there a way to go over that, to let's say 500?
Also, is it possible to align to left a hover text?

Not critical problems but I'd love to know :3 Thanks!

やれやれだぜ。