Data Types.
Strings
String types can be defined via surrounding text in single or double quotes, double square brackets or backticks.
SomeProperty = 'hello world'
SomeProperty = "hello world"
SomeProperty = [[
hello world
]]
SomeProperty = `hello world`
-- Please note that variables can't be used inside of interpolated strings.
🚧 Under Construction
Only double quote strings are available at the moment.
Colors
There are multiple ways to define colors in rsml.
Hex Colors
You can easily add hex codes into your style sheets via a #
prefix:
#C586C0
Tailwind Colors
Rsml has built-in syntax for adding tailwind colors into your style sheets, for example:
tw:fuchsia:200
Css Colors
Rsml has built-in syntax for adding css colors into your style sheets, for example:
css:rebeccapurple
RGB
Rgb colors can be defined as follows:
rgb (255, 82, 24)
Color3
Color3 colors can be defined as follows:
color3 (.8, .1, .3)
Measurements
A measurement is a number ending in either px
(offset) or %
(scale). Scale values evaluate to their decimal counterpart.
You can use a calculation of measurements to represent a pair of scale and offset values:
25px - 50% + 12px
{
Scale: -0.5, // - 50%
Offset: 37, // 25px + 12px
}
As you can see offsets can only be added and subtracted from other offsets, the same applies to scales. However *
, /
, ^
, %
operations can be used between an offset and a scale:
12px * 50% / 12% + 50% ^ 3px
{
Scale: 1250, // 50% ^ 3px
Offset: 50, // 12px * 50% / 12%
}
Tuples
A tuple is a grouping of other data types. They are defined by wrapping a comma separated list in brackets:
("hello", "world")
You can define the data type of the tuple via an annotation:
udim2 (50% + 25px, 13px + 12%)
Tuples can be given the following annotations:
Name | Data Type | Components | Example |
---|---|---|---|
udim | UDim.new | (Measurement) | udim (10px) |
udim2 | UDim2.new | (Measurement, Measurement) | udim2 (45% + 23px, 12px - 23%) |
rect | Rect.new | (Scale, Scale, Scale, Scale) | rect (10, 10, 10, 10) |
vec2 | Vector2.new | (Scale, Scale) | vec2 (.5, .2) |
vec3 | Vector3.new | (Scale, Scale, Scale) | vec3 (15, 12, 11) |
font | Font.fromId | (Number | String, "{Enum.FontStyle}"?, "{Enum.FontStyle}"?) |
rgb | Color3 | (Number, Enum.FontWeight?, Enum.FontStyle?) | font (16658221428, SemiBold) |
A measurement, or a tuple with only one component which is a measurement, will be automatically inferred as a udim
. This means you do not need to to wrap measurements with a udim tuple.