
As of version 1.0.6.4
Welcome 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. This is an article to go with the Bauxite video tutorials. Stuff that may be a little dry from a video. So written words it is!
And on that note, let’s get into it.
Today we’re going to be talking about variables and data types and what they do. The short of it, a variable is pretty much a box that has a name on it which you can put things into. And a data type is the description of what you might put into the box. And finally, data which is the concrete realization of that datatype.
A loose example would be if you were moving and you had a box that you needed to fill up. On this box, you might write the word “Bedroom #1” on it. This would be the variable name. It will tell people that it probably need to be put into the 1st bedroom. Data type is how you describe what you put into the box. Let’s say this box only had comics in it. So the variable name would “Bedroom #1” which has a data type of comicbooks.
So a variable has a name and it has a data type. But you need one more thing which is actual data. Going back to our moving box example, the data would be the comics such Amazing Spider-Man, Tales of the Jedi (yeah, the OG), or Peanuts. So box “Bedroom #1” contains Peanuts comics. Movers will be able to pick up that box and do some action to it and in this case, put it into the truck and move it cross country.
Bauxite has variables that have a data type and data which will allow you do things within RPG In A box.
The way to create a variable in Bauxite is the following:
$<your variable name> = <some data>;
The $ symbol tells Bauxite that this is a variable. Always. If it doesn’t have a $ in front then it is either a special type of object within Bauxite or it’s a function, which we’ll get to both later on. Just know that the variables you create will start with a $. Next is the name of the variable. The name should make sense and there are some rules of what it can be named which will come up shortly. Next we have the = sign. This called an assignment operation. It tells Bauxite to put whatever data on the right side into the variable on the left. And now we got the data. Data can be any of the particular datatypes that Bauxite supports. I will briefly talk about datatypes here but will cover it more in a later article.
Now there are some rules around naming a variable. The name must start with a letter and have no special characters in it other than the underscore (_) character. And it must have at least one character in it.
Pro-tip: While one letter variables are possible, they are certainly not recommended. Going back to the moving box example, if you had a box that had the letter B written on it, would you be able to easily tell what was in that box? Or more importantly, would someone else know? (or more likely, yourself in a week.)
The following are valid variable names:
- $myVariable
- $totalCount
- $b
- $bubble_list
Here are some invalid variable names:
- $1138
- $this-one
- $example$
- $_wontWork
When you try to apply/save and you have a bad variable, it will not compile. And should highlight which row has the issue.
Here are some full examples including sample data:
- $count = 0;
- $address = “555 Main st.”;
- $enemyCoordinate = coord[3, 4, 6];
- $isRunning = true;
Wait, you might say. What’s that thing at the end of the examples? That is a semi-colon ;. That is an indicator to Bauxite that that is the end of a statement. It is required for all statements (with noted exceptions), not just assigning data to variables.
Well, that was a lot just on variables. We only touched on data types. In the next tutorial, we’ll be doing a more deep dive into each available datatype!
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.
One thought on “Bauxite: Variables, data types, and the path to assignment”