On the matter of display panels...
Posted: Wed Nov 06, 2024 5:21 pm
Creating display panels from code is a bit cumbersome right now:
Therefore I kindly request that display panels can be updated to show their message from code instead of the workaround, or possibly already do it without a call to an update function. It seems there is no way to set "Always show" and "Show in chart" flags in the api, so add that aswell, please. Finally, "Always show" is a bit counter-intuitive since alt-mode needs to be enabled for it to work. So I would suggest either making alt-mode toggleable by code, or really "always show" the first line, if the flag is enabled.
Code: Select all
local display_panel = surface.create_entity{
name = "display-panel",
position = {-2, -3},
force = player.force
}
display_panel.get_or_create_control_behavior().set_message(1, {
icon = { type = "item", name = "coal" },
text = "Test",
condition = {
fulfilled = true, -- not sure why this does nothing
first_signal = {type="item", name="raw-fish"},
comparator = "=",
second_signal = {type="item", name="raw-fish"}
}
})
-- workaround: since the display panel doesn't show anything, connect it to a circuit network, and disconnect it immediately after, to give it an update
local a = some_other_required_entity_with_circuit_connection_ability.get_wire_connector(defines.wire_connector_id.circuit_red, true)
local b = display_panel.get_wire_connector(defines.wire_connector_id.circuit_red, false)
a.connect_to(b, false, defines.wire_origin.script)
a.disconnect_from(b) -- not really necessary since wire_origin.script disables drawing the wire already