Edit_Pos Gets But Won`t Set

typing and executing the following into testpad will not do anything to the current edit position

renoise.song().transport.edit_pos.line = 3  

I can get the current position fine with:

print(renoise.song().transport.edit_pos.line)  

slightly baffled as I see Vv has used this in his custom shortcuts script, so its not read only?

any help appreciated

try:
local pos = renoise.song().transport.edit_pos
pos.line = 3
renoise.song().transport.edit_pos = pos

Thanks, it works

but the next question would be why does it not directly?

renoise.SongPos is an object. Not just a number?

Ok, I have to polish up a bit here then as I was just assuming due to syntax

i.e.

is a number

is an object?
Why then can pos.line in vVs example be set to three? is that not also an object or rather an object derrived from the original lua/renoise class?

Happy to do some reading if someone can point me in the right direction.

Ok thanks Bantai, I realise this is something then that has caught me out before aswell, not too intuitive as you say

guess there is a technical reason for this somewhere along the line.

It is just that with a lot of dynamic objects (I guess this all involves objects with values that are constantly changing and getting updated) these things have to be updated in a whole.
pos.line is one and pos.sequence is another (i believe), both values have to be updated at the same time so that Renoise really understands you correctly you want to skip to the specific line in that particular sequence.
Since Lua isn’t very quick, if you would do it in this order
renoise.song().transport.edit_pos.line = 3
renoise.song().transport.edit_pos.sequence = 5

Renoise first jumps to line 3 in the sequence it currently is and then perhaps one line later it jumps to sequence 5.

So by setting these values first in a forked object variable and then submit these back to the whole Renoise object, you get sure both line and sequence position gets updated at the same time.
I guess this explanation might make a lot more sense than voodoo worshipping.

I guess, if script blocks are executed in a broken up manner? I realise the audio processing is paramount in renoise for obvious reasons.

It is just unfortunate that the syntax is the same as for when variables are directly accessable. I`m sure it will become more second nature over time though

cheers

That’s true and i wrestled with the same problem at the beginning, but by keeping the former in mind, it has never been a problem since to work with these objects for me.

Good to air this out, got my edit_pos stuff working thanks to this thread

Bumped into this again and just wanted to throw this function up here that takes values for (pattern,track,line,column) and moves the cursor accordingly.

no bounds checking or default values but I may come back and edit later:

--------------------------------------  
--sets edit pos (no bounds checking)  
--------------------------------------  
local function set_edit_pos(pattern,track,line,column)  
  
 local song = renoise.song()  
 local pos = song.transport.edit_pos  
 pos.line = line  
 pos.sequence = pattern  
 --update pos object  
 song.transport.edit_pos = pos   
 --set the track  
 song.selected_track_index = track  
 --set the column --check new note column is visible and show it if not  
 if song.tracks[track].visible_note_columns < column then  
 song.tracks[track].visible_note_columns = column  
 end  
 --set the column  
 song.selected_note_column_index = column  
end