Get the x and y coordinates from a circle with a certain radius and angle.
Parameters
#
Name
Type
Description
1
degrees
Number
The number of degrees to calculate with.
2
radius x
Number
The x radius in pixels. This is the number of pixels from the center of the circle to the horizontal edge.
3
radius y
Number
This value is optional. The y radius in pixels. This is the number of pixels from the center of the circle to the vertical edge.
Example
-- Calculate the x and y coordinate on 45 degrees with a radius of 200 pixels
face = img_add("face.png", 100, 100, 200, 200)
x, y = geo_rotate_coordinates(45,200)
move(face, x, y, nil, nil)
-- Calculate the x and y coordinate (oval) on 45 degrees with a radius x of 200 pixels and radius y of 100 pixels
myimage2 = img_add("face.png", 100, 100, 200, 200)
x, y = geo_rotate_coordinates(45,200,100)
move(myimage2, x, y, nil, nil)
Photo slot: shots/geo_rotate_coordinates.png
has_feature
Simulation Instrument Studio 1
Overloads
has_feature(name)
Has_feature can be used to check if the current version of Studio or Studio supports the asked feature.
Parameters
#
Name
Type
Description
1
name
String
The feature name.
Example
if has_feature("TIMER") then
timer_start(0, 100, function()
print("timer callback")
end)
end
Photo slot: shots/has_feature.png
instrument_prop
Simulation Instrument Studio 1
Overloads
instrument_prop(property)
Returns a value from info.xml. Width and height are the instrument size, not the panel size.
Parameters
#
Name
Type
Description
1
property
String
The type of property to fetch. See the table below
Properties
Property
Type
Description
AIRCRAFT
String
Aircraft the instrument is set for.
AUTHOR
String
Author.
TYPE
String
Instrument type.
UUID
String
Instrument id.
PREF_WIDTH
Number
Preferred width, from info.xml.
PREF_HEIGHT
Number
Preferred height, from info.xml.
WIDTH
Number
Width in use.
HEIGHT
Number
Height in use.
DESCRIPTION
String
Description.
VERSION
Number
Instrument version.
DEVELOPMENT
Boolean
True when launched from the editor.
PLATFORM
String
WINDOWS, MAC, LINUX, RASPBERRY_PI, or UNKNOWN.
Example
-- Preferred size from info.xml. Do not use the panel size.
w = instrument_prop("PREF_WIDTH")
h = instrument_prop("PREF_HEIGHT")
Interpolate settings. Can be manually created (see example), or created from table user property with interpolate_settings_from_user_prop function. Make sure all settings are provided in ascending order.
2
value
Number
Input value.
3
cap
Boolean
(Optional, default false) When input range is outside of settings and cap is false, nil is returned. Otherwise the min or max output value is returned.
Example
-- 0 kt is 0 degrees, 200 kt is 300 degrees
deg = interpolate_linear(ias, {0, 0}, {200, 300})
Example: a table, and a pilot table
-- 0 kt is 0 degrees, 100 kt is 140, 200 kt is 300
local curve = { {0, 0}, {100, 140}, {200, 300} }
local deg = interpolate_linear(curve, 150)
-- Same curve, filled in by the pilot before launch
local prop = user_prop_add_table("Airspeed curve", "Knots against needle degrees", "Knots", "DOUBLE", 0, "Indicated", "Degrees", "DOUBLE", 0, "Needle")
local from_pilot = interpolate_settings_from_user_prop(user_prop_get(prop))
local deg2 = interpolate_linear(from_pilot, 150)
Photo slot: shots/interpolate_linear.png
log
Simulation Instrument Studio 1
Overloads
log(message, ...)
log(type, message, ...)
Writes a line to the Studio log.
Parameters
#
Name
Type
Description
1
type
String
(Optional) Can be 'INFO', 'WARN' or 'ERROR'. Default is set to be an info message.
The type of property to fetch. See the table below
Properties
Property
Type
Description
AUTHOR
String
Panel author.
NAME
String
Panel name.
UUID
String
Panel id.
LAYOUT_UUID
String
Layout id.
WIDTH
Number
Panel width.
HEIGHT
Number
Panel height.
DESCRIPTION
String
Description.
VERSION
Number
Panel version.
DEVELOPMENT
Boolean
True when launched from the editor.
PLATFORM
String
WINDOWS, MAC, LINUX, RASPBERRY_PI, or UNKNOWN.
Example
-- Print the panel authorprint( panel_prop("AUTHOR") )
-- See if we started from the create/edit tab
if panel_prop("DEVELOPMENT") then
print("We are running in development mode!")
end
Photo slot: shots/panel_prop.png
resource_info
Simulation Instrument Studio 1
Overloads
resource_info(filename)
Resource_info can be used to get information of a resource file. This can also be used to check if a resource exists.
Parameters
#
Name
Type
Description
1
filename
String
The file name of the resource. Including it's extension.
Example
-- We are looking for more information about the bla.png image
resource_meta = resource_info("bla.png")
-- Check if the image could be found
if resource_meta == nil then
print("bla.png not found!")
elseif resource_meta["TYPE"] == "IMAGE" then
print("bla.png is an image and has w=" .. resource_meta["WIDTH"] .. " h=" .. resource_meta["HEIGHT"])
else
print("bla.png is not an image!")
end
Photo slot: shots/resource_info.png
shut_down
Simulation Instrument Studio 1
Overloads
shut_down(type)
Shut down the application (Studio or Studio) or the system where the instrument runs on.
Parameters
#
Name
Type
Description
1
type
String
'APPLICATION' if you want to shut down Studio or Studio, or 'SYSTEM' if you want to shutdown the system (windows, Raspberry Pi etc.)
Example
-- Shut down Windows or the Raspberry Pishut_down("SYSTEM")
Photo slot: shots/shut_down.png
var_cap
Simulation Instrument Studio 1
Overloads
var_cap(value,min,max)
Limit a value to a given minimum and maximum value.
Parameters
#
Name
Type
Description
1
value
Number
The is the value that needs to be limited to the min and max value.
2
min
Number
The minimum value to limit to.
3
max
Number
The maximum value to limit to.
Example
-- Keep the needle on the card
deg = var_cap(deg, 0, 360)
Photo slot: shots/var_cap.png
var_format
Simulation Instrument Studio 1
Overloads
var_format(value,decimals)
Round a number to a certain number of decimals and always shows that selected amount of decimals.
Subscribe to more different data sources, such as X-Plane, FSX and SI variables.
Example
-- Note that the order in which the variables are given to the variable_subscribe function determines the order in which the variables will enter this function-- In our case -- "sim/cockpit2/gauges/indicators/altitude_ft_pilot" maps to "altitude"-- "TIME ZULU" maps to "time_seconds"-- "MY_CUSTOM_VARIABLE" maps to "my_custom_variable"
function callback_function(altitude, time_seconds, my_custom_variable)
print("Altitude from X-Plane=" .. altitude)
print("Time seconds from FSX=" .. time_seconds)
print("My Custom variable from SI=" .. my_custom_variable)
end
-- multi subscribevariable_subscribe("XPLANE", "sim/cockpit2/gauges/indicators/altitude_ft_pilot", "FLOAT",
"FSX", "TIME ZULU", "Seconds",
"SI", "MY_CUSTOM_VARIABLE", "INT", callback_function)
Photo slot: shots/variable_subscribe.png
request_callback
Simulation Instrument Studio 1
Overloads
request_callback(callback_function)
Force a callback on a given data subscription (X-Plane, FSX, FS2, FS2020, IIC or external sources).
Parameters
#
Name
Type
Description
1
function_callback
String
The callback function that should be updated
Example
-- This function will be called when new data is available from X-Plane
function new_altitude_callback(altitude)
print("New altitude: " .. altitude)
end
-- Subscribe X-Plane datarefsxpl_dataref_subscribe("sim/cockpit2/gauges/indicators/altitude_ft_pilot", "FLOAT", new_altitude_callback)
-- Force a callback. The 'new_altitude_callback' function will be called here with its current arguments.request_callback(new_altitude_callback)