CE value help needed!

Stuck at a level? Need help with R'n'D or anything R'n'D related? Post here!

Moderators: Flumminator, Zomis

Post Reply
User avatar
Rockford4ever
Posts: 152
Joined: Tue Jan 03, 2006 7:41 pm
Location: Belgium

CE value help needed!

Post by Rockford4ever »

As the title says, I need help with CE values.
So, these are the settings:

Custom Element 1

Config 1
CE Value is 3 + random 0.
"Use last CE value after change" is checked.

Config 2
Nothing.

Change

Page 1
Element changes to CE1 when pressed by player;
CE action: Set CE value - 1

Page 2
Element changes to BD diamond when CE value get 0.


Now when I play the level, I expected the CE to change to a BD diamond after it is pressed by the player 3 times, but it doesn't!

Level file: Here.
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

Re: CE value help needed!

Post by Zomis »

Rockford4ever wrote:Element changes to CE1 when pressed by player;
CE action: Set CE value - 1
Uncheck the "change to" box and it will work. As it is for you now, the CE-value is resetted for you when you press the CE, since it changes to a new instance of the CE the value is set back to the default.
User avatar
Holger
Site Admin
Posts: 4081
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Post by Holger »

> Uncheck the "change to" box and it will work.

This is correct.

> As it is for you now, the CE-value is resetted for you when you press the
> CE, since it changes to a new instance of the CE the value is set back to
> the default.

This is NOT correct. ;-)

As Rockford4ever said, he has checked "Use last CE value after change", so the CE value is NOT reset after the CE change! The problem is a different one: Each time the player presses the CE, the CE changes (to itself). But remember: A CE can only change once per frame. So after it changed to itself, it cannot change anymore. So even when the condition on the second page is true ("CE value gets 0"), the CE cannot change anymore, so it never changes to a CD diamond.

Although Zomis' solution indeed works, it might be needed to have the CE really change to itself each time it is pressed (for example, to use the CE change as a trigger for another CE). This is possible: Use three CE pages, and put the "CE changes to itself when pressed by player" on that third page! Then it works like that:

1. "If player presses CE, subtract 1 from CE value."
2. "If CE value gets zero, change CE to BD diamond,"
3. "If player presses CE, change CE to itself."

As CE pages are handled sequentially, page 2 is handled before page 3, so it works as it should (the CE change on page 3 is ignored then, which is OK).

One last note: It is probably very hard to "press" a CE three times, as this is checked every frame! So you need to be able to press the CE for exactly one frame and release the key, which I doubt is possible at all. Better use "when switched by player" for this test, which requires to release the key and press it again for the next "switch event". Then you can see that you indeed have to press (well, switch) it three times before it changes to the diamond! (When using "when pressed by player", the CE will most probably change directly after you "press" it, as only 3 frames of pressing == 3 * 1/50 s == ~1/16 s pressing time are needed!)
User avatar
Rockford4ever
Posts: 152
Joined: Tue Jan 03, 2006 7:41 pm
Location: Belgium

Post by Rockford4ever »

Thanks, Zomis' solution works, but I dont get Holger's solution to work...
But I don't need that yet, this is all that I needed and I could use the "If CE value at zero of element" option for a trigger too! ;)
Thaks for the help anyways, now it really works. I've never used the CE values before, so I needed help. Forums are great ;)
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

Post by Zomis »

Rockford4ever wrote:Thanks, Zomis' solution works, but I dont get Holger's solution to work...
I suspect that has something to do with "change when ce value gets 0". I just ran into the same problem working with Locating n-th instance of element...
Post Reply