Reference Elements, CE values and CE scores explained

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

Moderators: Flumminator, Zomis

Post Reply
User avatar
Holger
Site Admin
Posts: 4178
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Reference Elements, CE values and CE scores explained

Post by Holger »

In this post, Lee Brewer asked about "Reference Elements":
Also...has there ever been a finished instruction manual posted (since I have been away from the forum for awhile) that makes a simple explanation of using CE values and other things like the ref section of the game editor?
So what are CE values and what are "reference elements" (which can be found in the "REF" section of the level editor's element palette)?

CE value and CE score

The CE score

Well, CE score is a value that can be configured when selecting a custom element (also called "CE" here), pressing the "Properties" button and then selecting the "Config 1" tab on the left: The default value for each CE is "10", just like for many other game elements (which are not custom elements). When setting the CE to "collectible", this value is added to the score when collecting this CE in the game. The CE score is unique for each custom element, but not for each instance of a custom element. What does this mean?

Well, if you have "custom element 1" (graphically displayed as some sort of wall with a "001" on it) with CE score "10", and place three of these elements in the level playfield, they will all have the same CE score of "10". That's no big surprise. But what happens if you set that CE to "can fall" and add a change condition (on the "Change" tab) to set the CE score to "100" after/when "impact (on something)"? The CE score will change to "100" instead of "10" if you let one of those three CEs fall down a few tiles. Collecting any (or all) of these three CEs will then increase the score by 100, not only when collecting the one CE that fell down. Changing the CE score will change it for all CEs of that kind (that is, with the same number, which is "001" in this example).

The CE value

With CE values, things are a bit different: Each of several instances of the same CE in the game has its own, unique CE value. Using the same example as above, but with CE value instead of CE score, will only change the CE value for those CEs that fall down, but keep the CE value of all other (same) CEs untouched. (However, collecting them won't add the CE value to the game score, as it is not treated as a "score" value, but this could be added with some additional CE conditions if required.)

Conclusion: Use "CE score" if you want to store values for all CEs of the same kind, and use "CE value" if you want to store values for each individual instance of a CE on the playfield.

And as a side note: You can not only store numbers as CE scores or CE values, but also (the internal numbers of) game elements, which you can then use later to re-create game elements from. Just use CE action "Set CE value" or "Set CE score" with action operator "=" and an action parameter under "[element]" (like "target", "trigger" or "action ->", with the latter specifying an explicit game element, while "target" and "trigger" are related to the "target element" or the "trigger element" used on that CE change page).

The "CE value" and "CE score" fields can be used for complex and tricky "CE programming", but within this post, only a few simple uses will be demonstrated.

Reference Elements

"Reference elements" are those elements that are listed in the "REF" section of the editor's element palette, and they can be used to refer to other game elements when creating CE changes.

The demo level set attached to this post will demonstrate most of them, and each level has an envelope with a short description of the reference element shown in that level. Here are some additional descriptions of these demo levels:

Level 1: Reference element "Element triggering change"

This level has a custom element with a rock, an emerald and a diamond above it. Any element that falls onto this CE triggers a change of that CE to a 3x3 block of this element. This is done by simply using the reference element with the name "Element triggering change" in the CE's change page that refers to the element that was causing (triggering) the CE change. More precisely, this reference element is used in the "extended change target" of that CE's change page to create not only a single new game element instead of that CE, but a whole 3x3 block (with 9 new game elements) at the previous CE's position (but requiring playfield tiles to be empty to create the new game element at the 3x3 block's playfield positions).

Level 2: Reference element "Player triggering change"

The second demo level nearly does the same, but not with game elements falling on a CE, but players touching a certain other (non-CE) game element. The CE in this level is then triggered by any player touching that other game element (the one with a traffic sign on it) and, as a result, changes to itself plus the player that has touched that other game element.

So we effectively used two reference elements here (in the "extended change target" area of the change page of this CE): The "self" reference element (named "the current custom element"), which just replicated the same custom element again, and the "player triggering change" reference element, which is used to add the player that triggered the change (therefore effectively teleporting that player to the new playfield position).

All this could indeed have been done without any reference element: Instead of the "self" reference element, the "custom element 1" could have been used. And instead of using the "player triggering change" reference element, four separate change pages could have been used, with player 1 to 4 who touched the other game element, and player 1 to 4 who will be created in the corresponding extended change target area. So, using reference elements just makes things a lot easier here.

Level 3: Reference element "CE value of element triggering change"

This level has two different custom elements: One ("001") that can "consume" things that fall on it (gems in this case), where "consume" means "remove that game element and store its element number in the CE value of this CE". The other CE ("002") can "produce" things, where "produce" means that a game element that falls on it will be removed, and its CE value will be taken as the element number of a game element that will be created three times at the bottom of the producing CE (which obviously only works with custom elements). To do this, the reference element "CE value of element triggering change" is used in the extended change target, to use the CE value of the CE that was falling onto it.

That way, all three different gems can be "stored" in the CEs below them (by just letting them fall onto them), which can then be pushed to fall onto CE "002", which re-creates those gems again. Especially, this shows clearly that each CE has its own, individual CE value.

Level 4: Reference element "CE score of element triggering change"

This level looks just like the previous level, and indeed they are nearly identical -- with one difference: Instead of the CE value, the CE score is used here. The CE score is not a value that individually exists for each CE on the playfield, but is the same for all same CEs (with the same number). Therefore, only one value can be stored for all three CEs of type "001" in this level. Which means that the last gem that was falling on any CE "001" is stored for all those CEs. Pushing those CEs onto CE "002" therefore always produces the same gem.

Level 5: Reference element "CE value of current element"

In this level, the CE that "consumes" the gems is the same as the one that "produces" them. Again, it stores the falling gem's element number in its CE value and produces that gem again if a rock falls onto it. To make this happen, it uses the reference element "CE value of current element" in this case, because it has to access its own CE value (and not the one of another CE that was triggering the change).

There is another custom element configuration setting required to make this work: On tab "Config 1", the checkbox for "use last CE value after change" has to be checked. This is needed to keep the CE value when the CE changes -- without this setting, the CE would re-initialize its CE value after each change, and would therefore "forget" the game element stored in its CE value.

Level 6: Reference element "CE x positions earlier or later in list"

These special reference elements just refer to those CEs that have a game element number that is by X lower (earlier in the list of CEs) or higher (later in the list of CEs) that the current CE (with "X" being in the range of "-8, ..., -1, +1, ..., +8"). So you can reference up to eight CEs earlier or later than the current CEs position in the element list.

What is this good for? Look at the level: There are four different keys and four different closed (unwalkable) doors, which can be changed to four different open (walkable) doors when collecting the key with the same color.

Creating all four keys and doors (which are 12 CEs overall) would be boring and error prone, as all four keys and doors are technically identical. Instead, just create a single key (one CE) and a single door (two CEs), but do not refer to the corresponding key CE directly when creating the change page (to let the door change from "closed" to "open" when collecting the key), but use a reference element that points to the matching relative CE position for the key CE (which is "-4" in this case) and for the second door CE in "open" state (which is "+4" in this case). (For the key, the setting "CE count" on tab "Config 1" was set to 0 to not let the key count like an emerald when collecting it.)

When done, just copy all three CEs three times, making sure that the new CEs have the same distance in the list of CEs as the old ones. When done, you have the final set of four keys and eight door CEs, which you can decorate now to give them different colors (by either using custom graphics or the CE setting "use graphics of element" on tab "Config 1", which was used in this level). That way, creating several similar, interacting CEs is much faster than editing them all manually, and you cannot accidently forget some setting or checkbox here and there.

You can download the whole demo level set below, together with all solution tapes.
Attachments
demo_levels.zip
(9.31 KiB) Downloaded 312 times
User avatar
Lee Brewer
Posts: 78
Joined: Tue Jul 25, 2006 2:53 am

Re: Reference Elements, CE values and CE scores explained

Post by Lee Brewer »

THis is a great start, but I admit I only got to example 3 before realizing I was not understanding. Here is you explanation and my anaylsis as I tried to reason it all out:
Level 3: Reference element "CE value of element triggering change"

This level has two different custom elements: One ("001") that can "consume" things that fall on it (gems in this case), where "consume" means "remove that game element and store its element number in the CE value of this CE". The other CE ("002") can "produce" things, where "produce" means that a game element that falls on it will be removed, and its CE value will be taken as the element number of a game element that will be created three times at the bottom of the producing CE (which obviously only works with custom elements). To do this, the reference element "CE value of element triggering change" is used in the extended change target, to use the CE value of the CE that was falling onto it.

That way, all three different gems can be "stored" in the CEs below them (by just letting them fall onto them), which can then be pushed to fall onto CE "002", which re-creates those gems again. Especially, this shows clearly that each CE has its own, individual CE value.



I give up! I just spent an hour or more trying to figure out why 003 is used in example 3 at all.

Could you, step by step, go through the actual mechanics of the way the program is "thinking?"

For example, I understand that when we drop the blue diamond (REF ✱) onto 001, that 001 turns into itself with 003 on top.
Image 8-21-23 at 7.11 PM.jpg
Image 8-21-23 at 7.11 PM.jpg (47.71 KiB) Viewed 9687 times


Then 003 disappears after [CD DELAY] of 10.
Image 8-21-23 at 7.12 PM.jpg
Image 8-21-23 at 7.12 PM.jpg (22.88 KiB) Viewed 9687 times
Image 8-21-23 at 7.11 PM.jpg
Image 8-21-23 at 7.11 PM.jpg (47.71 KiB) Viewed 9687 times
But does {CE DELAY} mean there is a universal CE value being changed every second the program is running, and after a change of 10 CE "units" (for lack of better term) the system triggers 003 to disappear?

Now back to the 001 config page. At the bottom we have:
:
Image 8-21-23 at 7.12 PM.jpg
Image 8-21-23 at 7.12 PM.jpg (22.88 KiB) Viewed 9687 times
OK, so now the CE value is what the trigger was.

Does this mean that another universal CE value is set to the CE value of the diamond? It cannot be the same CE value as the one that was changing to make 003 disappear.

I will not go any further here because I already know I do not understand enough to try and interpret the 002 configuration page from the standpoint of trying to figure out how the CE values are set and stored. I believe I understand the CV REF element, but 003 is again involved for some reason.

My best guess is somehow 003 is used as an nscreen representation of where the CE value is being stored and that every program defined element (not CE) has its own unique CE value so it can be referenced. But presently I have spent enough time on this my mind is about as useless as a certain usuper in DC. LOL!
Lee

WWII was fought against fascism, communism, and socialism - so what happened? "Sorry" to vets just does not cover it.
User avatar
Holger
Site Admin
Posts: 4178
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: Reference Elements, CE values and CE scores explained

Post by Holger »

Hi Lee, I will try to explain things a bit different, using your questions and the example level 3.
Could you, step by step, go through the actual mechanics of the way the program is "thinking?"
Sure! I will describe in detail what's going on in level 3.
I give up! I just spent an hour or more trying to figure out why 003 is used in example 3 at all.
This one (custom element 003) is in fact quite simple and has not much to do with the remaining CE trickery -- it's just an element to remove the gem elements that falls on custom element 001! (A detailed explanation of how this works will follow!)
For example, I understand that when we drop the blue diamond (REF ✱) onto 001, that 001 turns into itself with 003 on top.
That's right -- and it works as follows:

Let's have a look at the left CE 001. That's the one with the green emerald on top of it, with a sand tile in between. The player removes that sand, and the emerald falls down, hitting CE 001. Look at the tab "change" of CE 001:

There's the following "rules":

1.: [x] element changes to: [ ] after/when:
2.: [x] [hit by] element [<this element matches any element>]
3.: [x] use extended change target: (see below)
4.: [x] [set ce value][=][trigger element]

That means the following:

This CE 001 can change to something else when some condition is fulfilled. That condition is "when hit by a certain element". But in this case, it is not a specific element, but a reference element that means "when hit by ANY element", so this condition is fulfilled when any element hits CE 001, which is the case here (as CE 001 is hit by the green emerald).

But it does not change to empty space (as configured in the first "rule"), but to an "extended change target" (as defined by "rule" number 3). That "extended change target" is an area of size 3 x 3 game elements. In the middle is the "self" reference element, which simply means "CE 001" here. We could also have used "CE 001" directly, and it would work the same. All other eight elements that are surrounding the middle element could be empty, but that would not help here, as "empty" means "do not replace this element" here.

Therefore, to remove the green emerald that just hit CE 001, we need a temporary element that really removes it. We use CE 003, which we gave the "X" graphic so we can see it. We put it on top of the "self" element, so it will be placed at the same position where the green emerald is when it has hit CE 001. We use "replace when [collectible]" (which is the case for the green emerald) so it will really replace it. But we want to remove the emerald, and do not want to have that "X" CE instead. Well, that's quite simple!

Look at "CE 003", on tab "change": It has these simple "rules":

1.: [x] element changes to: [ ] after/when:
2.: [x] CE delay [10] / delay given in frames

So what does it do? It just waits for 10 game frames (which is 0.2 seconds, as one game frame is 1/50 second) and then just changes to empty space. That is, it simply disappears after 0.2 seconds. That's all!

We could also have used an empy space graphic for CE 003, so the green emerald would look like immediately disappearing, but to see what's going on I used that "X" graphic so we can see how the emerald is being removed by the "extended change target" of CE 001.

BTW: The "X" graphic is defined on the "config 1" tab of CE 003, as follows:

1.: [x] use graphic of element: [X]

Conclusion: CE 003 is just used in this level set to remove another element by "overwriting" it with an "X" element that disappears quickly afterwards. It does not store anything at all, but just turns to empty space after 0.2 seconds and is gone.

There's one "rule" in CE 001 left that we haven't covered, and that's rule number 4. It simply does the following:

It takes the element that was triggering the change of CE 001 (that is, the green emerald that hit it), and sets the CE value of CE 001 to the element number of the green emerald (which is called the "trigger element" here, as it triggered the change). So, as a result, CE 001 now has a CE value that has the (internal) element number of the green emerald!

The CE value of a custom element is just a number that is stored together with this custom element (and each custom element of type "CE 001" has its own CE value, so all three instances of "CE 001" can store a different number.)

Now we have CE 002. We drop our CE 001 (with the CE value that is the element number of the emerald) onto it! And it also changes to itself plus something more. First of all, it also removes what just hit it on top of it, by using that "X" styled CE 003 again. This removes CE 001, and it is gone.

Then, below of CE 002 (again by using the "self" element which could also have been just CE 002 directly), three same elements are created, using element "CE value of element triggering change". And that's what happens: The game engine takes the CE value of the element (CE 001) that triggered the change of CE 002 (because it hit it), and transforms it into a game element again. As that CE value has a number that represents a green emerald, exactly that element is created, three times, just below CE 002 which still sits there, waiting for the next CE that falls onto it.

This explanation was quite lengthy, but I hope that it was maybe a bit easier to understand (even though it's probably still a bit complex what's going on with all those custom elements, and with all those "rules")!

Please let me know it you have any further questions, and I will be happy to explain in more detail! :-)
User avatar
Lee Brewer
Posts: 78
Joined: Tue Jul 25, 2006 2:53 am

Re: Reference Elements, CE values and CE scores explained

Post by Lee Brewer »

Thanks for all of this...finally getting life out of the way to go back through this and learn!
I give up! I just spent an hour or more trying to figure out why 003 is used in example 3 at all.
This one (custom element 003) is in fact quite simple and has not much to do with the remaining CE trickery -- it's just an element to remove the gem elements that falls on custom element 001! (A detailed explanation of how this works will follow!)
Gotcha...as soon as I read that I was kicking myself for not recognizing it! In the past I had encountered needing what my mind calls a "forced empty space" to replace something when using the extended change target option. I do not remember how I handled it. This obvious fix for the situation does not seem familiar to me though. I think I found another work around, but that is buried in a lot of levels someplace!

Was planning on going over more notes you made, but oncoming migrain says otherwise. One mystery solved - thanks...will review the next part later.
Lee

WWII was fought against fascism, communism, and socialism - so what happened? "Sorry" to vets just does not cover it.
User avatar
Lee Brewer
Posts: 78
Joined: Tue Jul 25, 2006 2:53 am

Re: Reference Elements, CE values and CE scores explained

Post by Lee Brewer »

OK...got through the rest of them and they make sense. Thanks a lot for these examples.

I have used other work arounds for the transporter concept you made with the player triggering CE and the "self" CE using two different CEs (let's use 001 and 002).

Instead of using the REF elements, I just used the player and the actual CE. So when the player enters 001 it triggers 002 to change into itself (002) and the player. When a player enters 002 then 001 changes into itself (001) and the player. I am sure there are ways of using the REF elements you showed that I have not though about yet so know these will be useful.

To make different game elements be referenced to be pulled into the game I have used GEs to make an "array" of elements out of which each array member is sequentially or randomly placed into gameplay.

But those arrays cannot be added to during gameplay. So setting the CE value equal to something during gameplay gives a new option I have not used. I need to think about this and explore it!

I wish I had known about the "wildcard" element long ago! For example, if I have a CE I want to be able to dig everything, I used a GE with 16 elements in it the CE could dig. If I needed more than 16, I put a second GE inside the first one's group of elements. It is tedious filling those arrays with all of the other elements!

Thanks again!
Lee

WWII was fought against fascism, communism, and socialism - so what happened? "Sorry" to vets just does not cover it.
User avatar
Holger
Site Admin
Posts: 4178
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: Reference Elements, CE values and CE scores explained

Post by Holger »

Thanks for your feedback, Lee! I'm happy to know that it makes sense now! :-)
User avatar
Arno
Posts: 7
Joined: Thu Feb 10, 2022 1:10 pm

Re: Reference Elements, CE values and CE scores explained

Post by Arno »

With this information, I'll be able to remake Chip's Challenge!
Post Reply