Mouse position

Place to get help with not working mods / modding interface.
Cerus
Inserter
Inserter
Posts: 45
Joined: Mon Mar 11, 2013 7:05 pm
Contact:

Mouse position

Post 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?

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Mouse position

Post 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
Last edited by ficolas on Mon Jun 24, 2013 9:33 pm, edited 1 time in total.

MF-
Smart Inserter
Smart Inserter
Posts: 1235
Joined: Sun Feb 24, 2013 12:07 am
Contact:

Re: Mouse position

Post by MF- »

"some of os".. I though you are talking about operating systems for a while.. :D

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Mouse position

Post 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

Cerus
Inserter
Inserter
Posts: 45
Joined: Mon Mar 11, 2013 7:05 pm
Contact:

Re: Mouse position

Post by Cerus »

Interesting workaround, thanks!

kovarex
Factorio Staff
Factorio Staff
Posts: 8173
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Mouse position

Post 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.

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Mouse position

Post 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.

SilverWarior
Filter Inserter
Filter Inserter
Posts: 559
Joined: Mon Mar 04, 2013 9:23 am
Contact:

Re: Mouse position

Post 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

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: Mouse position

Post 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)?

Cerus
Inserter
Inserter
Posts: 45
Joined: Mon Mar 11, 2013 7:05 pm
Contact:

Re: Mouse position

Post 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.

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Mouse position

Post 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

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: Mouse position

Post 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).

Post Reply

Return to “Modding help”