i mean that if at start of script i do
while not get_mode() do
sleep(100)
end
it will not end, what you are saying is i probably first have to use something like
rec,vid,mode=get_mode()
while not mode do
No.
The values returned by get_mode are rec (is the camera in rec mode), video (is the current mode a video recording mode) and the mode number (a number, which in Lua is always true in a boolean context). In an expression like while get_mode() do, the first return value (rec in this case) is used and the others are discarded.
What you describe means that 'rec' stays false, meaning the camera is in playback under the conditions your script is running. If the logic of your script is trying to switch to rec, you need figure out why that is not working. Or if the camera actually switches to rec, there's some kind of bug in the port.
Note in chdkptp, you can easily see what get_mode does, by using
=return get_mode()