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.
[SOLVED]Woratana Mouse Highlight Add-On

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 85
I am the wood of my broom
2010 Project of the YearProject of the Month winner for January 2009Project of the Month winner for January 2010Project of the Month winner for April 2010
Woratana Mouse Script Addon?
3/21/2011



Summary
I would like to request if someone could please make an add-on for woratana's mouse script that could make an event react just by highlighting it (no clicking).

If the event has the comment [mreact] and the mouse was hovered above it, it will turn on a switch automatically and if the mouse hovered past it, the switch will get turned off. Please make it able to turn on many switches for each event. Maybe the switch turned on is based on the event number?

Features Desired
  • Event turns on a switch if the event has [mreact] as a comment.
  • Switch number is based on the event number

Games its been in
  • Just hover your mouse in any of the desktop icons. You'll notice there's going to be a box/whatever that's going to pop up. That's what I kinda wanted to do <:3c

What other scripts are you using?
  • Woratana Mouse Script
Code: [Select]
#==============================================================================
# [VX] SMS - Simple Mouse System
#------------------------------------------------------------------------------
# ? by Woratana [woratana@hotmail.com]
# ? Released on: 14/04/2008 (D-M-Y)
# ? Version: 1.5
#
# ? Credit: DerVVulfman, Near Fantastica, and Freak Boy [Mouse Input Module]
# lambchop, shun, Cybersam, Astro_mech, and Mr.Mo [Super Simple Mouse System]
# - Modern Algebra, Zeriab, Patrick Lester [Path Finding]
# - Near Fantastica, Fuso [Path Finding]
#
# - I will not be able to script this without those people and scripts above
#-----------------------------------------------------------------------------
#====[REQUIRE]=====
# - DerVVulfman's Mouse Input Module
# - Modern Algebra's Path Finding [version 2.0]
#
#====[FEATURE]=====
# - Support to use mouse in many scenes / windows
# - Mouse Pointer
# - Click on map to move player with Path Finding
# - Click on event to go talk/interact with that event
# - Click on event to walk to that event
# - You can choose scene(s) that don't want to use mouse
# - You can turn mouse ON/OFF automatically by call script:
# $scene.no_mouse = (true/false) # True to turn off mouse

#====[MOUSE TAGS]=====
# Put one (or more) of these tags in the event command 'Comment..'
# [mauto] : This event will run automatically after click on it
# [mnone] : This event will not be determine as event when click on it
# (a.k.a. Player will not interact with it)

# [mtop] : Player will always stop at tile above this event when click on it
# [mleft] : Same as [mtop], but left side
# [mright] : Same as [mtop], but right side
# [mdown] : Same as [mtop], but below
#------------------------------------------------------------------------------

module Mouse
#==============================================================================
# MOUSE SETUP PART
#----------------------------------------------------------------------------
Scroll_Delay = 30 # (in Frames)
# Mouse Delay when scroll up or down the list

Path_Finding_Iteration = 0 # (Integer, 0 for no limit)
# How deep you want path finding to process until find the way
# less number will be able to find only easy path, less lag
# high number will be able to find complicated path, possible to increase lag

Scene_No_Mouse = []
# Scene(s) that you don't want to use mouse
# e.g. Scene_No_Mouse = [Scene_File, Scene_Map, Scene_Title]

Auto_Find_Destination = true
# It will automatically find the cloeset destination on map
# when click on unpassable tile.
#==============================================================================
end

#==============================================================================
# ** Mouse Input Module
#==============================================================================
class << Mouse
  show_cursor = Win32API.new('user32', 'ShowCursor', 'l', 'l')
  show_cursor.call(0)

  $mousec = Sprite.new
  $mousec.z = 10001
  $mousec.x = $mousec.y = 1000
  $mouse_icon = $base_cursor = 'arrow'
  $mousec.bitmap = Cache.system($base_cursor)
  $mouse_duration = -1
  $mouse_changed = false
 
  alias wor_mouse_upd_mouse update unless $@
  def Mouse.update
    wor_mouse_upd_mouse
    if $scene.no_mouse
      $mousec.visible = false if $mousec.visible
      return
    else; $mousec.visible = true if !$mousec.visible
    end
    if $mouse_old_icon.nil? or $mouse_old_icon != $mouse_icon
      $mouse_old_icon = $mouse_icon
      $mousec.bitmap = Cache.system($mouse_old_icon)
    end
    if @pos.nil?
      $mousec.x = 1000 if $mousec.x != 1000
      $mousec.y = 1000 if $mousec.y != 1000
    else
      $mousec.x = @pos[0] if $mousec.x != @pos[0]
      $mousec.y = @pos[1] if $mousec.y != @pos[1]
    end
  end
 
  def Mouse.map_pos
    return nil if @pos == nil
    x = ($game_map.display_x / 256) + (@pos[0] / 32)
    y = ($game_map.display_y / 256) + (@pos[1] / 32)
    return [x, y]
  end
end

#==============================================================================
# ** Input
#==============================================================================
class << Input
  alias wor_input_upd_mouse update unless $@
  alias wor_input_trig_mouse trigger? unless $@
  alias wor_input_rep_mouse repeat? unless $@
  def Input.update
    wor_input_upd_mouse
    Mouse.update
  end
 
  def Input.trigger?(input)
    return wor_input_trig_mouse(input) if Mouse.pos.nil?
    if input == Input::B and !$scene.no_mouse
      return (wor_input_trig_mouse(input) or Mouse.click?(2))
    elsif input == Input::C and !$scene.no_mouse
      if $scene.is_a?(Scene_Map) and !$game_message.visible
        return wor_input_trig_mouse(input)
      else
        return (wor_input_trig_mouse(input) or Mouse.click?(1))
      end
    else
      return wor_input_trig_mouse(input)
    end
  end
 
  def Input.repeat?(input)
    if input == Input::B and !$scene.no_mouse
      return (wor_input_rep_mouse(input) or Mouse.click?(2))
    else
      return wor_input_rep_mouse(input)
    end
  end
end
#==============================================================================
# ** Graphics
#==============================================================================
class << Graphics
  alias wor_graph_fadeout_mouse fadeout unless $@
  def Graphics.fadeout(frames = 1)
    $mousec.visible = false if !$mousec.nil?
    wor_graph_fadeout_mouse(frames)
  end
end
#==============================================================================
# ** Window_Selectable
#==============================================================================
class Window_Selectable < Window_Base
  alias wor_winsel_ini_mouse initialize
  alias wor_winsel_upd_mouse update
  def initialize(*args)
    wor_winsel_ini_mouse(*args)
    @scroll_wait = 0
    @cursor_wait = 0
  end

  def update
    wor_winsel_upd_mouse
    update_mouse if self.active and self.visible
  end
 
  def update_mouse
    @cursor_wait -= 1 if @cursor_wait > 0
    (0..@item_max - 1).each do |i|
      irect = item_rect(i)
      irx = self.x + 16 + irect.x - self.ox
      iry = self.y + 16 + irect.y - self.oy
      move_cursor(i) if Mouse.area?(irx, iry, irect.width, irect.height)
    end
  end

  def move_cursor(index)
    return if @index == index
    @scroll_wait -= 1 if @scroll_wait > 0
    row1 = @index / @column_max
    row2 = index / @column_max
    bottom = self.top_row + (self.page_row_max - 1)
    if row1 == self.top_row and row2 < self.top_row
      return if @scroll_wait > 0
      @index = [@index - @column_max, 0].max
      @scroll_wait = Mouse::Scroll_Delay
    elsif row1 == bottom and row2 > bottom
      return if @scroll_wait > 0
      @index = [@index + @column_max, @item_max - 1].min
      @scroll_wait = Mouse::Scroll_Delay
    else
      @index = index
    end
    return if @cursor_wait > 0
    Sound.play_cursor
    @cursor_wait += 2
  end
end
#==============================================================================
# ** Window_MenuStatus
#==============================================================================
class Window_MenuStatus < Window_Selectable
  def item_rect(index)
    return Rect.new(0, index * 96, contents.width, 96)
  end
end
#==============================================================================
# ** Window_NameInput
#==============================================================================
class Window_NameInput < Window_Base
  alias wor_winnam_upd_mouse update
  def update
    wor_winnam_upd_mouse
    if self.active and self.visible
      (0..TABLE[@mode].size - 1).each do |i|
      irect = item_rect(i)
      irx = self.x + 16 + irect.x - self.ox
      iry = self.y + 16 + irect.y - self.oy
      @index = i if Mouse.area?(irx, iry, irect.width, irect.height)
      end
    end
  end
end
#==============================================================================
# ** Window_PartyCommand
#==============================================================================
class Window_PartyCommand < Window_Command
  def update_mouse
    (0..@item_max - 1).each do |i|
    irect = item_rect(i)
    irx = self.viewport.ox + 16 + irect.x - self.ox
    iry = 288 + 16 + irect.y - self.oy
    self.index = i if Mouse.area?(irx, iry, irect.width, irect.height)
    end
  end
end
#==============================================================================
# ** Window_ActorCommand
#==============================================================================
class Window_ActorCommand < Window_Command
  def update_mouse
    (0..@item_max - 1).each do |i|
    irect = item_rect(i)
    irx = self.viewport.ox + 288 + 16 + irect.x
    iry = 288 + 16 + irect.y
    self.index = i if Mouse.area?(irx, iry, irect.width, irect.height)
    end
  end
end
#==============================================================================
# ** Window_Message
#==============================================================================
class Window_Message < Window_Selectable
  def update_mouse
    (0..@item_max - 1).each do |i|
      irect = item_rect(i)
      irx = self.x + 16 + irect.x - self.ox
      iry = self.y + 16 + irect.y - self.oy + ($game_message.choice_start * WLH)
      self.index = i if Mouse.area?(irx, iry, irect.width, irect.height)
    end
  end
end

#==============================================================================
# ** Scene_Base
#==============================================================================
class Scene_Base
  alias wor_scebase_posstr_mouse post_start
  alias wor_scebase_preter_mouse pre_terminate
  attr_accessor :no_mouse
 
  def post_start
    if !$mousec.nil?
      $mousec.visible = true
      @no_mouse = false
      # If this scene is in Scene_No_Mouse
      Mouse::Scene_No_Mouse.each do |sce|
        if $scene.is_a?(sce)
          $mousec.visible = false
          @no_mouse = true
        end
      end
    end
    wor_scebase_posstr_mouse
  end
 
  def pre_terminate
    $mousec.visible = false if !$mousec.nil?
    wor_scebase_preter_mouse
  end
end
#==============================================================================
# ** Scene_File
#==============================================================================
class Scene_File < Scene_Base
  alias wor_scefil_upd_mouse update
  def update
    (0..@item_max - 1).each do |i|
      ix = @savefile_windows[i].x
      iy = @savefile_windows[i].y
      iw = @savefile_windows[i].width
      ih = @savefile_windows[i].height
      if Mouse.area?(ix, iy, iw, ih)
        @savefile_windows[@index].selected = false
        @savefile_windows[i].selected = true
        @index = i
      end
    end
    wor_scefil_upd_mouse
  end
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map < Scene_Base
  alias wor_scemap_upd_mouse update
 
  def update
    wor_scemap_upd_mouse
    if !@no_mouse
      # IF left click
      if Mouse.click?(1) and !$game_message.visible and
        !$game_map.interpreter.running?
        mouse_xy = Mouse.map_pos
        return if mouse_xy.nil?
        old_direction = $game_player.direction
        $game_player.turn_toward_pos(mouse_xy[0], mouse_xy[1])
        # IF click near player, and there's trigger to event, run event
        return if ($game_player.front?(mouse_xy[0],mouse_xy[1]) and
      $game_player.check_action_event)
        $game_player.clear_path
        $game_player.mouse_force_path(mouse_xy[0], mouse_xy[1])
      # IF middle click
      elsif Mouse.click?(3) and !$game_message.visible and
        !$game_map.interpreter.running?
        mouse_xy = Mouse.map_pos
        return if mouse_xy.nil?
        $game_player.clear_path
        $game_player.turn_toward_pos(mouse_xy[0], mouse_xy[1])
      end
    end
  end
end
#==============================================================================
# ** Game_Character
#==============================================================================
class Game_Character
  def mouse_force_path(x, y, auto_check = ($game_map.events_xy(x, y).size > 0))
    ori_x, ori_y = x, y
    path_xy = $game_map.find_dest_xy(x, y, @x, @y)
    return if path_xy.nil?
    x, y = path_xy[0] ,path_xy[1]
    # Force_move from MA's path finding
    if map_passable?(x,y)
      path = $game_map.find_path (self.x, self.y, x, y, false,
      Mouse::Path_Finding_Iteration, self)
      path.reverse!
      # Turn toward destination
      newmove = RPG::MoveCommand.new
      newmove.code = 45 # Script..
      newmove.parameters = ["turn_toward_pos(#{ori_x},#{ori_y})"]
      path.push newmove
      # Add script to check if there's event trigger
      if auto_check
        newmove = RPG::MoveCommand.new
        newmove.code = 45
        newmove.parameters = ['check_action_event']
        path.push newmove
      end
      # Add an end command
      path.push (RPG::MoveCommand.new (0))
      move_route = RPG::MoveRoute.new
      move_route.list = path
      move_route.repeat = false
      force_move_route (move_route)
    end
  end
 
  def clear_path
    @move_route_index = 0
    @move_route = RPG::MoveRoute.new
    @move_route.repeat = false
  end

  def turn_toward_pos(x,y)
    sx = distance_x_from_pos(x)
    sy = distance_y_from_pos(y)
    if sx.abs > sy.abs                    # Horizontal distance is longer
      sx > 0 ? turn_left : turn_right
    elsif sx.abs < sy.abs                 # Vertical distance is longer
      sy > 0 ? turn_up : turn_down
    end
  end

  def distance_x_from_pos(x)
    sx = @x - x
    if $game_map.loop_horizontal?
      if sx.abs > $game_map.width / 2
        sx -= $game_map.width
      end
    end
    return sx
  end
 
  def distance_y_from_pos(y)
    sy = @y - y
    if $game_map.loop_vertical?
      if sy.abs > $game_map.height / 2
        sy -= $game_map.height
      end
    end
    return sy
  end
 
  def front?(x,y)
    case @direction
    when 2; return true if (x == @x-1 and y == @y)
    when 4; return true if (x == @x and y == @y-1)
    when 6; return true if (x == @x and y == @y+1)
    when 8; return true if (x == @x+1 and y == @y)
    end
    return false
  end
end
#==============================================================================
# ** Game_Map
#==============================================================================
class Game_Map
  # Find Destination for Path Finding
  def find_dest_xy(x, y, self_x, self_y)
    has_event = false
    event_ary = events_xy(x, y)
    # Remove Event that has 'mnone'
    (event_ary).each do |i|
      return if i.is_a?(Game_Player)
      event_ary.delete(i) if i.comment?('[mnone]')
    end
    # Return original x, y if there are more than 1 events,
    # or the only event has priority type 'Below Character'
    if (event_ary.size == 1 and event_ary[0].priority_type != 1) or
    event_ary.size > 1
      return [x, y]
    elsif event_ary.size == 1
      # IF there's event, check for reserved direction
      has_event = true
      return if event_ary[0].is_a?(Game_Player)
      if event_ary[0].comment?('[mtop]')
        return [x, y-1]
      elsif event_ary[0].comment?('[mleft]')
        return [x-1, y]
      elsif event_ary[0].comment?('[mright]')
        return [x+1, y]
      elsif event_ary[0].comment?('[mdown]')
        return [x, y+1]
      elsif event_ary[0].comment?('[mauto]')
        event_ary[0].start
        return nil
      end
    end
    # Check for passable direction or it's Same X/Y or doesn't allow auto-find
    if (event_ary.size != 1 and $game_player.map_passable?(x, y)) or (self_x == x and self_y == y) or
  (!Mouse::Auto_Find_Destination and !has_event)
      return [x, y]
    end
    # Find nearest path
    nx = (self_x - x)
    ny = (self_y - y)
    npath_real = []
    if (nx.abs < ny.abs and nx != 0) or (ny == 0) # X is closer than Y
      npath_real << (nx > 0 ? 'right' : 'left')
    else # EQUAL, or Y is closer than X
      npath_real << (ny > 0 ? 'up' : 'down')
    end
    npath_real_tran = move_translate(npath_real, x, y) # Translate word to value
    # If the fastest way is possible, return it
    if $game_player.map_passable?(npath_real_tran[0][0], npath_real_tran[0][1])
      return [npath_real_tran[0][0], npath_real_tran[0][1]]
    end
    npath = []
    # Add other possible ways
    npath << 'up' if !npath_real.include?('up')
    npath << 'left' if !npath_real.include?('left')
    npath << 'down' if !npath_real.include?('down')
    npath << 'right' if !npath_real.include?('right')
    npath = move_translate(npath, x, y) # Translate other possible ways
    (0..npath.size-1).each do |np| # Calculate distance from each point
      npath[np] =
      [npath[np], (self_x - npath[np][0]).abs + (self_y - npath[np][1]).abs]
    end
    npath = npath.sort_by {|i| i[1]} # Sort by Distance
    # Check to move~
    npath.each do |n|
      return [n[0][0], n[0][1]] if $game_player.map_passable?(n[0][0], n[0][1])
    end
    # IF there's no way to go
    return nil
  end
 
  def move_translate(ary, x, y)
    (0..ary.size - 1).each do |n|
      if ary[n] == 'up'
        ary[n] = [x, y-1]
      elsif ary[n] == 'left'
        ary[n] = [x-1, y]
      elsif ary[n] == 'right'
        ary[n] = [x+1, y]
      elsif ary[n] == 'down'
        ary[n] = [x, y+1]
      end
    end
    return ary
  end
end
#==============================================================================
# ** Game_Event
#==============================================================================
class Game_Event < Game_Character
  def comment?(comment, return_index = false )
    if !@list.nil?
      for i in 0...@list.size - 1
        next if @list[i].code != 108
        (0..@list[i].parameters.size - 1).each do |j|
          if @list[i].parameters[j].include?(comment)
            return [true, [i,j]] if return_index
            return true
          end
        end
      end
    end
    return [false, nil] if return_index
    return false
  end
end



Did you search?
Yes. But they're scripter-related stuff.
« Last Edit: September 02, 2011, 11:30:05 AM by Nessiah »


*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Code: [Select]
#==============================================================================
# ** Game_Event
#==============================================================================

class Game_Event < Game_Character
 
  def comment?(comment, return_index = false )
    if !@list.nil?
      for i in 0...@list.size - 1
        next if @list[i].code != 108 and @list[i].code != 408
        (0..@list[i].parameters.size - 1).each do |j|
          if @list[i].parameters[j].include?(comment)
            return [true, [i,j]] if return_index
            return true
          end
        end
      end
    end
    return [false, nil] if return_index
    return false
  end
 
  alias coz_nessy_mreact_ge_update update
  def update
    coz_nessy_mreact_ge_update
    if comment?('[mreact]')
      key = [$game_map.map_id, @id, "D"]
      trigger = (Mouse.map_pos[0] == @x and Mouse.map_pos[1] == y) rescue false
      $game_self_switches[key] = trigger
      refresh
    end
  end
 
end

Hey Nessy

*
Rep:
Level 85
I am the wood of my broom
2010 Project of the YearProject of the Month winner for January 2009Project of the Month winner for January 2010Project of the Month winner for April 2010
Aww thank you cozziekuns <3 I really appreciate it!


*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Forgot to mention, it turns the self switch D of the event on when the mouse is hovering over. Use the [mreact] tag.

*
Rep:
Level 85
I am the wood of my broom
2010 Project of the YearProject of the Month winner for January 2009Project of the Month winner for January 2010Project of the Month winner for April 2010
Thanks! It's working very nicely :D