Philsco

Flipped Out RPG2Knet.com vet
Veteran
Joined
Apr 5, 2015
Messages
41
Reaction score
9
First Language
English
Primarily Uses
If you are like, "why so much text, bruh!?," see the very last sentence, please!

I have been using Shaz's (excellent!) script, "Super Simple Mouse Script by Shaz."  I really hate to post a "help me!" post so quickly after joining the community, but I think I have a fair and comprehensive way to ask that will help a lot of people in general, and will allow me to become a more valued part of the community.

I've been "studying" Shaz's script (and it's a good script!), and I think I understand the gist of it (to be read: "been Googling syntax and declarations"), but I just want to understand what mouse control functions are what.  Before going into what all I know (which I am more than willing to do...!  ...but first...), I'd like to know what all of you expert script coders consider to be the most fundamental of the fundamentals to know about "Mouse Interaction with Events."  I'm not looking to make a "move to mouse click" script, yet.  That's not my ambition.  I simply wish to know what basic built-in variables and functions (methods...gotta get used to saying that!)... *ahem* so yes, what basic variables, methods, and data manipulation techniques do I need to know to make a, "click on event with a condition that allows it to be clickable and it activates" script?  This is my first ambitious endeavor into scripting, so bring the lube and be gentle!

Feel free to skip this next part if you're going in raw-dogging it........but...

Okay, okay, first things first, so we can skip SOME garbage....  I'm not "totally" virgin!  I'm pretty familiar with C++, HTML, XML, Java, and VERY VERY VERY familiar with Actionscript (Macromedia, 2.0, and 3.0), so I understand conditional boolean and for statements/strings/arrays/[push,concat,modulate,etc]addition and subtraction(+=,-=,/=,%=,*=,etc)/return/defining a function(or method in rgss3),and other basic syntax stuff.  Also, I've used RPG Maker 98, 2k, and RM2k3 including RPGAdvocate's version and the "hacked" versions allowing 999999 variables and 999 pics etc etc etc blah blah blah.  I understand the idea of object control (using "." to say, "this.object.doesthis(with_this_statement, and_this_one, and_also_this)"), and I get...well, the "bare basics," y'know?  But I don't actually know the core functions/methods or the global variables to use, or what they do, what they relate to, etc etc when it comes to Ruby and RGSS3 :p

Sorry, I know, VERY long winded, but the main complaint I've seen on this thread with help requests has been that they are too vague and don't really give you guys much to go on, so I wanted to make sure I gave you the tools to fix what's broken!
 
Last edited by a moderator:

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,296
Reaction score
1,493
First Language
English
Primarily Uses
Other
Are you asking in context of specifically Shaz's script?
 

Philsco

Flipped Out RPG2Knet.com vet
Veteran
Joined
Apr 5, 2015
Messages
41
Reaction score
9
First Language
English
Primarily Uses
Nope.  Just in what the basics necessary to define the mouse position and how to interact with its defined position are.
Thanks though!  I fear I might not have been clear enough on that.
I just want the basic "these are mouse scene coord variables"
and "These are commands to interact with an event which is at specified coord variables"
and "This is how to recognize a comment tag, and this is how to input one that says basically 'can be clicked by mouse to activate'"

also... "one that says 'must be within xxx variable range of actor to activate' "

So...any/all of that info would be awesome.  Or links to resources where I could learn it, 'cuz the F1 file was NOT capable!
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,529
Reaction score
14,848
First Language
English
Primarily Uses
RMMV
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


I can't take credit for that functionality. SephirothSpawn and Near Fantastica wrote the very original mouse script that we used in the Aveyond games made with RMXP. We made a lot of mods to it for each new XP game. When I started to use Ace, I completely rewrote most of the system (and after becoming even more familiar with Ace and seeing further shortcomings in the design, plan to do another complete overhaul). The very basic stuff though - get buttons pressed, get mouse scene coordinates, etc - will still come from the original API calls and logic that was written way back when.
 

Philsco

Flipped Out RPG2Knet.com vet
Veteran
Joined
Apr 5, 2015
Messages
41
Reaction score
9
First Language
English
Primarily Uses
Sorry about the wrong forum post >_< guess I didn't look hard enough.  I'll get the lay of the land better before I make another post.

Anyway I guess my main confusion comes from having looked at a couple other scripts to compare methods, and I found that different calls were used for some reason.

Mouse.lclick? AND Mouse.rclick? WHICH RETURN BOOLEAN TRUE/FALSE

Mouse.trigger()? (0) (1) (2)

and Mouse.press()? (0) (1) (2)

I noticed that they all seem to use different methods of finding the mouse, too.

*Mouse.position (for the script you worked on, Shaz)

@pos = Mouse.pos AND self.x, self.y = *Mouse.pos (for Jet's script)

Mouse.within?(visible_rects[shown_elements.index(index)])  (For Meph's, though it's for selecting window elements)

Also, in all of these, none of these Mouse classes are ever defined.  So, I'm guessing they're core to the RGSS3 API, or are they Ruby calls?
I guess what I really need (that I can't find for the life of me!) is a list of Mouse calls and functions, be it a brief list that I can experiment with, or a link to some website that has been eluding my Google-Fu.  Normally I would just pick and choose commands from scripts until I understand them, but seeing as there appears to be so many ways to call upon Mouse functions, I was wondering if there was something I missed before I dive in.

Here are some of the scripts I looked at:
Jet's
http://pastebin.com/raw.php?i=K1hGYjr6

Super Simple Mouse Script by Shaz

http://pastebin.com/TxKQa3WK

Meph's Mouse Selectable Windows

http://pastebin.com/6kJ1wj6J
 
Last edited by a moderator:

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,296
Reaction score
1,493
First Language
English
Primarily Uses
Other
Win32API calls are used to retrieve the absolute positions of the mouse cursor and the absolute position of the game window.

Based on these coordinates calculating the in-game mouse coordinates are straightforward. Mouse.position is an interface provided which does this calculation for you and returns the in-game mouse screen x- and y-coordinate.

How would you transform this into possible event locations?

*hugs*
 

Philsco

Flipped Out RPG2Knet.com vet
Veteran
Joined
Apr 5, 2015
Messages
41
Reaction score
9
First Language
English
Primarily Uses
Thanks, Zeriab!  I appreciate that (both the hugs and the help ;D )

So, to make sure I got it...
Mouse.position is already in the actual RGSS3 architecture itself, and uses Windows API calls to calculate the Game.exe's window position, width and height (to give accuracy regardless of whether it's windowed or fullscreen), and the Mouse's relative location to the screen and game window based around that.  It then returns...I'm guessing an Array based on (x, y)?  There may be other operators there, like whether the mouse is within the bounds of the window or not, but for now all I need is to know that it returns (most likely) a set of variables in the form of an array with the first two ([0] [1] positions) being x and y, respectively.

Further, to get event positions based on mouse position, you'd just take the screen's "square" grid (17x13) and multiply it by 32.  Then, whenever you are checking a mouse event such as left-clicking (whichever command of the 3 that I listed is used best for my tastes, I'll just have to test to find out), just take the current Mouse.position's array x/y, and divide it by 32.  Then check for current events' positions, maybe?  I dunno, this is where I'll have to toy around :p

Basically, if each "square on the grid" is 32x32, that means if you are in the 4th "square" over, and 7th down, you're between the mouse coordinates of (128, 224) and (160, 256).  Or rather, if you're between the coordinates of (128, 224) to (160, 256), you're within the bounds of the event at map grid coordinate's (4, 7) event.

...pretty close?  And thank you all for your patience, and all of your help in allowing me to expediently learn a new language.
 
Last edited by a moderator:

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,296
Reaction score
1,493
First Language
English
Primarily Uses
Other
No, when I talked about Win32API I meant that we have to implement the Win32API calls directly. RGSS3 does not provide any nice interface for that.

I remembered wrongly about the sequence, sorry about that. Consider this piece of code from my Ace WIP mouse script

  #--------------------------------------------------------------------------  # * Mouse to Input Triggers  #--------------------------------------------------------------------------  LEFT_CLICK = 1  RIGHT_CLICK = 2  MIDDLE_CLICK = 4   MOUSE_TRIGGERS = [LEFT_CLICK, RIGHT_CLICK, MIDDLE_CLICK]  #--------------------------------------------------------------------------  # * API Declaration  #--------------------------------------------------------------------------  ASYNC_KEY        = Win32API.new('user32',    'GetAsyncKeyState', 'i',     'i')  SCREEN_TO_CLIENT = Win32API.new('user32',    'ScreenToClient',   %w(l p), 'i')  CURSOR_POS       = Win32API.new('user32',    'GetCursorPos',     'p',     'i')  FIND_WINDOW      = Win32API.new('user32',    'FindWindowA',      %w(p p), 'l')
GetCursorPos gives us the absolute positions where ScreenToClient converts them into positions relative to the game window.
FindWindowA is used for finding the window handle of our game. GetAsyncKeyState is to get the state of the mouse triggers. I.e. left/middle/right mouse button pressed down right now?

As for clicking, you have to consider what defines the mouse clickable boundaries of an event. Is it the logical tile used for collisions and keyboard triggers, or is rather the visible sprite. For visible sprite, would it then be the sprite's bounding box, or something else?

*hugs*

 - Zeriab
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,529
Reaction score
14,848
First Language
English
Primarily Uses
RMMV
Mouse.lclick? AND Mouse.rclick? WHICH RETURN BOOLEAN TRUE/FALSE


Mouse.trigger()? (0) (1) (2)


and Mouse.press()? (0) (1) (2)


*Mouse.position (for the script you worked on, Shaz)


@pos = Mouse.pos AND self.x, self.y = *Mouse.pos (for Jet's script)
That's right - what you're seeing there are OUR method names in OUR scripts. People use different names for methods that do the same thing - they're just made-up names. If you look into them, you'll see that somewhere along the line, they probably make the same Win32API calls.
 

Philsco

Flipped Out RPG2Knet.com vet
Veteran
Joined
Apr 5, 2015
Messages
41
Reaction score
9
First Language
English
Primarily Uses
I apparently have a "blind and stupid" curse placed on me for RGSS3 and Ruby.  I've not noticed the Win32API calls in any of those until you pointed them out >_<
Makes everything soooo much clearer now haha.  You guys are awesome, just puttin' that out there.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,529
Reaction score
14,848
First Language
English
Primarily Uses
RMMV
I just realized that you had the impression that mouse control was a part of the engine. It's not. So everything you see in those scripts EXCEPT the Win32API calls is custom done by the developer. The API calls are the only things that they really need to have in common - how they implement everything else is entirely the developer's design.
 

Philsco

Flipped Out RPG2Knet.com vet
Veteran
Joined
Apr 5, 2015
Messages
41
Reaction score
9
First Language
English
Primarily Uses
Yeah somehow I totally missed every single script's reference to Win32API calls.  You guys just took what I thought was already possible for this system and blew the roof right off!
 

Latest Threads

Latest Posts

Latest Profile Posts

I just did some math and... apparently what seemed to be a little fun gimmick turned out to be an 80+ actors project :kaoswt2:
Yay! the original character contest 3 pack is here!
Both MV and MZ looks very good, congratulation for both RMW and Tkool participant!
I definitely can add these characters to use for my game project.

Steam link
The worst part of game development has to be marketing. Ugh...
May be starting a new job in a month or so. The thought is both exciting and terrifying.
Not like a rollercoaster though. Rollercoasters are just terrifying.
"Merchants don't sell you a product. They sell you something RIGHT NOW. That's all they're selling, the product of having what you want RIGHT NOW and not having to wait for it."

Forum statistics

Threads
112,476
Messages
1,068,550
Members
146,143
Latest member
marquez19marissa
Top