Unexpected behaviour with deleting automation?

A slightly unexpected behaviour when deleting the automation in the selected pattern track:

-make a song with two patterns --(Important so that some automation is left on other pattern )

-automate e.g. volume on selected track over the two patterns you created.

-run the following code in testpad and you would expect the selected_track_parameter.value to be set to the default value (0dB again for volume) --line 14

for some reasons you have to run the code twice for this line to work?

Am I missing something here or is it a bug/ expected unusual behaviour?

local song = renoise.song()
--get current automation
local automation = song.selected_pattern_track:find_automation(song.selected_track_parameter)

--delete pattern_track automation
if automation ~= nil then --if nil there is none in this pattern_track

--set DSP slider to default value 
song.selected_track_parameter.value = song.selected_track_parameter.value_default


Volume Automation over two patterns before code is run:

5830 auto delete lua bug 1.PNG

DSP lane after code is run: Volume should be at 0dB? :

5831 delete bug lua 2.PNG

When deleting automation, the player will apply “automation following” shorty after the automation for deleted. Same thing that happens when you start playing back the song at pattern 0.

So your “song.selected_track_parameter.value = song.selected_track_parameter.value_default” gets overwritten by that.

That behavior maybe is not really obvious, but I think it makes sense. Starting playback would anyway reset the parameter value change.

I see, the problem I had was wanting to delete all automation pattern by pattern and then reset the parameter.value at the end. I can work around this now I know whats going on; probably with a timer.

edit: probably wasn`t that scenario causing the prob-- too much Lua recently.