[2.1.9] programmable speaker .alert_parameters.alert_message is read only?

Bugs that are actually features.
Icicubes
Long Handed Inserter
Long Handed Inserter
Posts: 57
Joined: Sun Jul 10, 2022 8:38 pm
Contact:

[2.1.9] programmable speaker .alert_parameters.alert_message is read only?

Post by Icicubes »

/c if game.player.selected then game.player.selected.alert_parameters.alert_message=game.player.selected.alert_parameters.alert_message.."what" end
The modding docs say this table is read and write, but at least this alert_message is read only (or broken) otherwise the command above would not silently fail for me (it doesn't change it).
Rseding91
Factorio Staff
Factorio Staff
Posts: 17210
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.1.9] programmable speaker .alert_parameters.alert_message is read only?

Post by Rseding91 »

You have to read the entire alert_parameters value into a local variable, modify what ever sub-values you want, then write the entire thing back in one go.
If you want to get ahold of me I'm almost always on Discord.
Icicubes
Long Handed Inserter
Long Handed Inserter
Posts: 57
Joined: Sun Jul 10, 2022 8:38 pm
Contact:

Re: [2.1.9] programmable speaker .alert_parameters.alert_message is read only?

Post by Icicubes »

That still didn't fix my issue. My game disagrees with you.
202607~1.JPG
202607~1.JPG (365.17 KiB) Viewed 153 times
robot256
Smart Inserter
Smart Inserter
Posts: 1422
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: [2.1.9] programmable speaker .alert_parameters.alert_message is read only?

Post by robot256 »

I can't read the script in your screenshot, it's too complicated. Try this script instead:

Code: Select all

/c game.print(serpent.block(game.player.selected.alert_parameters)); game.player.selected.alert_parameters = {alert_message = "Hello world", show_alert=true, show_on_map=true};  game.print(serpent.block(game.player.selected.alert_parameters))
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4694
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.1.9] programmable speaker .alert_parameters.alert_message is read only?

Post by boskid »

Your code is still bugged, you are setting alert_message on a copy.

Code: Select all

.alert_parameters.alert_message = 
is bugged. In a correct code there will be

Code: Select all

.alert_parameters =
somewhere
Post Reply

Return to “Not a bug”