Page 1 of 1

Speaker alert_message is read only?

Posted: Sat May 14, 2022 9:49 pm
by WildBraas
I read an api and discovered that alert_aprameters is [Read/Write].
But alert_message do not change:

Code: Select all

function on_gui_closed(event)
	if event.entity.name == "programmable-speaker" then
		event.entity.alert_parameters.alert_message = "+"
		log(serpent.block(event.entity.alert_parameters))
	end
end
script.on_event(defines.events.on_gui_closed, on_gui_closed)
log gives me old value.
What I doing wrong?

Re: Speaker alert_message is read only?

Posted: Sun May 15, 2022 1:31 am
by DaveMcW
You have to write the table back to entity.alert_parameters.

Code: Select all

local parameters = event.entity.alert_parameters
parameters.alert_message = "+"
event.entity.alert_parameters = parameters

Re: Speaker alert_message is read only?

Posted: Sun May 15, 2022 5:07 am
by WildBraas
Thank you