PDA

View Full Version : Loops within loops



Rob H
February 5th, 2005, 01:05 PM
Ben (or anyone else),

Is there a way of supporting a looped frame within another looped frame so that you can still access both loop indexes from e.g. a bit of lua code?

The reason I want this is to be able to support a star rating for each DVD in LDJ, but I'm sure there would be other applications.

JLee's CCF has this code for a star button which is located in a looped frame :-

STATE:LUA:
val = NetRemote.GetVariable('MP.Rating');
if (val == '') then
return 0;
end;
return tonumber&#40;val&#41;>=<LoopIndex>;


Which is fine for a single cover, but I would want this to work on a DVD cover which is already in a loop.

I don't think this is currently possible in NR, but I think it would be useful. Something like a function outer() which would return the LoopIndex from the outer scope might be a way to do this - alternatively some form of subcripting on LoopIndex. I prefer the use of outer() since it would work even if the containing loop were placed inside yet another loop.

I have a feeling that the interim solution is going to be to have a bit of lua that sets the image to one of a selection of images each of which has an extra star in it.

Ben S
February 7th, 2005, 06:19 PM
Interesting thought. You'd have to define levels of loops. This is one I'll have to ponder for a bit and come up with a strategy that works everywhere (loops within loops within loops within loops).

PS. I recognize that lua! :)

Rob H
February 7th, 2005, 06:22 PM
I think the outer() function would do just that wouldn't it. You could use outer(outer(LoopIndex)) to go up two levels.

It would still work if you pasted a looped frame inside another looped frame.

Of course, that's from the user side. The NR internals might be a bit more complicated :)

Rob H
April 16th, 2005, 03:25 PM
Have you had a chance to ponder this at all yet Ben?

Ben S
April 17th, 2005, 02:05 PM
A bit, but nothing up my sleeve yet. I have found a few things I'd also like to do with this, so it will get some cycles this week.