Hawk's Mouse Control System
#1
Hawk's Mouse Control System
Version 0.3.0
by Hawk-McKain

Nov 5 2006

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


Change Log | Click to Open/Close

ToDo | Click to Open/Close



[size-Large]Demo:[/size]
You can find the demo attached
.rar   Mouse_Control_v0.3.0.rar (Size: 237.26 KB / Downloads: 2)



[size-Large]Installation:[/size]
Requirements:
This script requires the SDK to work. It comes with the Demo or you can get it here: SDK Topic
Also, it'd be a good idea to get SephirothSpawn's Method & Class Library Additions [Mirror]
Note: Any scripts with hard-coded changes will be listed in their entirety

Mouse Input
Keyboard Input
View Range
Path Finding
Note: You can set the max depth for "find_path" by passing a 3rd argument.


Scripts:

Context Menus v1
Mouse Control System v0.3.1


These are split up for easier modifying.


Actor Handler v0.2.4
Event Handler v0.2.4
Terrain Handler v0.2.5




Implementing:
As much as I would like this to be a "Plug & Play" script during the beta it will still require some work to integrate fully into the system.

---- Command Windows ----

First thing you'll have o do is to replace most of the "Input.trigger?(Input::C)" type things with "Keyboard.left_click?" or "Keyboard.right_click?" for C and B respectivly. I'm a bit stumped on how to bypass this all together, because short of completely replacing the built-in Input module I can't think of anything. As for replacing it, I don't want to do that because it would interfere with "F1" or "F2" or whatever key brings up the settings menu.

Along with that, you have to remember to add "Keyboard.update" to the loop, though I've been adding it to the "update" method since I ran into some problems with it before, however I'm not entirely sure what caused it.

---- Context Menu ----

This is somewhat optional not to mention in development, you can add your own context menu items. I've begun work on a mini tutorial of this feature near the end of the post. Also if anyone knows a better way to design context menus I'm open to redesigns.

Anyway, about it, for now it works based on event name and terrain tag, also, the only way I know of doing things like bringing up message windows is by using common events. Which is another thing I could really use some feedback on, I'm not sure the best way to make coding menu items easier. One idea I had was to make the interpreter accessor and accessor some of the variables it uses, but.... I don't think that's such a wise idea.


[size-Large]Mini Tutorial:[/size] (I'll be rewriting this soon for the new syste,. Please be patient!)
Alrighty! Welcome to the latest tutorial made for Beta v3!

In version 3 I've worked on making it simpler to add and modify menu items by making each option it's own method. (ex. terrain_water_handler)

Ok, first off I'll show you the menu templates for events, terrain and actors.

Variable Templates:
@NPCs
- This variable holds all the various NPC names and the associated menu items.
Example | Click to Open/Close

Ok, now we're going to use the banker as an example. When you right click on an event with "(Banker)" in the name it will put those three options into the menu. The first one will update the amount of money in your account, then the next two will let you deposit and withdraw money.

@terrain_tags - This variable holds both the name-to-tag and tag-to-name information.
Example | Click to Open/Close

This allows the developer to name the terrain tags to make them easier to remember, then convert the number tag to a name string and vice versa.

@terrain_items - This variable holds all the items associated with each number tag.
Example | Click to Open/Close

This will take the terrain number tag you set for each tile and add it to the right-click menu. It works the same way as the events version.
Note: '0' is the default for all tiles I would't don't set anything to it.

@player - This variable holds any items associated with the actor.
Example | Click to Open/Close

This one typically won't have many options in it.

Alright, that's all the work needed for displaying the items, now how are we supposed to make them -do- something? That's where these templates come in handy. Mostly it's just copy/paste, then fill in the areas enclosed by pointy brackets (<>'s) and you'll be all set!


Handler Templates:
Event Handler:

Template | Click to Open/Close


Terrain Handler:
Template | Click to Open/Close


I get the feeling those pretty much didn't explain a whole lot.... So just look at the ones in the demo for reference. I tried to make a variety of different items to give you some ideas.

System Internals:
Alright, now what happens when the user right-clicks something?
  • First, it examines what's under the mouse. If it's an event it makes two versions (don't ask me why). First is @event_info, this one has all the info about the event (name, location, etc.). The second is @event_action, which stores all the event pages and commands.

    Anyway, it checks the event's name for anything enclosed by parentheses ()'s and gets the menu list for it.

    Now, if it's over the actor it parses @player for menu items.

    If it's neither an event or an actor it will assume it's a terrain and parses @terrain_items.
  • Second, when the player right-clicks on an event or normal terrain it passes it through the proper handler which will dynamically call the right method. (ex. If the player right-clicks on an NPC named "(Banker)" it will call "event_banker_handler")

    The first time through it checks for any items to be disabled, and then when the player selects something it runs through again and figures out what to do from there.
  • Finally, it plays any sounds the dev put in, and normally changes back to Scene_Map.

Anyway, that long explanation is for this: Add the name of a predefined set of menu items to the name of the NPC and it'll display those items.

Now, I've also added a way to further customize this setup. Normally it takes the default range required from the predefined list, but you can add a number enclosed in vertical lines (ex. |4|) and it'll use that range in place of the default. Unfortunately it will apply the range to all items. I'll find away to adjust this later.

And that's about it! You don't have as much control over terrain items however, but those should stay pretty constant normally.

I get the feeling that doesn't make as much sense as I'd like. So just ask me to clairify anything you don't understand. Though, actually ask me questions so I can make an FAQ type thing!


[size-Large]Known Bugs:[/size]
For now there are some minor bugs I'm not going to bother with for the moment.

First, and you'll probably notice this if there's a window without mouse support more than anything, the mouse clicks carry over, I think this is because of how Near made his Keyboard module.

Second, in the main menu (with all the actors), when you can select an actor it doesn't calculate the window size properly for some reason. Resolved in v0.2.4.

Third, if you have to click on an event twice if you walk up to it from the side. Resolved in v0.2.0.


[size-Large]Credits and Acknowledgements:[/size]
Most of the scripts I used were made by Near Fantasica, so a big thanks has to go to him for being such a scripting god. Without him I'd never have done anything like this.

Also, in the demo I have SephirothSpawn's Method & Class Library Additions script, though I'm not sure if I've really used it yet. Either way, thanks to him for that too.
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Dynamic Weather and Time System ThallionDarkshine 0 2,848 05-25-2012, 01:00 PM
Last Post: ThallionDarkshine
  Tutorial system Jimmie 0 2,688 08-14-2009, 01:00 PM
Last Post: Jimmie
  Mouse Over Translated Fox536 0 2,573 08-01-2009, 01:00 PM
Last Post: Fox536
  New and Easy Cache system azrith001 0 2,765 09-02-2008, 01:00 PM
Last Post: azrith001
  Vehicle System El Conductor 0 2,775 12-22-2007, 01:00 PM
Last Post: El Conductor
  Mouse corbaque 0 2,117 08-30-2007, 01:00 PM
Last Post: corbaque
  IMPROVED Fog of War System Samo the thief 0 2,504 05-06-2007, 01:00 PM
Last Post: Samo the thief
  Weight Equip System and Limit Samo the thief 0 2,557 01-29-2007, 01:00 PM
Last Post: Samo the thief
  Prize Points System Dark Ruby 0 2,538 01-28-2007, 01:00 PM
Last Post: Dark Ruby
  Export and Import System EmilyAnnCoons 0 2,414 12-29-2006, 01:00 PM
Last Post: EmilyAnnCoons



Users browsing this thread: 1 Guest(s)