Comments and Events

Lionheart123

Veteran
Veteran
Joined
Dec 14, 2019
Messages
44
Reaction score
1
First Language
English
Primarily Uses
RMVXA

Kes

Global Moderators
Global Mod
Joined
Aug 3, 2012
Messages
21,472
Reaction score
10,869
First Language
English
Primarily Uses
RMVXA
'Scripts' is where people who have written a completed script they want to share with others can post it.

I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,649
Reaction score
5,296
First Language
Indonesian
Primarily Uses
RMVXA
Hey there! you're using a kinda outdated version that script and it's going to hurt your game performance. I made a fix to incorporate both the lag issue and yours. See if it works, so I can safely update my github repository.
Code:
# =============================================================================
# TheoAllen - Interact Hover Notification
# Version : 1.1c
# Contact : Discord @ Theo#3034
# Translation: Davi Felipe (http://www.mundorpgmaker.com.br)
# =============================================================================
($imported ||= {})[:Theo_InteractNotif] = true
# =============================================================================
# CHANGE LOGS:
# -----------------------------------------------------------------------------
# 2020.01.05 - Attempt to make sure the notif is displayed
# 2019.01.15 - Performance optimization. Making it less lag
# 2013.08.21 - Bugfix when changing map
# 2013.08.04 - Bugfix at Event Page Condition
# 2013.07.24 - Finished script
# =============================================================================
=begin

  Introduction :
  This script display a hovering notification on events
 
  How to use :
  Put this script below Materials but above Main
  Use the comment <interact: interaction name> in the event
 
  Terms of Use :
  Credit me, TheoAllen. You are free to edit this script by your own. As long
  as you don't claim it yours. For commercial purpose, don't forget to give me
  a free copy of the game.

=end
# =============================================================================
# Configuration :
# =============================================================================
module THEO
  module Interact
  
    # Speed of the fade in / fade out on the notification
    FadeSpeed = 20
  
    # The bigger the value, the higher the notification will be above the event
    Displacement = 0
  
    # Maximum width
    Width  = 300
  
    # Font settings
    FontName = ["Calibri"]
    FontSize = 18
    FontBold = true
    FontItalic = false
  
  end
end
#==============================================================================
# End of configuration
#==============================================================================
class Game_Event < Game_Character
  attr_writer :hover_notif
  def hover_notif
    return @hover_notif if @hover_notif
    setup_hover_notif
    return @hover_notif
  end
 
  alias theo_ihn_page_setting setup_page_settings
  def setup_page_settings
    theo_ihn_page_setting
    setup_hover_notif
  end
 
  def setup_hover_notif
    @hover_notif = ""
    @list.each do |command|
      next unless command.code == 108 || command.code == 408
      case command.parameters[0]
      when /<interact\s*:\s*(.*)>/i
        @hover_notif = $1.to_s
      end
    end
  end
 
  def list_is_empty?
    list.all? do |command|
      command.code == 0 ||
      command.code == 108 ||
      command.code == 408 ||
      command.code == 118
    end
  end
 
  def trigger_is_possible?
    return false if list_is_empty?
    return false if trigger != 0
    return true
  end
 
  def meet_with_player?
    return in_front_of_player? if normal_priority?
    return below_or_above_player?
  end
 
  def in_front_of_player?
    self.x == $game_player.front_x && self.y == $game_player.front_y
  end
 
  def below_or_above_player?
    self.x == $game_player.x && self.y == $game_player.y
  end
 
  def showing_hover_notif?
    return false unless @hover_notif
    return false if @hover_notif.empty?
    return false if @erased
    return false if $game_map.interpreter.running?
    return trigger_is_possible? && meet_with_player?
  end
 
end

class Game_Player < Game_Character
 
  def front_x
    $game_map.round_x_with_direction(@x,@direction)
  end
 
  def front_y
    $game_map.round_y_with_direction(@y,@direction)
  end
 
end

class Window_InteractNotif < Window_Base
  attr_reader :event
  include THEO::Interact
 
  def initialize(event)
    super(0,0,Width,fitting_height(1))
    self.opacity = 0
    self.contents_opacity = 0
    @event = event
    setup_font
    update_placement
    refresh
  end
 
  def setup_font
    font = contents.font
    font.size = FontSize
    font.name = FontName
    font.bold = FontBold
    font.italic = FontItalic
  end
 
  def refresh
    contents.clear
    @text = @event.hover_notif
    draw_text(contents.rect,@text,1)
  end
 
  def update
    super
    update_placement
    update_opacity
    refresh if need_refresh?
  end
 
  def update_placement
    self.x = @event.screen_x - self.width/2
    self.y = @event.screen_y - self.height - Displacement
  end
 
  def update_opacity
    if @event.showing_hover_notif?
      update_fadein
    else
      update_fadeout
    end   
  end
 
  def need_refresh?
    @text != @event.hover_notif
  end
 
  def line_height
    FontSize
  end
 
  def fade_speed
    return FadeSpeed
  end
 
  def update_fadein
    self.contents_opacity += fade_speed
  end
 
  def update_fadeout
    self.contents_opacity -= fade_speed
  end
 
end

class Sprite_Character
 
  alias aed_interact_update update
  def update
    aed_interact_update
    update_interact_notif
  end
 
  def update_interact_notif
    return unless @character.is_a?(Game_Event)
    text = @character.hover_notif || ""
    if text.empty?
      @interact.dispose if @interact && !@interact.disposed?
    else
      if !@interact || @interact.disposed?
        @interact = Window_InteractNotif.new(@character)
        @interact.update
      else
        @interact.update
      end
    end
  end
 
  alias aed_dispose_interact dispose
  def dispose
    aed_dispose_interact
    @interact.dispose if @interact && !@interact.disposed?
  end
 
end
 

Lionheart123

Veteran
Veteran
Joined
Dec 14, 2019
Messages
44
Reaction score
1
First Language
English
Primarily Uses
RMVXA
Sorry for the late reply!

I've tried the script, but everything seems to be working the same way as it did with the other one...
Also, the hover for the cloned events still did not appear....
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,649
Reaction score
5,296
First Language
Indonesian
Primarily Uses
RMVXA
Then can you make a test project to put two scripts together and put it here so I can take a look?
 

Lionheart123

Veteran
Veteran
Joined
Dec 14, 2019
Messages
44
Reaction score
1
First Language
English
Primarily Uses
RMVXA
Oops! Haha. I finally made it work.

The original problem of my event is that the cloned event overwrites all other stuff in the event section, so all I'll have to do is put the command in the base event that was to be cloned.

Sorry for wasting your time.... :p
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I feel like it's about time I share all the result of my experiment project here. But there's a lot of it.
Me and brother have an ongoing rivalry. We constantly fight for the High Score in Galaga on our arcade cabinet. Today I take back the top with 239,000. He'll be back. (No-Fire glitch is banned)
Made Custom ENEMY Information Screen
I'm having such a hard time thinking of an interesting battle system. and not being a coder, certain things I wanna do seem a lot harder lol.
Created a character outline with some code. I have no use for this. I'm....bored.....

Forum statistics

Threads
93,722
Messages
914,926
Members
123,325
Latest member
ayumi009
Top