RandX Alpha - Documentation
Welcome to the RandX documentation! If you've ever needed to create a random generator on the fly, this project is for you.
This project is still in alpha! Make suggestions to help us improve.
Using this tool does not require technical knowledge of any programming language, and can be used in a fairly simple way. It is, however, highly expansive and shouldn't introduce any limitations. If it does, let us know so we can add a feature!
Basic Example
Here's a basic example of a random generator. This is a simple generator that will output a random amount of a random vehicle.
Detailed Explanation
The first line of the program starts with two forward slashes. This indicates a comment. The program will skip over this line and is just meant to be a note for humans reading your generator.
On line 3, we are telling the generator how many results we want to generate. We do this by setting a special value called "_amount" to a number between 1 and 1.76 million. Be warned, values greater than 200 thousand may slow down or crash devices.
On line 5, we start a list. When we create a generator, we can pull a random value from lists. In this case, we are pulling a random value from a list of vehicles. All lists must start with the "list" keyword and end with a colon.
Note: Variables and Lists are case-sensitive. This means that "vehicles" and "Vehicles" are two different lists. Variables and lists can contain letters, numbers, and underscores, but cannot start with an underscore since these are reserved for special variables like "_amount".
On line 6, we add our first item to the list: a car. Items in the list are case-sensitive, but the case can also be modified. This will be explained later. On line 7, we add another vehicle, this time a truck, in the same way. Note the dash character used as a bullet point.
On line 8, you'll notice the item has spaces in it. This is allowed! Keep in mind that extra spaces and the beginning and the end will be removed. If you want to keep spaces, you can use quotes around the item. This will be explained later.
On line 9, we add a spaceship to the list. Note the "10%" after the name. You can use the percent symbol paired with a number to represent the odds this item should have to be picked. In this case, the spaceship has a 10% chance of being picked, and since our list has 4 other items, each other item will split the remaining 90% of the odds. That means there is a 22.5% chance of each other item being picked.
On line 10, we add "megatron" to our list. Note that this time, there is a backslash before the percent symbol. This is because the percent symbol is a special character in rscript. If you want to use a percent symbol in a name, you must use a backslash before it. This is known as an escape character. Escape characters are used to make special characters be treated like any other letter.
Note: This also applies to colons. If you want to use a colon in a name, you must use a backslash before it. This is because colons are used to define variables, lists, and results.
The list has now ended.
On line 12, we see the keyword "result" followed by a colon. This means that the content on line 13 is what will be generated as a final result.
Line 13 starts with the text "I want". This means that for every generation we perform, the text generated will start with "I want". This is known as static text because it never changes. The next thing we see is "[1-6]". This is a quick tool to generate a random number from 1 to 6, inclusive. This could also be done by creating a list called "numbers", and adding every number from 1 to 6 to the list, but this shorthand is much more efficient. Next, we see "[vehicles]". This will pick a random item from our vehicles list. After the "[vehicles]" tag is the letter "s". This makes whatever vehicle was picked plural. Keep in mind that this means if the number we randomly pick from 1 to 6 is 1, the grammar of the sentence will be incorrect (ex: 1 cars). We will show you how to fix this later. Finally, we see more static text, and this completes our result.
This generator will produce text like:
I want 5 cars please!
I want 3 spaceships please!
I want 6 hot air balloons please!
I want 1 trucks please!
I want 2 megatron 5%s please!
Basic Syntax
<> The basic syntax of rscript is simple and relatively similar to standard pseudoscript. It is a line-based language, meaning that each line is a new command and/or serves its own purpose. The language is designed to be easy to read and write, and is pretty lenient with syntax.Keywords
Keywords are words that tell the generator what you are trying to do on a specifc line/lines. This includes the list keyword, and the result keyword.
Keywords are case-insensitive, meaning that "list" and "List" are the same thing. Use whatever floats your boat.
The "result" keyword is the only required portion of any generator. without it, you couldn't get an output.
Variables
Variables can be set by the user and are used to store and manipulate data.
Comments
Comments are used to add notes to your generator. They are not read by the generator and are only for human consumption.
Misc
There are a few other things that are important to know about the syntax of rscript.
Builtin Variables
Builtin variables are variables that are reserved for specific purposes. These values are case-sensitive and are used to perform specific tasks. They typically modify the behavior of the generator in some way.
Variables are case-sensitive, meaning that "_amount" and "_Amount" are two different things (_Amount doesn't exist!). Use the correct case when using variables.
Tags
Tags are what allow for the smooth usage of random generation and selection. Between tags that work on their own and tags that require variables as input, they makeup the backbone of the generator.
Random Tags
Random tags are used to generate random numbers, characters, or a combination.
Dynamic Tags
Dynamic tags are to used to access and maniuplate varibles and lists.
Lists
Lists are used to store and access a group of items. These items can be anything from numbers to strings to timestamps.
Inline Modifiers
Inline modifiers are used on individual list items to modify how they function or are chosen.