Simulation Instruments

Home›All functions›Text

Text

Simulation Instrument Studio 1

txt_add

Simulation Instrument Studio 1

Overloads

txt_add(text,style, x,y,width,height)

Places a text box at x, y. The style string sets font, size, color, and alignment.

Parameters

#NameTypeDescription
1txtStringThis is the txt being shown
2styleStringThe style to use. See the style arguments below.
3xNumberThis is the most left point of the canvas where your text should be shown.
4yNumberThis is the most top point of the canvas where your text should be shown.
5widthNumberThe text width on the canvas.
6heightNumberThe text height on the canvas.

Style

Separate arguments with a semicolon. -fx- names are accepted too.

ArgumentTypeDescription
fontStringFont family, or a TTF file in the instrument resources folder.
sizeNumberFont size in pixels.
spacingNumberSpace between letters, in pixels.
colorStringA name such as white, or a hex color. #RRGGBBAA is red, green, blue, alpha.
halignStringleft, center, or right.
valignStringtop, center, or bottom.
visibleBooleanfalse hides the text.
opacityNumber0.0 invisible to 1.0 fully visible.
background_colorStringA color behind the text box.
angle_zNumberRotation in degrees, in instrument space.

Example

-- Altitude in feet, right-aligned in the drum window
alt = txt_add("0", "font:Roboto-Bold.ttf; size:28; color:#f2f4f6; halign:right;", 140, 96, 80, 36)
Photo slot: shots/txt_add.png

txt_set

Simulation Instrument Studio 1

Overloads

txt_set(txt_id, text)

Changes the text of an existing text box.

Parameters

#NameTypeDescription
1txt_idNumberReference to a txt object
2txtStringThis is the txt being shown

Example

alt = txt_add("0", "size:28; color:white; halign:right;", 140, 96, 80, 36)

-- Sim sent 3450 ft
txt_set(alt, "3450")
Photo slot: shots/txt_set.png

txt_style

Simulation Instrument Studio 1

Overloads

txt_style(txt_id,style)

Replaces the style of a text box. Keys you do not name keep their current value only if you name opacity and visible.

Parameters

#NameTypeDescription
1txt_idNumberText identifier. This number can be obtained by calling txt_add.
2styleStringThe new style to apply. See txt_add for styling options.

Example

qnh = txt_add("29.92", "size:16; color:#c8d0d8;", 90, 180, 60, 22)

-- Kollsman window is in range. Make it brighter.
txt_style(qnh, "size:18; color:#ffffff;")
Photo slot: shots/txt_style.png

running_txt_add_cir

Simulation Instrument Studio 1

Overloads

running_txt_add_cir(x, y, nr_visible_items, item_width, item_height, radius, value_callback, style)
running_txt_add_cir(x, y, nr_visible_items, item_width, item_height, radius_x, radius_y, value_callback, style)

A strip of text items that scrolls as the caret moves.

Parameters

#NameTypeDescription
1xNumberThis is the most left point of the canvas where your running text should be shown.
2yNumberThis is the most top point of the canvas where your running text should be shown.
3nr_visible_itemsNumberNumber of text items that should be shown.
4item_widthNumberThe width of every text object in pixels.
5item_heightNumberThe height of every text object in pixels.
6radius_xNumberThe horizontal radius from the middle of the circle in pixels.
7radius_yNumber(Optional) The vertical radius from the middle of the circle in pixels. When not present, radius_x is used.
8value_callbackFunctionCallback function which will ask for the text that should be shown.
9styleString or FunctionThe style to use. More information on styles.

Example

-- Compass card. Twelve labels on a 110 px radius.
function card_label(i)
    local marks = {"N","3","6","E","12","15","S","21","24","W","30","33"}
    return marks[(i % 12) + 1]
end

card = running_txt_add_cir(160, 160, 12, 28, 28, 110, card_label, "size:14; color:white; halign:center; valign:center")
Photo slot: shots/running_txt_add_cir.png

running_txt_add_hor

Simulation Instrument Studio 1

Overloads

running_txt_add_hor(x, y, nr_visible_items, item_width, item_height, value_callback, style)

A strip of text items that scrolls as the caret moves.

Parameters

#NameTypeDescription
1xNumberThis is the most left point of the canvas where your running text should be shown.
2yNumberThis is the most top point of the canvas where your running text should be shown.
3nr_visible_itemsNumberNumber of text items that should be shown.
4item_widthNumberThe width of every text object in pixels.
5item_heightNumberThe height of every text object in pixels.
6value_callbackFunctionCallback function which will ask for the text that should be shown.
7styleString or FunctionThe style to use.

Example

function freq(i)
    return string.format("1%02d.%02d", 18 + i, 0)
end

-- A row of comm presets
presets = running_txt_add_hor(20, 200, 6, 70, 24, freq, "size:14; color:#9bd; halign:center;")
running_txt_move_carot(presets, 0)
Photo slot: shots/running_txt_add_hor.png

running_txt_add_ver

Simulation Instrument Studio 1

Overloads

running_txt_add_ver(x, y, nr_visible_items, item_width, item_height, value_callback, style)

A strip of text items that scrolls as the caret moves.

Parameters

#NameTypeDescription
1xNumberThis is the most left point of the canvas where your running text should be shown.
2yNumberThis is the most top point of the canvas where your running text should be shown.
3nr_visible_itemsNumberNumber of text items that should be shown.
4item_widthNumberThe width of every text object in pixels.
5item_heightNumberThe height of every text object in pixels.
6value_callbackFunctionCallback function which will ask for the text that should be shown.
7styleStringThe style to use. See txt_add for available style properties.

Example

function notch(i)
    return tostring(i * 10)
end

-- Flap degrees, top to bottom
flap_labels = running_txt_add_ver(12, 20, 4, 40, 28, notch, "size:14; color:white;")
running_txt_move_carot(flap_labels, 1)
Photo slot: shots/running_txt_add_ver.png

running_txt_move_carot

Simulation Instrument Studio 1

Overloads

running_txt_move_carot(running_txt_id, position)

Sets the caret of a running text.

Parameters

#NameTypeDescription
1running_txt_idNumberThe running txt id of which to move the carot
2positionNumberThe position to move the carot to.

Example

function card_label(i)
    local marks = {"N","3","6","E","12","15","S","21","24","W","30","33"}
    return marks[(i % 12) + 1]
end

card = running_txt_add_cir(160, 160, 12, 28, 28, 110, card_label, "size:14; color:white; halign:center;")

-- Heading 090. East is the fourth mark.
running_txt_move_carot(card, 3)
Photo slot: shots/running_txt_move_carot.png