[2.0.23] Crash with sprite-button elem_tooltip and virtual signals

Place to report issues and suggest improvements to the API documentation.
User avatar
hgschmie
Inserter
Inserter
Posts: 48
Joined: Tue Feb 06, 2024 5:18 am
Contact:

[2.0.23] Crash with sprite-button elem_tooltip and virtual signals

Post by hgschmie »

Consider this code:

Code: Select all

local button = {
    type = "sprite-button",
    sprite = 'virtual-signal'/" .. signal_name,
    number = signal.count,
    tooltip = prototypes.virtual_signal[signal_name].localised_name,
    button.elem_tooltip = {
        type = 'signal',
        name = signal_name,
    },
}
crashes with
}}
Screenshot 2024-11-28 at 17.21.00.png
Screenshot 2024-11-28 at 17.21.00.png (45.25 KiB) Viewed 169 times
basically, it expects a "signal_type" key in the elem_tooltip element. Which is defined as an ElemID (https://lua-api.factorio.com/latest/con ... lemID.html) that has no such thing.

(I won't comment on the identity confusion of virtual signals, that are called 'virtual', 'signal' or 'virtual-signal' in various places of the API ... )
Rseding91
Factorio Staff
Factorio Staff
Posts: 14408
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.23] Crash with sprite-button elem_tooltip and virtual signals

Post by Rseding91 »

You are missing the signal_type value in the signal definition. Specifically this part:

Code: Select all

local button = {
    type = "sprite-button",
    sprite = 'virtual-signal'/" .. signal_name,
    number = signal.count,
    tooltip = prototypes.virtual_signal[signal_name].localised_name,
    button.elem_tooltip = {
        type = 'signal',
        signal_type = 'virtual', -- This value
        name = signal_name,
    },
}
If you want to get ahold of me I'm almost always on Discord.
User avatar
hgschmie
Inserter
Inserter
Posts: 48
Joined: Tue Feb 06, 2024 5:18 am
Contact:

Re: [2.0.23] Crash with sprite-button elem_tooltip and virtual signals

Post by hgschmie »

Hi,

Thanks for the quick reply! The "LuaGuiElement::elem_tooltip" field is define as an "ElemID", which is defined as having three elements: "type", "name" and optional "quality". There is no 'signal_type' on that definition.

I *know* that adding that line fixes it (see https://github.com/JasonLandbridge/Circ ... i.lua#L202). What I am saying that this is either needs to be updated/fixed in the docs. :-)
Post Reply

Return to “Documentation Improvement Requests”