Bauxite: I got your data types right here!

As of version 1.0.6.4

Welcome back to this series on the Bauxite scripting language for RPG in a Box. I’m Keith and again asking for you to learn something new. In the last article, we talked about variables and how they are akin to a box used for moving. And how a variable contains data or comicbooks in that box. AND that data has a type. A comic book is a comic.

So what is a data type? A data type is a way to describe your data. This description will tell Bauxite what things you can do to it. Example of the comic. You know a comic has a certain form, has a front cover with art and large exciting letters on it. It has 15-20 pages inside filled with an interesting story and more great art. And finally, the back cover. Which may have an ad. *shrug*

So great! You know what  a comic looks like. Now, what are its behaviors? No, data types won’t storm out of a room after you insulted it by saying Comic Sans is terrible. A behavior is just how you expect the data to work. For the comicbook, you know you can read it. You can pick it up. You can shelve it. Or you can put it in a sleeve with an appropriate sized piece of cardboard (for backing cause don’t bend that!). Or you can set it on fire. For when you need kindling, lost in the wilderness.

Lucky for us, no fire is needed. Now that we know what a data type is, let’s get into what is supported in Bauxite. I’m just going to rattle them all off first then talk about each one.

  • String
  • Number
  • Boolean
  • Coordinate
  • Color
  • Entity
  • Array
  • Codex

Now, examples.

The String

Strings are just characters. They can be numbers, letters, special characters, unicode characters such as Japanese. If you went through the first tutorial, you have already seen a string with “Hello world!” Generally, you’ll be using a string to show text on the screen. Another use is as an identifying/key in a codex. There are some cool things you can do with a string but more on that later.

Examples:

  • $myString = “Hello, World!”;
  • $location = “Planet Earth!”;

The Number

A number is just that: a number. It can be 0, it could be 9897987324. And it could also be 3.1415 or it could be -1138. Number are used all over. You can find them in coordinates, tiles, complex math equations to spawn an asteroid at the exact point in your space scene. Numbers are pretty core. You can’t escape them. But there is a maximum and minimun which is a which is roughly plus or minus 9.9 x 10^29. Yeah, pretty big.

Examples:

  • $total = 400;
  • $degrees = -32;
  • $pi = 3.14;

The Boolean

Probably the simplistic of datatypes in Bauxite is the boolean. This is a datatype to describe truthiness. Or rather, if something is true or false. That’s it. Usually you’ll see a boolean as a result of some expression. Woah, expressions? Real quick, here’s a simple one. A 50 foot tree is taller than a 10 foot tree. That might be written out like this

$isTreeTaller = $fiftyFtTree > $tenFtTree; 

Bauxite will run that expression and give the variable $isTreeTaller a true value. You’ll see booleans a lot in places where logic needs to happen. Like if the player went left then do an action. If the player has a red sword, then cast fireball. So yeah, booleans.

Examples:

  • $isRunning = true;
  • $isDoorClosed = false;
  • $isGreaterThanZero = 10 > 0;

The Coordinate

What is a coordinate? It is a series of 3 numbers that corresponds to a position on a map. That is the X position, the Y position, and the Z position. The maps are constructed in 3D space on a grid system. Generally, you will be using whole numbers to indicate a coordinate. You can also use decimals, as well. If you are coming from other 3D game engines, you might see this as a 3D vector, and well, you’d be right. A note about the vertical axis in RPG In A Box. The Z axis is used for height. Generally, you’ll find other engines use Y. Keep that in your noggin as you get into your experiences.

Examples:

  • $playerLocation = coord[2, 4, 0];
  • $vikingSpawnLoc = coord[-23, 16, 0];

The color

Color is a data type that will define a color value. From red to blue to neon green, you’d use this data type to define it. A color can be defined in one of two ways. First is with a RGB value or a set of three values each representing a value of a color: R for red; G for green; B for blue. The values range from 0 to 255. So something like color[0, 0, 255] will give you pure blue. The second way to define a color is with the equivalent hex value of the RGB. What’s a hex value? Hexadecimal is a way to count to 16 instead of the normal 10 in decimal numbers. The letters A through F for the values 10 – 15. We start at 0. color[“0000ff”] is the same as color[0, 0, 255].

Examples:

  • $blueColor = color[0, 0, 255];
  • $redColor = color[“ff0000”];

The entity

The entity is the cornerstone of all the things that can be placed, moved, interacted with in RPG in a Box. And of all the data types listed, this is the most complex. As in it has most data to work with. The entity can be compared to a house. There are many different rooms in the house all with different functions and it can contain little boxes of more things. You can safely say that each house has a kitchen, at least one bathroom and one bedroom. And now the cool part. I mean, cooler part. As we have different types of houses, we also have different types of entities. There’s a character entity, a tile entity, and an object entity. They all share the same structure but each will have different rooms, so to speak. We’ll get to these soon enough.

Examples:

  • $newEnemy = entity[“enemy1”];

The array

Now we come to the array data type. Most simply, an array is a container that holds other data types. Remember those moving boxes? Think of the moving truck as the array. It will hold all the boxes. Of all the data types we have, the array is the only one that has extra functions to be able to manage the date inside of it. These actions include adding data and removing data. And getting the size of the array.

Examples:

  • $modelList = array[“tree”, “house”, “cat”];
  • $countList = array[43, 21, 11, 0];
  • $miscList = array[“one”, 2, 3.14, $countList];

The codex

And finally, we have the codex. The codex is like an array except it data is accessed bit differently. And data is put in differently. The codex uses what’s called a key-value pair. A key is used to lookup the value or the data. Using the house example, think of the key as the address to the house. When you put the address, you know exactly where the house is at. The key functions in the same way. The key is always a string but the value can be any data type.

Examples:

  • $gameConfig = codex[“initResolution”: “1920×1080”, “startLevel”: 5];
  • $mapDetails = codex[“xSize”: 30, “ySize”: 30, “startingTown”: “Coal Town”];

And that’s pretty much it as data types go in Bauxite. Looking over the demo I had from the first tutorial which I’ll just go again, you can see a combination of all these data types in play. Even the codex makes an appearance even though it’s not explicitly defined. But it’s there. Could you find it?

So great, you know all the data types. But how do you use them? That will be forth coming at little bit at a time.

As always, thanks for joining. I’ll have more in this series up soon! Until then, don’t stop learning and have a little fun along the way.

For more information
RPG in a Box script documentation


Leave a comment