Direction information of the player cursor

Things that we aren't going to implement
Gweneph
Inserter
Inserter
Posts: 45
Joined: Thu Nov 14, 2019 11:51 pm
Contact:

Direction information of the player cursor

Post by Gweneph »

I'm trying to read and/or write the direction of the cursor (for building an entity) but I haven't found any api to do so.

I thought I might have a clever workaround by pipetting an entity that has the desired orientation with LuaPlayer.pipette_entity, but unfortunately, the direction is not taken from the pipetted entity despite that happening when a player does so with q. This does seem like a bit of bug as the API says
Invokes the "smart pipette" action on the player as if the user pressed it.
Then I figured I might be able to keep track of the rotation by tracking when the player rotates, shift rotates, with something rotatable in their cursor, or pipettes something, but unfortunately the on_player_pipette event only includes the LuaItemProtoype, which doesn't contain any direction information.

So then I checked out the tips and tricks simulations, because they have to rotate the build cursor programmatically, and it turns out they use game.camera_player_cursor_direction but this property only seems to be available in simulations not in the main game.

So I would like some way to read or write the direction of the player cursor? If not, could one be added?

As for justification, it's for a mod that's working to allow players with limited to no vision to play by speaking the required information. We already have building and rotation working with accessible speech, but we're working around the system and, as a result, the gui preview doesn't match what happens. This would make playing with low vision or with sighted assist confusing, and make multiplayer with sighted folks untenable.
Anfilt
Burner Inserter
Burner Inserter
Posts: 7
Joined: Sun Oct 02, 2022 8:02 pm
Contact:

Re: Direction information of the player cursor

Post by Anfilt »

I would also like to add this would be quite helpful to have. For something I am working on this would be quite handy as well. Trying to figure out some way to work around the cursor being such a black box right now. Other than the cursor stack.
User avatar
MrGrim
Fast Inserter
Fast Inserter
Posts: 244
Joined: Sat Apr 09, 2016 7:58 pm
Contact:

Re: Direction information of the player cursor

Post by MrGrim »

I also have a use for this. If you alter what's in the cursor in the on_pre_built event then what gets built will be altered, but I cannot control the direction. Right now I think I can work around it by putting a place holder simple entity item in the cursor then destroy the resulting entity in the subsequent on_built_entity event and rebuild what I need in the right direction but that's a bit prone to problems.

Alternatively if the on_pre_built even had some method to cancel the build I could just create what I need there.
User avatar
ownlyme
Filter Inserter
Filter Inserter
Posts: 444
Joined: Thu Dec 21, 2017 8:02 am
Contact:

Re: Direction information of the player cursor

Post by ownlyme »

i just wondered the same thing.
i'm using the rotation keybind for cycling between variations of my turret (in the cursor stack/cursor ghost), but it feels weird that they keep rotating while doing that
creator of 55 mods
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
braxbro
Inserter
Inserter
Posts: 35
Joined: Sun Jan 01, 2023 2:54 am
Contact:

Re: Direction information of the player cursor

Post by braxbro »

MrGrim wrote: Sun Nov 10, 2024 12:23 am I also have a use for this. If you alter what's in the cursor in the on_pre_built event then what gets built will be altered, but I cannot control the direction. Right now I think I can work around it by putting a place holder simple entity item in the cursor then destroy the resulting entity in the subsequent on_built_entity event and rebuild what I need in the right direction but that's a bit prone to problems.

Alternatively if the on_pre_built even had some method to cancel the build I could just create what I need there.
If you clear the cursor stack iirc it will cancel the build…? I can’t remember perfectly, but I remember at some point Spaghettorio was doing some nonsense with the cursor stack in pre_build before I found a better solution.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14890
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Direction information of the player cursor

Post by Rseding91 »

Gweneph wrote: Wed Jun 15, 2022 12:30 am I'm trying to read and/or write the direction of the cursor (for building an entity) but I haven't found any api to do so.
This is because it's not part of the game state and so is not available to mods. If that changes some day, then we will add the Lua API. But, until then, this is a won't-implement.
If you want to get ahold of me I'm almost always on Discord.
curiosity
Filter Inserter
Filter Inserter
Posts: 558
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Direction information of the player cursor

Post by curiosity »

Rseding91 wrote: Mon Dec 30, 2024 8:50 pm This is because it's not part of the game state and so is not available to mods. If that changes some day, then we will add the Lua API. But, until then, this is a won't-implement.
Could you perhaps include it into the action? That gets sent over the network anyway. Then mods will be able to get it on custom input. Seems like it would solve the OP's problem, too.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3454
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Direction information of the player cursor

Post by boskid »

curiosity wrote: Mon Dec 30, 2024 9:31 pm Could you perhaps include it into the action? That gets sent over the network anyway. Then mods will be able to get it on custom input. Seems like it would solve the OP's problem, too.
https://lua-api.factorio.com/2.0.28/eve ... InputEvent already contains `cursor_position` that is raised for custom inputs with lua action.
curiosity
Filter Inserter
Filter Inserter
Posts: 558
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Direction information of the player cursor

Post by curiosity »

boskid wrote: Mon Dec 30, 2024 9:37 pm https://lua-api.factorio.com/2.0.28/eve ... InputEvent already contains `cursor_position` that is raised for custom inputs with lua action.
Exactly. So it could have cursor rotation as well.
Post Reply

Return to “Won't implement”