03-05-2008, 07:15 AM (This post was last modified: 10-14-2010, 04:21 AM by DerVVulfman.)
MOUSIE The Mouse System
Version: 3.1
Introduction
With this, you can use Near Fantastica's 'Pathfinding' script to move the character around with the mouse's point-n-click interface. Or you can use it to control menu window functions with some simple edits. Heck, you can even set the system to change the mouse cursor over pre-defined map events.
Features
Move your character with a point-n-click interface (Pathfinding required)
Control the menu with the mouse (Edits to the menu required... sample supplied)
Cursors change over pre-defined map events
True Double-click capability
True Mouse Continuous Pressing capacity
Mouse Press compatibility with Cybersam's Full Keyboard script
Map event clicking for sim-like games
Screenshots
Nah... just shows a mouse cursor over the screen... though the cursor can change over some events.
Instructions
Very little needs to be configured... adding mouse icons into the system, setting a few clicking parameters, pathfinding range. All of which are covered in the script.
To use this with Near Fantastica's pathfinding system, the pathfinding system must be placed ABOVE this system. This system supports both versions 1 and 2 of Pathfinding. It can work with both Pathfinding systems in your project, but this system will work with version 1 (for speed preferences) rather than version 2.
It does not need 'Pathfinding' to operate. However, the character will not move without one.
Any edits to the menu system should be placed BELOW this system, such as the edits by Lambchop below.
Edits
Below, you can see how this system can be used to manipulate the default menu system. The supplied code was created by Lambchop to control nearly every facet of the menu interface by mouse input.
#==============================================================================
# ** Window_Selectable
#------------------------------------------------------------------------------
# This window class contains cursor movement and scroll functions.
#==============================================================================
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# * Initialize the mouse
#--------------------------------------------------------------------------
alias mouse_initialize initialize
def initialize(x, y, width, height)
mouse_initialize(x, y, width, height)
@scroll_wait = 0
end
#--------------------------------------------------------------------------
# * Update the mouse
#--------------------------------------------------------------------------
alias mouse_update update
def update
mouse_update
mouse_operation if self.active
end
#--------------------------------------------------------------------------
# * Perform mouse operations
#--------------------------------------------------------------------------
def mouse_operation
mx = Mouse.pos_x - (self.x - self.ox + 16)
my = Mouse.pos_y - (self.y - self.oy + 16)
width = self.width / @column_max - 32
height = 32
for index in 0...@item_max
x = index % @column_max * (width + 32)
y = index / @column_max * 32
if mx > x and
mx < x + width and
my > y and
my < y + height
mouse_cursor(index)
break
end
end
end
#--------------------------------------------------------------------------
# * Track the position of the mouse cursor
#--------------------------------------------------------------------------
def mouse_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 = 4
elsif row1 == bottom and row2 > bottom
return if @scroll_wait > 0
@index = [@index + @column_max, @item_max - 1].min
@scroll_wait = 4
else
@index = index
end
$game_system.se_play($data_system.cursor_se)
end
end
#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
# This window displays party member status on the menu screen.
#==============================================================================
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Perform mouse operations
#--------------------------------------------------------------------------
def mouse_operation
return if @index < 0
mx = Mouse.pos_x - (self.x - self.ox + 16)
my = Mouse.pos_y - (self.y - self.oy + 16)
x = 0
width = self.width - 32
height = 96
for index in 0...@item_max
y = index * 116
if mx > x and
mx < x + width and
my > y and
my < y + height
mouse_cursor(index)
break
end
end
end
end
#==============================================================================
# ** Window_Target
#------------------------------------------------------------------------------
# This window selects a use target for the actor on item and skill screens.
#==============================================================================
class Window_Target < Window_Selectable
#--------------------------------------------------------------------------
# * Perform mouse operations
#--------------------------------------------------------------------------
def mouse_operation
return if @index <= -1
mx = Mouse.pos_x - (self.x - self.ox + 16)
my = Mouse.pos_y - (self.y - self.oy + 16)
x = 0
width = self.width - 32
height = 96
for index in 0...@item_max
y = index * 116
if mx > x and
mx < x + width and
my > y and
my < y + height
mouse_cursor(index)
break
end
end
end
end
#==============================================================================
# ** Window_NameInput
#------------------------------------------------------------------------------
# This window is used to select text characters on the input name screen.
#==============================================================================
class Window_NameInput < Window_Base
#--------------------------------------------------------------------------
# ? Update the position of the mouse
#--------------------------------------------------------------------------
alias mouse_update update
def update
mouse_update
mouse_operation if self.active
end
#--------------------------------------------------------------------------
# * Perform mouse operations
#--------------------------------------------------------------------------
def mouse_operation
index = @index
mx = Mouse.pos_x - (self.x - self.ox + 16)
my = Mouse.pos_y - (self.y - self.oy + 16)
width = 28
height = 32
# Exit if between Capital and non-caps
if ( Mouse.pos_x > 296 && Mouse.pos_x < 350)
return
end
# Switch mx area if going from caps to/from non-caps
if Mouse.pos_x <= 318
mx -= 136
elsif Mouse.pos_x >= 337
mx -= 166
end
for index in 0...180
x = 4 + index / 5 / 9 * 152 + index % 5 * 32
y = index / 5 % 9 * 32
if mx > x and
mx < x + width and
my > y and
my < y + height
$game_system.se_play($data_system.cursor_se) unless @index == index
@index = index
break
end
end
# Set Y condition for outside boundary check
# Value of 9 could be 8 ( 8 * 32) as Last row in CHARACTER_TABLE empty.
y = 9 * 32
# Outside test
outside = false
outside = true if mx < 4
outside = true if mx > 312
outside = true if my < 4
outside = true if my > y
# Go to 'OK' if outside character window
if outside
$game_system.se_play($data_system.cursor_se) unless @index == 180
@index = 180
end
end
end
#==============================================================================
# ** Window_Message
#------------------------------------------------------------------------------
# This message window is used to display text.
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# * Perform mouse operations
#--------------------------------------------------------------------------
def mouse_operation
mx = Mouse.pos_x - (self.x - self.ox + 16)
my = Mouse.pos_y - (self.y - self.oy + 16)
x = 8
width = 128
height = 32
for index in 0...@item_max
y = ($game_temp.choice_start + index) * 32
if mx > x and mx < x + width and my > y and my < y + height
mouse_cursor(index)
break
end
end
end
end
#==============================================================================
# ** Window_PartyCommand
#------------------------------------------------------------------------------
# This window is used to select whether to fight or escape on the battle
# screen.
#==============================================================================
class Window_PartyCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Perform mouse operations
#--------------------------------------------------------------------------
def mouse_operation
mx = Mouse.pos_x - (self.x - self.ox + 16)
my = Mouse.pos_y - (self.y - self.oy + 16)
y = 0
width = 128
height = 32
for index in 0...@item_max
x = 160 + index * 160
if mx > x and
mx < x + width and
my > y and
my < y + height
mouse_cursor(index)
break
end
end
end
end
#==============================================================================
# ** Window_MenuPosition
#------------------------------------------------------------------------------
# This window positions the cursor on the screen.
#==============================================================================
class Window_MenuPosition < Window_Selectable
#--------------------------------------------------------------------------
# * Perform mouse operations
#--------------------------------------------------------------------------
def mouse_operation
mx = Mouse.pos_x - (self.x - self.ox + 16)
my = Mouse.pos_y - (self.y - self.oy + 16)
y = 0
width = self.contents.width / @item_max - 10
height = 32
for index in 0...@item_max
x = self.contents.width / (@item_max) * index + 4
if mx > x and
mx < x + width and
my > y and
my < y + height
mouse_cursor(index)
break
end
end
end
end
#==============================================================================
# ** Arrow_Base
#------------------------------------------------------------------------------
# This sprite is used as an arrow cursor for the battle screen. This class
# is used as a superclass for the Arrow_Enemy and Arrow_Actor classes.
#==============================================================================
class Arrow_Base < Sprite
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias mouse_update update
def update
mouse_update
mouse_operation
end
end
#==============================================================================
# ** Arrow_Enemy
#------------------------------------------------------------------------------
# This arrow cursor is used to choose enemies. This class inherits from the
# Arrow_Base class.
#==============================================================================
class Arrow_Enemy < Arrow_Base
#--------------------------------------------------------------------------
# * Perform mouse operations
#--------------------------------------------------------------------------
def mouse_operation
mx, my = Mouse.pos
for index in 0...$game_troop.enemies.size
enemy = $game_troop.enemies[index]
bitmap = RPG::Cache.battler(enemy.battler_name, 0)
width = bitmap.width
height = bitmap.height
x = enemy.screen_x - width / 2
y = enemy.screen_y - height
if mx > x and
mx < x + width and
my > y and
my < y + height
break if @index == index
@index = index
$game_system.se_play($data_system.cursor_se)
break
end
end
end
end
#==============================================================================
# ** Arrow_Actor
#------------------------------------------------------------------------------
# This arrow cursor is used to choose an actor. This class inherits from the
# Arrow_Base class.
#==============================================================================
class Arrow_Actor < Arrow_Base
#--------------------------------------------------------------------------
# * Perform mouse operations
#--------------------------------------------------------------------------
def mouse_operation
mx, my = Mouse.pos
for index in 0...$game_party.actors.size
index = $game_party.actors.size - index - 1
actor = $game_party.actors[index]
bitmap = RPG::Cache.battler(actor.battler_name, 0)
width = bitmap.width
height = bitmap.height
x = actor.screen_x - width / 2
y = actor.screen_y - height
if mx > x and
mx < x + width and
my > y and
my < y + height
break if @index == index
@index = index
$game_system.se_play($data_system.cursor_se)
break
end
end
end
end
#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
# This is a superclass for the save screen and load screen.
#==============================================================================
class Scene_File
#--------------------------------------------------------------------------
# * Update the mouse
#--------------------------------------------------------------------------
alias mouse_update update
def update
mouse_update
save = false
mx, my = Mouse.pos
x = 0
width = (save ? 160 : 640)
height = 104
for index in 0...4
y = 64 + index % 4 * 104
if mx > x and
mx < x + width and
my > y and
my < y + height
break if @file_index == index
@savefile_windows[@file_index].selected = false
@file_index = index
@savefile_windows[@file_index].selected = true
$game_system.se_play($data_system.cursor_se)
break
end
end
end
end
Important Windows Edit Note
The demo does not include the revised copy of the Windows Edits above. The revised version properly handles the default English Name Edit Window, even considering the empty column between capital in non-capital letters in the window. There is a comment within the code which notes and recognizes the bottom most portion of the CHARACTER_TABLE holding empty characters.
Credits and Thanks
First of all, I'd like to credit Lambchop for getting me involved with this mess. ;p Hahaha... just kidding. She helped me to avoid 'Battlesystem Burnout' for all the battlesystem code I've worked on for these past months.
I also have to credit Mr.Mo for portions of the mouse-cursor system, Behemoth for some portions of his mouse input system, Near Fantastica for his Pathfinding system (one of the reasons I got involved), and Corbaque (a French scripter) who was responsible for the double-click system.
I also have to thank Delmaschio of RMVXP.Com and House Slasher for noticing that autorun events did not hinder point-n-click movement... now fixed. Along with that, allow me to thank sixtyandaquarter for bringing up the idea of enabling and disabling menu and movement functions in the system. And thanks to Reives for the idea of changing the entire set of mouse icons in-game. Finally, thanks to sixtyandaquarter for getting me off my butt to add the event-clicking feature.
And insofar as menu edits, please give credit to yamina-chan who noticed that the default windows edits had not considered proper spacing and handling where the Name Edit Window was concerned.
Terms and Conditions
Free for use, even with commercial projects.
Yeah... really. Use it. You just gotta credit all of us involved.
Sorry for posting in such an old thread, but... is there any way to modify this so you can click something across the map, and activate it as if it were player touch? Like the girl with the pink hair stuck on the island, if you could click or double click her to make her talk or something.
I am wondering because I am trying to make a visualnovel type game, and it would be very handy.
Someone else in the forum (another member) asked me the same question just two weeks ago. At this time, no.
I haven't seen a mouse script with that form of point-n-click capabilities as yet because most 'clicks' perform actions on the motion control of the player character and not towards the events themselves. Not saying it isn't a good idea though.
DerVVulfman Wrote:Someone else in the forum (another member) asked me the same question just two weeks ago. At this time, no.
I haven't seen a mouse script with that form of point-n-click capabilities as yet because most 'clicks' perform actions on the motion control of the player character and not towards the events themselves. Not saying it isn't a good idea though.
I'm just unable to get to that... right now.
can you show me how i can set it up so i can add more commands with come pictures for example i have a door i want to open and i want the small icon to come up as a door how could i do that?
o.o It should be pretty easy in the script itself. Creating a 'door' icon and adding it into the config section where you insert the 'door' icon like the other graphics. Then adding the 'door comment' in the door event like you would an 'enemy comment' in an enemy event.
DerVVulfman Wrote:o.o It should be pretty easy in the script itself. Creating a 'door' icon and adding it into the config section where you insert the 'door' icon like the other graphics. Then adding the 'door comment' in the door event like you would an 'enemy comment' in an enemy event.
can you brake that down into sections lol i have no knowledge of scripts by the way dont you have a tutorial on creating scrips?
While this is a plug-n-play system, allowing you to enter the new 'comments' into an event so you can bring up popup icons for some events. Let me restate that it is covered in the script itself. I practically FILL my scripts nowadays with the instructions. It may not be a 'beginners' level script however. For a new person, there are many 'intermediate' or 'advanced' systems that could confuse a new RGSS(2) user.
As to a tutorial on creating scripts? We all learned the hard way... by screwing around. But you did come up with an idea... "A beginner's guide to using submitted scripts" (a topic for a later date).
DerVVulfman Wrote:While this is a plug-n-play system, allowing you to enter the new 'comments' into an event so you can bring up popup icons for some events. Let me restate that it is covered in the script itself. I practically FILL my scripts nowadays with the instructions. It may not be a 'beginners' level script however. For a new person, there are many 'intermediate' or 'advanced' systems that could confuse a new RGSS(2) user.
As to a tutorial on creating scripts? We all learned the hard way... by screwing around. But you did come up with an idea... "A beginner's guide to using submitted scripts" (a topic for a later date).
:) glad to know i sparked an idea up
ok so as for the editing part of the script iam going to try and find out how it works if i can't would you mind guiding me and showing me were everything is well not everything just the parts that i need to create the new icon and make it work
i am a genius lmao!! just kidding well after looking threw it i found it :) how cool well thanks i basically only found it because if the tip you gave me
DerVVulfman Wrote:Someone else in the forum (another member) asked me the same question just two weeks ago. At this time, no.
I haven't seen a mouse script with that form of point-n-click capabilities as yet because most 'clicks' perform actions on the motion control of the player character and not towards the events themselves. Not saying it isn't a good idea though.
I'm just unable to get to that... right now.
I found a temporary way to do that... and it's to make the player graphic and event graphics transparent, set an autorun event to make the player speed 'fastest' and then click things, while they are player touch. It works pretty well, but when you have a group of 6 boxes layout out like this:
[][][]
[][][]
It causes glitches when you click elsewhere in the map if the player must pass over them.
I saw on another site that someone had invented a 'Mouse Interaction script' and it sent me to a dead link on what Im guessing is your old site, so thats why I came here.
EDIT:: By this sense, if I set the events to action button instead of player touch, it would be possible to make it work right, no? All I need for that is to know what to edit so the click is also the A button. I mean, I have it working right now but its odd to hit space and click, thats not too user friendly.
(I'm making a Time Hollow fan game. If needed, I can provide screenshots or a download demo :D