Code: Select all
for i = 1,10 do
vlc.volume.set(vlc.volume.get()+1)
print(vlc.volume.get())
print(" ")
end
However, this is my result: 1 1 2 2 3 3 4 4 5 5
On another occasion, I get a different result: 1 1 1 2 2 3 3 4 4 5
If I wait for a small amount of time between setting and getting however, I consistently get the expected result:
Code: Select all
for i = 1,10 do
vlc.volume.set(vlc.volume.get()+1)
vlc.misc.mwait(vlc.misc.mdate() + 2000)
print(vlc.volume.get())
print(" ")
end
Result: 1 2 3 4 5 6 7 8 9 10
If I wait for any less than 'vlc.misc.mdate() + 2000' then I occasionally print the same value twice.
I am running this code via the HTTP interface using VLC 3.0.8. I haven't tested but I assume this can be replicated with any vlc based get/set.
I assume this is a quirk of the system rather than a bug.
What is the correct way to check for updated values in a LUA script like the one above?