Read whether stone/concrete/ground is under mouse cursor?

Place to get help with not working mods / modding interface.
Post Reply
Tinyboss
Fast Inserter
Fast Inserter
Posts: 205
Joined: Sun Nov 16, 2014 12:11 pm
Contact:

Read whether stone/concrete/ground is under mouse cursor?

Post by Tinyboss »

I've made the Picker mod which behaves like the middle mouse button in Minecraft: put your cursor over an entity and activate Picker with a hotkey, and it selects the corresponding item from your inventory. I'd like to extend it to be able to pick stone, concrete, and hazard concrete as well, but I don't see how to do it. I'm using player.selected to get the entity currently under the cursor--is there a corresponding pointer to the tile under the cursor?

I thought I found the answer with player.cursor_position, but that's a write-only property. I guess there are synchronization issues?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13246
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Read whether stone/concrete/ground is under mouse cursor?

Post by Rseding91 »

You can't. The mouse position is not part of the game state and as such can't be read from mods.
If you want to get ahold of me I'm almost always on Discord.

Tinyboss
Fast Inserter
Fast Inserter
Posts: 205
Joined: Sun Nov 16, 2014 12:11 pm
Contact:

Re: Read whether stone/concrete/ground is under mouse cursor?

Post by Tinyboss »

Rseding91 wrote:You can't. The mouse position is not part of the game state and as such can't be read from mods.
Thanks for the definitive answer.

User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: Read whether stone/concrete/ground is under mouse cursor?

Post by DedlySpyder »

Rseding91 wrote:You can't. The mouse position is not part of the game state and as such can't be read from mods.
Then what is the point of cursor_position?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13246
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Read whether stone/concrete/ground is under mouse cursor?

Post by Rseding91 »

DedlySpyder wrote:
Rseding91 wrote:You can't. The mouse position is not part of the game state and as such can't be read from mods.
Then what is the point of cursor_position?
It's write only. It was put in to make the game trailer and never removed.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Modding help”