Locating nth instance of an element

All about creating levels and level sets, custom elements and custom artwork.

Moderators: Flumminator, Zomis

Post Reply
Tomi
Posts: 339
Joined: Wed Aug 03, 2005 3:37 pm
Location: Slovakia

Locating nth instance of an element

Post by Tomi »

I need this technique for a levelset I'm working on. I wonder if anyone was able to do this before?

The level looks like this: it's filled with steel walls. In the middle, there's a big (almost) empty area. It's named "main area". It contains some letters/walls/... and some CE1-s. If this helps you, they're in rows, separated by empty rows, like this:





There are also some other things in the level, but they're not important. CE1s are only in the main area.

In another, smaller level area ("number area"), there is a number ("n"). And I need to locate n-th CE1 in big area and change it into CE2. (n doesn't need to be stored as a text. If you'd like, it may be stored also as CE value or whatever, but if possible, it should work on current stable version.)

Pretty impossible, huh?
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Post by Holger »

> it may be stored also as CE value or whatever, but if possible, it should
> work on current stable version

No help (sorry!), but a little clarification:

The current stable version is 3.1.2 and does not yet contain the "CE value" concept. (I think you know this, and would want it only as a "last resort" solution. I rather wanted to make this clear for others who read this sentence.)
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

Re: Locating nth instance of an element

Post by Zomis »

Tomi wrote:Pretty impossible, huh?
Not at all impossible. But a question: Am I allowed to use a temporary CE (like CE3) for use until I've found the n-th CE, and then change all the CE3s back to CE1? If so, then it would probably be very easy - both with and without "CE values". If without then I'd need a "counter - 1" CE (which is easy to create, I know).

My idea:
CE1.page1 changes to CE3 when <machine start>
CE1.page2 changes to CE1 when change by CE1 page 1
Decrease counter when change by CE1 page 1

CE1.page3 changes to CE2 when counter = 0
CE3.page1 changes to CE1 when counter = 0

Haven't tested this yet, but I believe it should work perfectly.
If you need, I can implement this on an example level and give it to you.
Tomi
Posts: 339
Joined: Wed Aug 03, 2005 3:37 pm
Location: Slovakia

Post by Tomi »

You may use as many CEs as you need.

> Haven't tested this yet, but I believe it should work perfectly.
I hope it will! As always, this isn't the only problem with the levelset, but this one really *should* get released!

> If you need, I can implement this on an example level and give it to you.
I'd like it this way.

Normally, there should be just about 10 CE1s, but sometimes there may be up to 50 CE1s and in extreme and rare cases there may be even 100 of them. (Or more?)
One more thing: It should be as fast as possible. At least in normal cases (with less than 20 CE1s). Generally, it should take max 50 frames, but it's not needed. What I need most is functionality (= if it works), speed is secondary.
Tomi
Posts: 339
Joined: Wed Aug 03, 2005 3:37 pm
Location: Slovakia

Post by Tomi »

I've tried to test it, and it doesn't work. The problem is that it actually decreases the counter just once - because the ce1.page1 activates just once, at the beginning (aka machine start). It needs some more tweaks, but I wasn't able to repair it properly.
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

Post by Zomis »

Yeah, I forgot to mention that the value should continue to be decreased every time the machine is running... But I've encountered other problems, but I hope those can be fixed...
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

Post by Zomis »

Ok, here we go: http://www.zomis.net/rnd/info.php?f=431
Built with 3.2.0-6 but should also work in 3.1.1

The only little bug is that the first element is counted as 0, making it impossible to "select". That could be fixed using a workaround somehow, just haven't felt like implementing it :) (you wanna do something yourself, eh? ;))

It could probably be made much easier when the next version comes out (with a "change when change action by page of"-condition comes, I think it was coming in the next version...). I had some problems making it with CE value so I chose a "good old" counter.
5 CEs required. And some space :)

What do you think, is it fast enough? ;) :D
Daniel H.
Posts: 535
Joined: Sun Apr 02, 2006 7:13 pm
Location: USA

Post by Daniel H. »

I realize that I am reviving a very old topic here, but does anybody know of a way to solve this problem (locating the nth instance of a custom element) using R'n'D 3.2.6.x or newer?
The H. World levelset can be downloaded from http://www.bd-fans.com/RnD.html -- search The H. World on that page.
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

Post by Zomis »

Does the solution I mentioned above work?
And if it does, I guess you want it done without using that extra space, huh?

Under what conditions do you want it to work, is it ok if the CEs change to other CEs and then back or should they always remain the same, how should the located CE be marked, how much space is allowed to be used, etc?

There might be better ways of doing this now than it was 4 years ago :)
Post Reply