The one line...

There is a single array line in all of DS-cadia that does not behave like the typical array lines. Variable arrays store both the x and y coordinates of the entry in question, and when placed in a variable, copies both x and y coordinates with it. Normally, the coordinates are not treated like separate entries, but the following line is special:

(5:390) starting with entry #, set # entries in array # to #.

This line sets coordinate specific entries. In our previous array %Jukebox, we would have to declare entries 0, 2, 4, 6, and 8 to store the same data line (5:311) did since this line only stores half the array value. In reality, our %Jukebox array, if represented as a line of data would look like this:

4 0 72 0 2 0 34 0 16 0

As you can see, to properly use (5:390), you’d have to multiply the entry you’re trying to store by 2 if it's an X coordinate, or multiply by 2 then add 1 if you wanted to store a Y coordinate instead.

To further illustrate this concept, let's use a short example to compare how to store coordinates to arrays first using line (5:311) use variable # as an array, and set entry # of it to # and then again, using line (5:390) starting with entry #, set # entries in array # to #.

Let's say we're making DS for a boss fight in a roleplaying game, and we want her (the boss) to periodically teleport to 1 of 4 specific locations on the map. We want to avoid using multiple triggers for her just to select a location to teleport to, so a viable option would be to use arrays to store those coordinates, and then have her select 1 of the entries from the array as the place for her to teleport.

For this short demonstration, we'll be using these coordinates: (14,38), (24,30), (20,47), and (34,30).

Storing coordinates with (5:311)

While it's not possible to directly set the .y coordinate using the (5:311) line, we can use a temporary variable to store both the X Y coordinates, and then feed it directly in. A trigger setting these values would look like this:

(0:0) When everything is starting up,
(5:384) set variable %temp_var to the x,y position (14,38).
(5:311) use variable %Boss_Tele_Locs[4] as an array, and set entry 0 of it to %temp_var.
(5:384) set variable %temp_var to the x,y position (24,30).
(5:311) use variable %Boss_Tele_Locs[4] as an array, and set entry 1 of it to %temp_var.
(5:384) set variable %temp_var to the x,y position (20,47).
(5:311) use variable %Boss_Tele_Locs[4] as an array, and set entry 2 of it to %temp_var.
(5:384) set variable %temp_var to the x,y position (34,30).
(5:311) use variable %Boss_Tele_Locs[4] as an array, and set entry 3 of it to %temp_var.
Storing coordinates with (5:390)

One the other hand, the (5:390) implementation will initialize the array with the exact values as shown in the previous block. That would look something like this:

(0:0) When everything is starting up,
(5:390) starting with entry 0, set 1 entries in array %Boss_Tele_Locs[4] to 14.
(5:390) starting with entry 1, set 1 entries in array %Boss_Tele_Locs[4] to 38.
(5:390) starting with entry 2, set 1 entries in array %Boss_Tele_Locs[4] to 24.
(5:390) starting with entry 3, set 1 entries in array %Boss_Tele_Locs[4] to 30.
(5:390) starting with entry 4, set 1 entries in array %Boss_Tele_Locs[4] to 20.
(5:390) starting with entry 5, set 1 entries in array %Boss_Tele_Locs[4] to 47.
(5:390) starting with entry 6, set 1 entries in array %Boss_Tele_Locs[4] to 34.
(5:390) starting with entry 7, set 1 entries in array %Boss_Tele_Locs[4] to 30.
Examining both methods

As you can see from those two triggers, while the line usage is similar, how the entry values of the arrays are handled is completely different. But one way we can verify that those two blocks of DS are setting the same data, is for us use a trigger that will display all the values in the array, like so:

(0:31) When someone says {View Boss Tele Array},
(5:310) use variable %Boss_Tele_Locs[4] as an array, and copy entry 0 of it into variable %temp_var.
(5:200) emit message {Boss location entry 0; %temp_var.x, %temp_var.y} to the triggering furre.
(5:310) use variable %Boss_Tele_Locs[4] as an array, and copy entry 1 of it into variable %temp_var.
(5:200) emit message {Boss location entry 1; %temp_var.x, %temp_var.y} to the triggering furre.
(5:310) use variable %Boss_Tele_Locs[4] as an array, and copy entry 2 of it into variable %temp_var.
(5:200) emit message {Boss location entry 2; %temp_var.x, %temp_var.y} to the triggering furre.
(5:310) use variable %Boss_Tele_Locs[4] as an array, and copy entry 3 of it into variable %temp_var.
(5:200) emit message {Boss location entry 3; %temp_var.x, %temp_var.y} to the triggering furre.

If this command is said in game, the player would see see the following:

Boss location entry 0; 14, 38

Boss location entry 1; 24, 30

Boss location entry 2; 20, 47

Boss location entry 3; 34, 30

So, if there's anything to take away from this bit of info, it's to avoid using line (5:390) wherever possible for the sake of keeping the array entries consistent, and to minimize complication if you intend to change those entries later on in the code.

Account E-Mail

Password