I'm trying to create a line from an object to the mouse, and have it update each frame
I'm not sure the best way to get mouse position each frame.
The only way I've seen in the documentation is to use a custom input, but that will only activate when the button is first pressed
i.e: script.on_event("my-custom-input", function(event) local cursor_position = event.cursor_position end)
Is there any other way to get the mouse position?
Thanks!
Get mouse position each frame?
-
Gizzmohammer
- Inserter

- Posts: 23
- Joined: Wed May 07, 2025 1:55 am
- Contact:
Re: Get mouse position each frame?
There is no way to get mouse position apart from certain events as mouse position is not part of game state, and as such is not available to mods.
You can look at how https://mods.factorio.com/mod/Tapeline does it, which seems to be using a selection tool and area from event such as this https://lua-api.factorio.com/latest/eve ... ected_area
You can look at how https://mods.factorio.com/mod/Tapeline does it, which seems to be using a selection tool and area from event such as this https://lua-api.factorio.com/latest/eve ... ected_area
