Please provide player's cursor position or a way to highlight around the cursor
Please provide player's cursor position or a way to highlight around the cursor
When a mining drill is in the player's cursor, the resource mining area is displayed with a highlight.
However, as far as I know, there is no way to do this with a modded item that is not a mining drill nor a power pole.
Therefore, as part of LuaPlayer.cursor_stack or LuaPlayer.cursor_ghost, I would like it if the position of the entity to be placed were somehow provided so I can render a visualization to the player that shows what area will be affected by the entity - before this entity is actually built.
However, as far as I know, there is no way to do this with a modded item that is not a mining drill nor a power pole.
Therefore, as part of LuaPlayer.cursor_stack or LuaPlayer.cursor_ghost, I would like it if the position of the entity to be placed were somehow provided so I can render a visualization to the player that shows what area will be affected by the entity - before this entity is actually built.
Re: Please provide player's cursor position or a way to highlight around the cursor
Couldn't you get the cursor position, and place a sprite maybe with the brightness multiplied by day brightness at the position? Follow the mouse around every tick if they have the item in their hand. I don't know how to tell if the character puts the item away, but tracking if they had an item in their hand and it was one you want highlighted should work.
I have mods! I guess!
Link
Link
Re: Please provide player's cursor position or a way to highlight around the cursor
Getting the player's mouse position will never be done because then every player would have to send a network packet every time their mouse moved.
However something to draw LuaRendering objects relative to the player's cursor ghost could be done, and has been requested previously.
However something to draw LuaRendering objects relative to the player's cursor ghost could be done, and has been requested previously.
Re: Please provide player's cursor position or a way to highlight around the cursor
What about light about the cursor by godmode in the night? Can it be seen in the multiplayer?
Re: Please provide player's cursor position or a way to highlight around the cursor
It has been on my mental to-do to make every entity support having some "area" visualization when in the cursor. I just haven't figured out how that would interact with already-built entities and such.
Right now electric poles show all areas in the world that have electric coverage when you hold one but things like beacons don't.
I could easily make a property which just shows "an area" around the item when in the cursor that has no other logic. Unless someone has better ideas.
Right now electric poles show all areas in the world that have electric coverage when you hold one but things like beacons don't.
I could easily make a property which just shows "an area" around the item when in the cursor that has no other logic. Unless someone has better ideas.
If you want to get ahold of me I'm almost always on Discord.
-
- Filter Inserter
- Posts: 464
- Joined: Tue Jun 28, 2016 2:07 pm
- Contact:
Re: Please provide player's cursor position or a way to highlight around the cursor
Something like that. Although I don't see how it would ever really work out to be anything except "just draws a square when held".IronCartographer wrote: ↑Wed Dec 11, 2019 9:29 pmDoes this refer to potential interactions like custom filtering of highlighting for entities that would overlap the area?
If you want to get ahold of me I'm almost always on Discord.
Re: Please provide player's cursor position or a way to highlight around the cursor
This sounds really dumb, but could the mouse cursor be made a luaEntity, that specifically only exists/updates for the current player? (to prevent network lag) Then it would have a position, and a sprite could be drawn using luarender if the player cursor stack changed and it matched a certain item.Rseding91 wrote: ↑Wed Dec 11, 2019 10:15 pmSomething like that. Although I don't see how it would ever really work out to be anything except "just draws a square when held".IronCartographer wrote: ↑Wed Dec 11, 2019 9:29 pmDoes this refer to potential interactions like custom filtering of highlighting for entities that would overlap the area?
I don't know if a sprite can be made to 'follow' an entity. An entity can be made a target, but the only things that draw I can think of are non-moving entities: power poles, miners, turrets, etc. I can think of many reasons it would be useful for a draw_<foo> to follow an entity.
I have mods! I guess!
Link
Link
Re: Please provide player's cursor position or a way to highlight around the cursor
Ever heard of script rendering? https://lua-api.factorio.com/latest/LuaRendering.htmlI don't know if a sprite can be made to 'follow' an entity. An entity can be made a target, but the only things that draw I can think of are non-moving entities: power poles, miners, turrets, etc. I can think of many reasons it would be useful for a draw_<foo> to follow an entity.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: Please provide player's cursor position or a way to highlight around the cursor
Bilka wrote: ↑Wed Dec 11, 2019 11:31 pmEver heard of script rendering? https://lua-api.factorio.com/latest/LuaRendering.htmlI don't know if a sprite can be made to 'follow' an entity. An entity can be made a target, but the only things that draw I can think of are non-moving entities: power poles, miners, turrets, etc. I can think of many reasons it would be useful for a draw_<foo> to follow an entity.
Code: Select all
draw_sprite{sprite=…, orientation=…, x_scale=…, y_scale=…, tint=…, render_layer=…, orientation_target=…, orientation_target_offset=…, oriented_offset=…, target=…, target_offset=…, surface=…, time_to_live=…, forces=…, players=…, visible=…, only_in_alt_mode=…} → uint64
Create a sprite.
Parameters
Table with the following fields:
sprite :: SpritePath
orientation :: float (optional): The orientation of the sprite. Default is 0.
x_scale :: double (optional): Horizontal scale of the sprite. Default is 1.
y_scale :: double (optional): Vertical scale of the sprite. Default is 1.
tint :: Color (optional)
render_layer :: RenderLayer (optional)
orientation_target :: Position or LuaEntity (optional): If given, the sprite rotates so that it faces this target. Note that orientation is still applied to the sprite.
orientation_target_offset :: Vector (optional): Only used if orientation_target is a LuaEntity.
oriented_offset :: Vector (optional): Offsets the center of the sprite if orientation_target is given. This offset will rotate together with the sprite.
target :: Position or LuaEntity: Center of the sprite.
target_offset :: Vector (optional): Only used if target is a LuaEntity.
surface :: SurfaceSpecification
time_to_live :: uint (optional): In ticks. Defaults to living forever.
forces :: array of ForceSpecification (optional): The forces that this object is rendered to.
players :: array of PlayerSpecification (optional): The players that this object is rendered to.
visible :: boolean (optional): If this is rendered to anyone at all. Defaults to true.
only_in_alt_mode :: boolean (optional): If this should only be rendered in alt mode. Defaults to false.
Return value
Id of the render object
I have mods! I guess!
Link
Link
Re: Please provide player's cursor position or a way to highlight around the cursor
Once I write the mod with player's selected highlighting: https://mods.factorio.com/mod/TorchLight
The mod creates small LuaRendering.light between player and selected entity, but the light can be attached only one for them.
The mod creates small LuaRendering.light between player and selected entity, but the light can be attached only one for them.