Data Types
Data types are the ways computers store and handle information. It's also used to be sure the programmer isn't trying to subtract a piece of text from a number or multiply 15 by 'true'.
Data types are the ways computers store and handle information. It's also used to be sure the programmer isn't trying to subtract a piece of text from a number or multiply 15 by 'true'.
Number —> Any number.
For example: 5, 10.2, -9.5
String —> A piece of text. Must be wrapped in quotation marks. The intepreted text will be the text within the quotation marks.
For example: "Hello world!", ""
Boolean —> A true or false value.
For example: true, false
No other types are currently supported, such as tables (lists/dictionaries) or functions.
Random numbers can be generated by substituting where a constant would otherwise be with a short literal like:
i[1,10]
This atom generates an integer from 1 to 10. Conversely, for generating real numbers:
r[1,10]
This atom generates an real number from 1 to 10. Note that no space can occur at any place within the atom.
To be technical, this atom produces a random number within the range [1, 10), but the difference between this and a random number generator that generates numbers within the range [1, 10] is unnoticeable.These data types can be entered as arguments into any instruction. For example:
DEF number var = 10
DEF number varRandom = i[5,15]
This line defines a variable called 'var', labels it as a numerical variable, and stores the number 10 within.
THROW! "Hello world!"
This line throws an error (intentionally) and, for its error message, it accepts the string "Hello world!". Note that in-game the error message will not show the quotation marks.
For the majority of arguments, a variable name can be inputted rather than a constant. The lines below employ this technique and do the same as the two lines of code above:
DEF number ten = 10
DEF number var = ten
DEF errorMessage = "Hello world!"
THROW! errorMessage
Whatever variable is used for an argument must match the data type that argument must be in, otherwise an error may be thrown and the error message is not always clear on if this discrepancy was the issue. Thus be sure all variables passed in as arguments to instructions match their required data types!