Use of build-in tooltips
Use of build-in tooltips
Is there a way to call build-in tooltips from my mod - for example the one of recipes in crafting tab of character panel?
Re: Use of build-in tooltips
Not yet but I suggested it.
Re: Use of build-in tooltips
Cannot see how this will help me with my issue. Could you explain?Not yet but I suggested it.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Use of build-in tooltips
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Use of build-in tooltips
Can you please explain how choose-elem-button displays the detailed tooltips I get when I hover over a recipe in the crafting menu?Currently choose-elem-button is your only chance.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Use of build-in tooltips
Maybe you should start by stating what you're actually trying to do. I was assuming you're building a custom gui, for which choose-elem-button might (or might not) be a possible approach. Have you read the doc on LuaGuiElement.elem_type and elem_value?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Use of build-in tooltips
The Gui is like this:
the code is as follows (although the snippet probably doesn't say very much):
There are sprites and sprite-buttons of items, recipes and technologies. I can set guiElement.tooltip to some self-created localised string, but in case of recipes it would be very nice to present the tooltip factorio would present.
the code is as follows (although the snippet probably doesn't say very much):
Code: Select all
local function CreateSprite(frame, target)
local tooltip = target and target.HelperText
local sprite = target and target.SpriteName
local number = target and target.NumberOnSprite
local show_percent_for_small_numbers = target and target.UsePercentage
local style = Helper.SpriteStyleFromCode(target and target.SpriteStyle)
if target then
return frame.add {
type = "sprite-button",
tooltip = tooltip,
sprite = sprite,
number = number,
show_percent_for_small_numbers = show_percent_for_small_numbers,
style = style,
}
end
return frame.add {type = "sprite-button", style = style}
end
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Use of build-in tooltips
choose-elem-button shows tooltips automatically:ixu wrote: Thu Dec 03, 2020 10:51 am I can set guiElement.tooltip to some self-created localised string,
Code: Select all
/c
game.player.gui.center.clear()
local button = game.player.gui.center.add{type='choose-elem-button',elem_type='recipe'}
button.elem_value = 'iron-plate'
button.locked = true
- Attachments
-
- elem.png (97.37 KiB) Viewed 2395 times
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Use of build-in tooltips
That is quite cool. I missed it when I read the docu.
But actually this is not enough for my purpose.
1. This tooltip belongs to prototype. I need the one that belongs to the player (as in crafting-panel view)
2. Consequently, I would also like to have the number of objects that can be crafted displayed as a small number.
3. Since I allow a creation from my display, I would have liked to show it in the tooltip
Here is what I currently present: So, if I would have a free wish here, I would like a function LuaPlayer.get_recipe_tooltip(recipe) analogous to Function LuaControl.get_craftable_count(recipe)
But actually this is not enough for my purpose.
1. This tooltip belongs to prototype. I need the one that belongs to the player (as in crafting-panel view)
2. Consequently, I would also like to have the number of objects that can be crafted displayed as a small number.
3. Since I allow a creation from my display, I would have liked to show it in the tooltip
Here is what I currently present: So, if I would have a free wish here, I would like a function LuaPlayer.get_recipe_tooltip(recipe) analogous to Function LuaControl.get_craftable_count(recipe)
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Use of build-in tooltips
Like i said it's not a perfect solution, just a possible workaround. Showing the number can be partially faked by adding a label to the element button like it was done before LuaGuiElement.number existed. But getting the position correct is difficult if you want it in the right-bottom corner and want it to work on all gui scales.
Code: Select all
button.add{type='label',...}
No free wishes in this subforum, gotta go to the other one ;). Maybe you can convince someone to add .number support to choose-elem-button, but I'm not getting my hopes up.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Use of build-in tooltips
I was just kidding