ID:1861384
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
I'd like to see procs to get pressed (held down) keys, and a proc to get mouse position (x,y,z of tile, or even screen x,y)

Example:

/obj/weapon/automatic_rifle
tick() // Let's pretend this gets called a few times ever second.
if(istype(src.loc, /mob))
var/mob/M = src.loc
if(M.client)
if(M.client.IsKeyDown("LMB"))
shoot(locate(client.GetMouseCoordinates())) // Gets X, Y, Z of tile over which the cursor is hovering.
You can already get the coordinates from mice.

"The location argument varies with the type of control. For the map, it will be the turf where the mouse action happened. For info controls (statpanels), it will be the name of the statpanel where the action happened. For grid controls, it will be the cell where the action happened. For others controls it may vary, but most will leave this blank.

The control argument is the ID of the skin control where the action happened, such as "mappane.map" or "mainwindow.banner".

Click(location,control,params)
DblClick(location,control,params)
MouseEntered(location,control,params)
MouseExited(location,control,params)

Notice a pattern with the args "location" and "control" and "params" ?

Also, for future reference, I would suggest creating a more detailed feature request as this is pretty generic.
Will it report mouse position continuously?

Edit: Yeah those will report the position once, and there is still no way to get mouse position apart from those events.
In response to TheDracheX1
TheDracheX1 wrote:
Will it report mouse position continuously?

It depends on which mouse proc you're calling. Whether it's Click(), that's a one-time deal since you're clicking once. If it's MouseDown() I believe the location data does change based on moving the mouse, but I can't be certain since I rarely ever use it.
Well, I'd like to be able to get mouse position regardless of whether it was clicked or not.
If you're trying to get mouse coordinates base on "hovering" you can use MouseEntered(location,control,params). But it's not recommended to do such a thing unless you're making a lightweight game as the constant data creates overhead.

I would suggest reading the guide and reference as you've missed the Mouse abilities.

http://www.byond.com/docs/guide/
http://www.byond.com/docs/ref/
Please refer to the example I gave. It doesn't make sense to use MouseEntered. IMO: This level of user input is pretty darn basic, and every respectable framework should be able to support it.
Well, in your example I would probably save the MouseEntered location to a client variable, and then pass that through shoot().

Well that's some ugly code if you ask me.
In response to TheDracheX1
To be honest, it's ugly to do constant updates to check Mouse coordinates unless there's a need to. You could handle shoot() through Click() instead of constantly checking mouse coordinates. You wanted an example of MouseEntered() through your code, I supplied an example.
The point was continous firing if the mouse is kept clicked. Like an automatic rifle, not each time its clicked.
In response to TheDracheX1
TheDracheX1 wrote:
The point was continous firing if the mouse is kept clicked. Like an automatic rifle, not each time its clicked.


MouseDown(location,control,params)
I get that. But it's not what I'd like to see, that just fires when a mouse is CLICKED. There is no way of checking if the mouse is still pressed.

while(client.KeyDown("LMB"))
DoStuff()
Yes there is. MouseDown() is only called when a mouse is clicked and held down. Hence MouseDown().

Format:
MouseDown(location,control,params)

Args:
location: the turf, stat panel, grid cell, etc. in which the object was clicked
control: the name of the skin control involved
params: other parameters including mouse/keyboard flags, icon offsets, etc.; see mouse control
This is called when a mouse button is pressed while pointing to this object.

Don't define this unless you need it, because it generates extra communication that is otherwise avoided. Most operations can be done through Click(), DblClick(), and MouseDrop(). The other procedures are simply available for completeness.
In response to Maximus_Alex2003
You're completely missing his point.

@TheDracheX1: I think Kaiochao's mouse will help you in the meantime.
In response to FKI
FKI wrote:
You're completely missing his point.

@TheDracheX1: I think Kaiochao's mouse will help you in the meantime.

Nope. Point isn't missing at all. Actually, I was giving the wrong form of MouseDown. Instead of atom MouseDown(), you'll want client MouseDown() and MouseUp()


Also, notice how Kaiochaos demo has the Mouse procs I've previously mentioned.

    MouseEntered(o, l, c, p)
..()
mouse.on_map = TRUE
MouseUpdate(params2list(p)["screen-loc"])

MouseExited()
..()
mouse.on_map = FALSE

MouseMove(o, l, c, p)
..()
MouseUpdate(params2list(p)["screen-loc"])

MouseDrag(so, oo, sl, ol, sc, oc, p)
..()
MouseUpdate(params2list(p)["screen-loc"])


Also, given that this is more of Developer Help I believe it should be moved over to that sub-forum unless you're specifically asking for a new client var for Mouse-Held-Down.
In response to Maximus_Alex2003
"This is called when the a mouse button is pressed while pointing to the object. Note that MouseUp() will always be called after MouseDown() is called, even if over empty space. That means object and location may be null."

From what I can tell this is called once when you click on something. No way to check you're still clicking it unless you want to add vars and terrorize your codebase.

Maximus_Alex2003 wrote:
FKI wrote:
You're completely missing his point.

@TheDracheX1: I think Kaiochao's mouse will help you in the meantime.

Nope. Point isn't missing at all. Actually, I was giving the wrong form of MouseDown. Instead of atom MouseDown(), you'll want client MouseDown() and MouseUp()


Also, notice how Kaiochaos demo has the Mouse procs I've previously mentioned.

>   MouseEntered(o, l, c, p)
> ..()
> mouse.on_map = TRUE
> MouseUpdate(params2list(p)["screen-loc"])
>
> MouseExited()
> ..()
> mouse.on_map = FALSE
>
> MouseMove(o, l, c, p)
> ..()
> MouseUpdate(params2list(p)["screen-loc"])
>
> MouseDrag(so, oo, sl, ol, sc, oc, p)
> ..()
> MouseUpdate(params2list(p)["screen-loc"])
>


Also, given that this is more of Developer Help I believe it should be moved over to that sub-forum unless you're specifically asking for a new client var for Mouse-Held-Down.

Dude, this is feature request, I never even asked for help.
In response to TheDracheX1
Well, it's a tough feature request since the science already exists in the various built-in Mouse procs.

I wouldn't mind having a new read-only client var for something like client/mouse_held which reads true or false given if the Mouse Left/Right button is held down or not. But a new Mouse proc to do the same thing that's already existent seems redundant.
But it's not existant. You can hack a solution but it sure as hell ain't pretty.
In response to TheDracheX1
It's not a hacky solution. The args in the various Mouse procs for location, control, and params are there for a reason. This specific reason.

This request has somewhat already been requested in small various ways.

http://www.byond.com/forum/?post=1597354


Also, take a gander at this post:

http://www.byond.com/forum/?post=195024
Page: 1 2