Page 1 of 1

Mouse position

Posted: Mon Jun 24, 2013 9:07 pm
by Cerus
I've searched around but can't find an answer, is it possible to get mouse/cursor data (position, mouse click events, etc.) from the interface?

Re: Mouse position

Posted: Mon Jun 24, 2013 9:19 pm
by ficolas
Cerus wrote:I've searched around but can't find an answer, is it possible to get mouse/cursor data (position, mouse click events, etc.) from the interface?
No it is not, what some of us are using, is creating an "tool" item, without colision box, and placeable anywhere, to register the clicks using onentityplaced event, and automatically removing the entity when it is created, you can see a "example code" in my mod or in the test mode mod (read the testmode mod better because my mod doesnt use the pos of the entity created

Re: Mouse position

Posted: Mon Jun 24, 2013 9:30 pm
by MF-
"some of os".. I though you are talking about operating systems for a while.. :D

Re: Mouse position

Posted: Mon Jun 24, 2013 9:34 pm
by ficolas
MF- wrote:"some of os".. I though you are talking about operating systems for a while.. :D
tipibslg fasy in thr mobie phone is hahnd

just kidding xD
typing fast in the mobile phone is hard

Re: Mouse position

Posted: Mon Jun 24, 2013 9:47 pm
by Cerus
Interesting workaround, thanks!

Re: Mouse position

Posted: Tue Jun 25, 2013 4:08 am
by kovarex
Just to have idea what would be useful to have in the future for the modding.

Would some kind of usable/usable on position method of item be useful?
You would select the item with number from quickbar, and it would be either used or it would ask for position (special cursor) to click.
After that, function specified in the prototype would be fired.

Working directly with mouse cursor is something I would like to avoid.

Re: Mouse position

Posted: Tue Jun 25, 2013 6:56 am
by ficolas
kovarex wrote:Just to have idea what would be useful to have in the future for the modding.

Would some kind of usable/usable on position method of item be useful?
You would select the item with number from quickbar, and it would be either used or it would ask for position (special cursor) to click.
After that, function specified in the prototype would be fired.

Working directly with mouse cursor is something I would like to avoid.
Yes, it would be the same we have now, but less ugly, also in the prototype it could be specified if it gets used or not.

Re: Mouse position

Posted: Tue Jun 25, 2013 9:30 am
by SilverWarior
kovarex wrote:Working directly with mouse cursor is something I would like to avoid.
You are right, especially if every mouse move would execute some LUA script as you can get great performance usage with this.
As a workaround you could save mouse position at certain intervals (twice per second) into some variable and make that variable readable by LUA scripts to be used by moodders.
But I would ask the mooders first to see why they need this as it is posible they are trying to achieve something that could be better done on native level rather than with using scripts. Somehow I have a feeling that they might want something more out of the ingame GUI :D

Re: Mouse position

Posted: Tue Jun 25, 2013 12:58 pm
by drs9999
hmm why not expand the onputitem-event?
So atm it is called only if you right-click with a placable-item, why not raise the event everytime you right-click (with an item in your hand)?

Re: Mouse position

Posted: Tue Jun 25, 2013 2:44 pm
by Cerus
If you were curious why I wanted this functionality I'm toying with a "needs" mod that implements a hunger/thirst/fatigue simulation, part of the survival package is the ability to fish, which I wanted to have some level of interactivity and so I needed a way to detect where the mouse was so I could create the lure at that location.

Edit: So basically yeah, a "usable at position" item would be perfect for this.

Re: Mouse position

Posted: Tue Jun 25, 2013 3:25 pm
by ficolas
Cerus wrote:If you were curious why I wanted this functionality I'm toying with a "needs" mod that implements a hunger/thirst/fatigue simulation, part of the survival package is the ability to fish, which I wanted to have some level of interactivity and so I needed a way to detect where the mouse was so I could create the lure at that location.

Edit: So basically yeah, a "usable at position" item would be perfect for this.
an event raised when clicking a entity could also be really usefull

Re: Mouse position

Posted: Tue Jun 25, 2013 4:18 pm
by drs9999
ficolas wrote:an event raised when clicking a entity could also be really usefull
this could also be included in the expanded onpuitem-event.

The event would return the cursor-position on map and a pointer to the clicked entity(if there is one of course).