API ReferenceGE Extensionsflowgraphnodesui
ConvertUnit (Flowgraph Node)
- **Node Name:** `ConvertUnit`
Overview
- Node Name:
ConvertUnit - Category:
repeat_instant - File:
extensions/flowgraph/nodes/ui/convertUnit.lua
Converts a numeric value to the user's preferred unit system (metric/imperial) for distance or velocity.
Pin Schema
Input Pins
| Pin | Type | Default | Description |
|---|---|---|---|
value | number | - | Value to convert (in SI units - meters or m/s) |
velocity | bool | false | (Hidden) Use velocity conversion instead of distance |
big | bool | false | (Hidden) Use large units (km/mi/h instead of m/ft/s) |
format | string | "%0.2f%s" | (Hidden) Format string for the full output |
Output Pins
| Pin | Type | Description |
|---|---|---|
value | number | Converted numeric value |
unit | string | Unit label (e.g., "km/h", "mph", "m", "ft") |
full | string | (Hidden) Formatted string combining value and unit |
How It Works
work()- SelectstranslateVelocityortranslateDistancebased on thevelocityflag.- Calls the translation function with the input value and
bigflag. - Outputs the converted value, unit string, and optionally a formatted string.
- The
fullpin is only computed if it's connected (performance optimization via:isUsed()).
Key Dependencies
translateVelocity(value, big)- converts m/s to user's preferred velocity unittranslateDistance(value, big)- converts meters to user's preferred distance unit
Example Usage
-- Convert 30 m/s to user preference:
-- velocity=true, big=false → e.g., 108.00 km/h or 67.11 mph
local value, unit = translateVelocity(30, false)
-- Convert 1500m to large units:
-- velocity=false, big=true → e.g., 1.50 km or 0.93 mi
local value, unit = translateDistance(1500, true)See Also
- Medal / Auto Medal (Flowgraph Node) - Related reference
- Clear Messages (Flowgraph Node) - Related reference
- Context Translation (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide