Plastic Gem #8: Auto Naming Marker
by Paul Dana · 06/18/2008 (8:10 am) · 0 comments
Download Code File

Plastic Gem # 8 : Auto Naming Marker
Difficulty: Easy
For a list of gems see the Gem A Day page.
Gem 8 from Plastic Games shows how to create an auto-naming marker shape that will use a default symbol and color of your choice. The idea is these shapes are nice and easy to work with in the mission editor. The symbol and color make them nice and visible and the number will reflect their name making it easier to know the marker name just by looking at it (even from far away). An example will make things more clear.
For example, let's pretend you want a marker to show where turrets will spawn in your game. You can create a marker datablock indicating you want a prefix of "TurretSpawn" and and a red circle as the symbol and color. This defines a placeable shape that will default to a red circle and will automatically create a name for this object of "TurretSpawn_1", unless that name is already used, in which case it uses "TurretSpawn_2". In any event the marker will show up as a red circle with the number reflecting the name of the object. This makes it super easy to look in the mission editor and see red circle with a 7 in it. You know you can refer to that as TurretSpawn_7 in your scripts.
You must follow the instructions in Gem #2, and Gem #5, and Gem #7 before you can use this resource, and if you are doing that you really should likely follow Gem #3 as well..
1) Unzipping the files
After following the instructions in Gem #2, Gem #5, Gem #6 (and optionally Gem #3), unzip the pg08_autoNamingMarker.zip file provided with this resource. Merge the files in the plastic folder from the .zip file with the plastic folder you created in Gem #5. There is a server folder with two file you need to copy to the server folder you created as part of Gem #5.
2) Executing the scripts
We need to execute the digitBillboard.cs file that you copied over. Edit the plastic/server/init.cs script that you copied over in Gem #5 and then altered in the previous gem, Gem #7. In the section that looks like this:
add the following two lines under the line that executes the digitBillboard.cs script:
3) A note on the SampleDigitMarker defined in digitMarker.cs
Now that we know the scripts will execute we can take a look at how the auto-naming DigitMarker is setup. The programmer simply has to create a static shape datatblock that extends DigitMarkerBase and fill in some info. The SampleDigitMarker defined in digitMarker.cs shows an example of this:

Note the $plasticRef symbol that is defined in Gem #5 which tells the scripts where to find the plastic folder. Note also that a SampleDigitMarker will use a green square for it's symbol. Since this datablock does not define a differnt auto numbering prefix to use, it will use the defaulf value of "Marker". When you place the first marker it should be named Marker_1. When you place the second it should be called Marker_2.
4) Placing an Auto-Naming Marker
Place a SampleDigitMarker in the mission editor using the same steps described in Gem #1: Placeable Shapes. Note that when you place a Smapl
5) Making your own Auto-Naming Marker
For an example of using your own auto numbering prefix, let's pretend you want a marker for where Turrets will spawn in your game. You would define a datablock like this in some file that is executed:

Note that this TurretSpawnMarker will use a red circle for it's symbol and "TurretSpawn" for it's auto numbering prefix to use. When you place the first marker it should be named TurretSpawn_1. When you place the second it should be called TurretSpawn_2.
The Next Gem
That's all for this gem. The next gem explains in greater detail how we use the marker shape to achieve what we call "Visual Editing" in our games. This refers to our ability to be in the mission editor and simply look at a marker, even across the map, and know from the color, symbol, and number, what that marker is for. It also gives an example of using the number to display a given value, for example the number of enemy zombies to spawn. :-)

Plastic Gem # 8 : Auto Naming Marker
Difficulty: Easy
For a list of gems see the Gem A Day page.
Gem 8 from Plastic Games shows how to create an auto-naming marker shape that will use a default symbol and color of your choice. The idea is these shapes are nice and easy to work with in the mission editor. The symbol and color make them nice and visible and the number will reflect their name making it easier to know the marker name just by looking at it (even from far away). An example will make things more clear.
For example, let's pretend you want a marker to show where turrets will spawn in your game. You can create a marker datablock indicating you want a prefix of "TurretSpawn" and and a red circle as the symbol and color. This defines a placeable shape that will default to a red circle and will automatically create a name for this object of "TurretSpawn_1", unless that name is already used, in which case it uses "TurretSpawn_2". In any event the marker will show up as a red circle with the number reflecting the name of the object. This makes it super easy to look in the mission editor and see red circle with a 7 in it. You know you can refer to that as TurretSpawn_7 in your scripts.
You must follow the instructions in Gem #2, and Gem #5, and Gem #7 before you can use this resource, and if you are doing that you really should likely follow Gem #3 as well..
1) Unzipping the files
After following the instructions in Gem #2, Gem #5, Gem #6 (and optionally Gem #3), unzip the pg08_autoNamingMarker.zip file provided with this resource. Merge the files in the plastic folder from the .zip file with the plastic folder you created in Gem #5. There is a server folder with two file you need to copy to the server folder you created as part of Gem #5.
2) Executing the scripts
We need to execute the digitBillboard.cs file that you copied over. Edit the plastic/server/init.cs script that you copied over in Gem #5 and then altered in the previous gem, Gem #7. In the section that looks like this:
echo("--------- Initializing: Server Side Plastic Gems ---------");
exec("./digitBillboard.cs");
echo("--------- Server Side Plastic Gems - Initialized ---------");add the following two lines under the line that executes the digitBillboard.cs script:
exec("./autoNumberManager.cs");
exec("./digitMarker.cs");3) A note on the SampleDigitMarker defined in digitMarker.cs
Now that we know the scripts will execute we can take a look at how the auto-naming DigitMarker is setup. The programmer simply has to create a static shape datatblock that extends DigitMarkerBase and fill in some info. The SampleDigitMarker defined in digitMarker.cs shows an example of this:
datablock StaticShapeData( SampleDigitMarker : DigitMarkerBase )
{
category = "Plastic";
shapeFile = $plasticRef@"data/shapes/markers/marker_digits_v2.dts";
markerColor = "green";
markerSymbol = "square";
};
Note the $plasticRef symbol that is defined in Gem #5 which tells the scripts where to find the plastic folder. Note also that a SampleDigitMarker will use a green square for it's symbol. Since this datablock does not define a differnt auto numbering prefix to use, it will use the defaulf value of "Marker". When you place the first marker it should be named Marker_1. When you place the second it should be called Marker_2.
4) Placing an Auto-Naming Marker
Place a SampleDigitMarker in the mission editor using the same steps described in Gem #1: Placeable Shapes. Note that when you place a Smapl
5) Making your own Auto-Naming Marker
For an example of using your own auto numbering prefix, let's pretend you want a marker for where Turrets will spawn in your game. You would define a datablock like this in some file that is executed:
datablock StaticShapeData( TurretSpawnMarker : DigitMarkerBase )
{
category = "Plastic";
autoNumberPrefix = "TurretSpawn";
shapeFile = $plasticRef@"data/shapes/markers/marker_digits_v2.dts";
markerColor = "red";
markerSymbol = "circle";
};
Note that this TurretSpawnMarker will use a red circle for it's symbol and "TurretSpawn" for it's auto numbering prefix to use. When you place the first marker it should be named TurretSpawn_1. When you place the second it should be called TurretSpawn_2.
The Next Gem
That's all for this gem. The next gem explains in greater detail how we use the marker shape to achieve what we call "Visual Editing" in our games. This refers to our ability to be in the mission editor and simply look at a marker, even across the map, and know from the color, symbol, and number, what that marker is for. It also gives an example of using the number to display a given value, for example the number of enemy zombies to spawn. :-)