Page 1 of 1

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

Posted: Fri Nov 29, 2024 1:23 am
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 289 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 ... )

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

Posted: Fri Nov 29, 2024 9:32 pm
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,
    },
}

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

Posted: Sat Nov 30, 2024 1:19 am
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. :-)