Loading function...

Please make sure JavaScript is enabled. Otherwise you will be unable to see the function documentation.

Return the current resolution used by DSL's renderer. Although this shouldn't change during a normal play session, it is possible for another mod to resize the game. For this reason, it is often a good idea to get this value each frame you need it rather than once at setup. Also keep in mind that most render functions take normalized coords, meaning you will not usually need the actual resolution.

Arguments

None.

Results

Return the current aspect ratio. This value is the same as dividing the Width and Height returned by GetDisplayResolution.

Arguments

None.

Results

Set the current drawing layer used by cached draws. This value is reset every time the current thread changes, so you will only need to re-apply it once before a large amount of drawing as long as you know it is all done without the thread yielding (waiting). If you need to draw something somewhere other than a thread, you should call this function even if it is just to apply the default setting.

Arguments

Results

None.

Versions

DSL4 Although layers were not implemented until this version, cached draws used to be drawn at the same time as the POST_FADE layer rather than PRE_FADE (which is the new default).
DSL5 This function now works as intended, and does not wrongly raise an error when setting any layer besides POST_FADE.

Layers

Draw a rectangle. Keep the general rules of rendering in mind. X and Y define the top left of the rectangle.

Arguments

Results

None.

Versions

DSL4 Alpha is now optional, and 255 will be used if it is not present.

Create a Texture for later drawing given a relative path of a .png file.

Arguments

Results

Draw a Texture. Keep the general rules of rendering in mind. Use GetTextureDisplayAspectRatio to preserve the aspect ratio of the texture. X and Y define the top left of the rectangle.

Arguments

Results

None.

Versions

DSL4 All color values are now optional, and 255 will be used for missing ones.

Draw a Texture just like DrawTexture, but also with a Rotation specified in degrees.

Arguments

Results

None.

Versions

DSL4 All color values are now optional, and 255 will be used for missing ones.

Set the UV coords used for drawing a Texture. This defines what section of a texture is actually drawn, for example passing 0, 0, 0.5, 0.5 will only draw the top left part of a texture.

Arguments

Results

None.

Return the resolution of a Texture. Keep in mind that textures are drawn using normalized coords, so you will not usually need the actual resolution.

Arguments

Results

Return the aspect ratio of a Texture This value is the same as dividing the Width and Height returned by GetTextureResolution.

Arguments

Results

Return the ratio that should be used to draw a Texture without affecting its aspect ratio. This value is the same as dividing the texture's aspect ratio by the display's aspect ratio.

For the reasons described in GetDisplayResolution, you should call this function each frame it is needed rather than just once at setup.

Arguments

Results

Create a Font to be used when drawing text. This function only exists for future-proofing when there will be more ways to create a font, such as from a file. For now it is usually better to just use a string where a Font is expected, as that will do the same thing but also cache the font for use by any script.

Name should correspond to a font installed on the system. A default font will be used if it does not exist. Consider using a texture to draw text with a font that users of your script are not likely to have.

Arguments

Results

Draw some Text on screen using the current text formatting options, then discard the text formatting options.

If necessary, Text will be converted to a string using tostring. If more values are given after it, string.format is used to format the text.

If you need to measure the text before drawing it, consider using MeasureText.

Arguments

Results

Example

Draw some text for 3 seconds.

function main()
	local draw_until = GetTimer() + 3000
	repeat
		SetTextShadow()
		SetTextColor(255, 0, 0, 255)
		SetTextPosition(0.5, 0.2)
		DrawText("Kill Sheldon!")
		Wait(0)
	until GetTimer() >= draw_until
end

Measures text like DrawText, but without actually drawing anything and without discarding the current text formatting.

Arguments

Results

Discards the current text formatting options used by DrawText, but without actually having to draw the text.

Arguments

None.

Results

None.

Set the position of the text to be drawn. By default, X refers to the middle of the text and Y refers to the top of it. Use SetTextAlign if you want a different alignment.

This is a text formatting option.

Arguments

Results

None.

Set the size of the text to be drawn, where 1 would be as tall as the whole screen. Consider using SetTextScale for general use, unless you are sizing the text to fit in a specific area.

This is a text formatting option.

Arguments

Results

None.

Set the size of the text to be drawn just like SetTextHeight, but using a pre-defined base value. By default, text is drawn with a scale of 1.

This is a text formatting option.

Arguments

Results

None.

Set the font of the text to be drawn. Font should be the name of a font installed on the system, or a Font object created by CreateFont.

This is a text formatting option.

Arguments

Results

None.

Set the alignment of the text to be drawn. Only the first letter of the alignment strings are actually needed, the full name is just allowed for readability.

This is a text formatting option.

Arguments

Results

None.

Horizontal Alignment

Vertical Alignment

Set the color of the text to be drawn.

This is a text formatting option.

Arguments

Results

None.

Versions

DSL4 Alpha is now optional, and 255 will be used if it is not present.

An alias of SetTextColor.

This is a text formatting option.

Arguments

Results

None.

Versions

DSL4 Alpha is now optional, and 255 will be used if it is not present.

Apply a shadow to the text being drawn, and optionally set a color for it. This will remove the text's outline if it has one. If the full color is not specified, it will default to black.

This is a text formatting option.

Arguments

Results

None.

Versions

DSL2 An optional color value can be specified instead of just using black.

Apply an outline to the text being drawn, and optionally set a color for it. This will remove the text's shadow if it has one. If the full color is not specified, it will default to black.

This is a text formatting option.

Arguments

Results

None.

Versions

DSL2 An optional color value can be specified instead of just using black.

Set if the text being drawn should be bold. If Bold is not defined, it will default to true.

This is a text formatting option.

Arguments

Results

None.

Versions

DSL4 The optional Bold argument has been added, as boldness could not be disabled after being applied before.

Set if the text being drawn should be black (as in the font weight, not color). If Black is not defined, it will default to true.

This is a text formatting option.

Arguments

Results

None.

Set if the text being drawn should be italic. If Italic is not defined, it will default to true.

This is a text formatting option.

Arguments

Results

None.

Versions

DSL4 The optional Italic argument has been added, as boldness could not be disabled after being applied before.

Set the maximum size of the text being drawn. If horizontal clipping is enabled while word wrapping is also enabled, the word wrapping will be disabled.

This function respects the alignment of the text. For example if it is drawn horizontally centered, the left and right sides would be equally affected when clipping needs to be applied.

Both arguments are optional, meaning you must specify nil for the Max width if you only wish to specify a Max height. Using nil or just not passing anything for either option will disable clipping for that dimension. By default, clipping is disabled.

This is a text formatting option.

Arguments

Results

None.

Set the maximum width of the text being drawn. If word wrapping is enabled while horizontal clipping is also enabled, the horizontal clipping will be disabled.

Word wrapping will be disabled if Max width is 0, not given, or just not a number. By default, word wrapping is disabled.

This is a text formatting option.

Arguments

Results

None.

Define the requirements for the text being drawn to be re-drawn instead of allowing the cached version to be used. Only the first letter of the string is actually needed, the full name is just allowed for readability.

This is usually not needed, as text is already re-drawn whenever it will be noticeable by default.

This is a text formatting option.

Arguments

Results

None.

Redrawing Modes

Get a text formatting table representing the current text formatting options for later re-application with SetTextFormatting.

This function is usually the less preferable option compared to PopTextFormatting.

Arguments

None.

Results

Get a text formatting table representing the current text formatting options for later re-application with SetTextFormatting.

Unlike GetTextFormatting, this function also discards the current text formatting options. This makes this function the more preferable option when you are setting up a text format to be used later on in your script.

Arguments

None.

Results

Set the current text formatting options using a table returned by GetTextFormatting or PopTextFormatting.

Text formatting can also be a number, in which case it will correspond to a pre-defined style. 1 and 2 mimic the styles used by TextPrint, but the full list of styles allowed are shared with DrawTextInline.

Arguments

Results

None.

Versions

DSL3 The Text formatting argument can now be a number representing a pre-defined style.

Draw text in a single function call rather than using DrawText and related text formatting options.

Width is an optional number defining how long the text can be before word wrapping is applied. If you do not want word wrapping, simply skip this argument (do not use nil in place of it).

Text defines the text to actually be drawn, and can contain an arbitrary amount of inline format specifiers. If you want to draw anything besides an actual string, you must convert it using something like tostring. Keep in mind the text will be drawn on the current layer set with SetDrawLayer if a cached draw is used. If an inline format specifier takes extra arguments, they are expected to be given after the text string in the order that the specifiers appear.

Duration defines how many seconds the text will be drawn. For the sake of not letting multiple things print over each other, only one inline text draw can be happening on any given Style at a time. This means that if you draw two things at once using this function with the same Style, the first one will be replaced and only the second will be seen. This behavior can be disabled by passing -1 as the duration or by using the ~xy~ inline format specifier. Using 0 or -1 will only draw for a single frame.

Style defines the base style used for text. It can be one of the pre-defined styles listed below, or a text formatting table just like the one used by SetTextFormatting. This is a good option for text that will be used like a custom HUD component, as it will keep subsequent inline text draws from overlapping.

If done from a drawing thread, text will be drawn immediately instead of during a cached draw. This prevent subsequent DrawTextInline calls from replacing it which can result in overlapping text.

Arguments

Results

Versions

DSL2 The DrawTextInline function was introduced, but in such a limited way that the documentation labels it as a DSL3 function.
DSL4 An optional Width argument was added, using ~xy~ keeps existing text from being replaced (as well as this text), the total Width & Height is returned.

Pre-Defined Styles

NumberDescription
1Objective text that mimics using 1 with TextPrint.
2Subtitle text that mimics using 2 with TextPrint.
3Objective text like style 1, but left-aligned.
4Subtitle text like style 2, but left-aligned.
5Objective text like style 1, but right-aligned.
6Subtitle text like style 2, but right-aligned.

Inline Format Specifiers

Full NameShort NameDescription & Arguments
~alpha~~a~Take 1 extra argument to set the text's alpha value.
~bold~~b~Make the text bold.
~blue~Make the text blue
~cyan~~c~Make the text cyan.
~font~~f~Take 1 extra argument to set the text's font using a string or Font object.
~green~~g~Make the text green.
~height~Take 1 extra argument to set the text's height (replaces scale).
~italic~~i~Make the text italic.
~magenta~~m~Make the text magenta.
~normal~~n~Take away bold and italic formatting.
~objective~~o~Make the text use the color for objectives.
~red~~r~Make the text red.
~rgb~Take 3 extra arguments to set the text's color.
~subtitle~~s~Make the text use the color for subtitles.
~scale~Take 1 extra argument to set the text's scale (replaces height).
~texture~~t~Take 1 extra argument to draw an inline texture using a Texture object.
~white~~w~Make the text white.
~xy~Take 2 extra arguments to set the text's position and not replace text of the same style.
~yellow~~y~Make the text yellow.

Measure text like DrawTextInline, but without actually drawing.

Arguments

Results

Immediately clear the back buffer.

This is an advanced drawing function, meaning it is meant for advanced users and does not use cached draws.

Arguments

None.

Results

None.

Create a Texture that contains nothing by default, and should be filled in using targeted drawing functions.

This function does not take a normalized size, the Width and Height are measured in pixels.

Arguments

Results

Draw the back buffer onto Target.

This is an advanced drawing function, meaning it is meant for advanced users and does not use cached draws.

Arguments

Results

None.

Set whether or not alpha blending is enabled. If you turn this off, you should usually turn if back on after you're done drawing.

This is an advanced drawing function, meaning it is meant for advanced users.

Arguments

Results

None.