Tooltips: A better way to modify them via modding

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
danbopes
Inserter
Inserter
Posts: 27
Joined: Mon Feb 07, 2022 9:29 pm
Contact:

Tooltips: A better way to modify them via modding

Post by danbopes »

I'd like to improve how tooltips work, to give better control to developers on how they're drawn on the screen.

For example, right now, I'm trying to make an entity that is a cross between an Arithmetic Combinator, and a Constant Combinator. It has Inputs, and based on some data, it will have different outputs depending on what is happening. Right now, with everyone that I've talked to, there is no way to currently show custom "Ouput Signals:" in the overlay/tooltip on entity hover.

Thinking about this for a while, I think the best way IMO is to create an overridable function that will return values for custom entities. There are a few ways to go about doing this:

1. get_tooltip_blocks() // Returns something similar to:

Code: Select all

{
  block_type: 'electricity',
  label: 'Electricity'
}
{
  block_type: 'wire_reach',
  label: 'Wire reach'
}
{
  block_type: 'simple',
  name: 'Testing',
  value: 'Some random value'
}
{
  block_type: 'signal',
  label: 'Input Signals:',
  signals: [] // Array of signals
}
When the game goes to show the tooltip, we check to see if there is an override to the tooltip on the entity. If there is, call the function, build the tooltip blocks that way, otherwise revert back to the default behavior. Maybe for performance, we call a `register_custom_tooltip`, so that we don't have to see if the function exists on every entity, each hover. (It would also be helpful to provide the existing blocks that are generated based on the entity so we can simply modify one block)

2. An alternate would be to provide an override to specific functionality regarding tooltip generation. For example, for combinators, it would be nice to have a `get_signals_for_tooltip()` function that let's us override what the user sees.

IDK, there may be some better solutions, these were just the few that I came up with.

Koub
Global Moderator
Global Moderator
Posts: 7226
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: Tooltips: A better way to modify them via modding

Post by Koub »

[Koub] Moved to Modding Interface Requests
Koub - Please consider English is not my native language.

Heinermann
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed Jul 21, 2021 11:01 am
Contact:

Re: Tooltips: A better way to modify them via modding

Post by Heinermann »

I would like a way to add arbitrary text to the end of tooltips (for example a mod-specific status effect or displaying custom dynamic stats).

Moreso as some field that just gets appended or something would be enough for me.

Post Reply

Return to “Modding interface requests”