๐บ Viewport
Work with screen properties and effects.
๐ฟย Static Functionsโ
| Returns | Name | Description | |
|---|---|---|---|
| table | DeprojectScreenToWorld | Transforms a 2D screen coordinates into 3D world-space location | |
| Vector2D | GetMousePosition | Gets the current mouse screen location | |
| float | GetViewportScale | Gets the scale of viewport | |
| Vector2D | GetViewportSize | Gets the size of viewport | |
| Vector2D | ProjectWorldToScreen | Transforms a 3D world-space vector into 2D screen coordinates | |
SetBloodScreenEnabled | Enables/Disables the Blood Screen effect | ||
SetBloodScreenIntensity | Manually sets the Blood Screen intensity | ||
SetBrandingBarSettings | Sets the Branding Bar settings (the bar with 'nanos world - closed alpha ver...') | ||
SetCrosshairEnabled | Enables/Disables the Crosshair | ||
SetHardwareCursor | Loads and sets a hardware cursor in the game from a PNG image | ||
SetInteractionToolTipEnabled | Enables/Disables the Interaction ToolTip | ||
SetMousePosition | Sets the mouse position | ||
| function | Subscribe | Subscribes to an Event | |
Unsubscribe | Unsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback |
Moderate

DeprojectScreenToWorldโ
Transforms a 2D screen coordinates into 3D world-space location
local ret = Viewport.DeprojectScreenToWorld(screen_position)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector2D | screen_position | Required parameter | Screen position |
Returns
| Type | Description |
|---|---|
| table | with this format |
Optimal

GetMousePositionโ
Gets the current mouse screen location
local ret = Viewport.GetMousePosition()
Returns
| Type | Description |
|---|---|
| Vector2D | The current mouse screen location |
See also SetMousePosition.
Optimal

GetViewportScaleโ
Gets the scale of viewport
local ret = Viewport.GetViewportScale()
Returns
| Type | Description |
|---|---|
| float | The scale of viewport |
Optimal

GetViewportSizeโ
Gets the size of viewport
local ret = Viewport.GetViewportSize()
Returns
| Type | Description |
|---|---|
| Vector2D | The size of viewport |
Moderate

ProjectWorldToScreenโ
Transforms a 3D world-space vector into 2D screen coordinates
local ret = Viewport.ProjectWorldToScreen(world_position)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector | world_position | Required parameter | World 3D position |
Returns
| Type | Description |
|---|---|
| Vector2D | No description provided |
Optimal

SetBloodScreenEnabledโ
Enables/Disables the Blood Screen effect
Viewport.SetBloodScreenEnabled(is_enabled)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | is_enabled | Required parameter | No description provided |
Optimal

SetBloodScreenIntensityโ
If you want the Blood Screen to do not be overridden, disable it with Client.SetBloodScreenEnabled(false) beforeViewport.SetBloodScreenIntensity(intensity)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| float | intensity | Required parameter | From 0.0 to 1.0 |
Optimal

SetBrandingBarSettingsโ
Sets the Branding Bar settings (the bar with 'nanos world - closed alpha ver...')
Viewport.SetBrandingBarSettings(horizontal_alignment, vertical_alignment, is_lean?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| WidgetHorizontalAlignment | horizontal_alignment | Required parameter | Left, Center and Right supported |
| WidgetVerticalAlignment | vertical_alignment | Required parameter | Bottom and Top supported |
| boolean | is_lean? | false | Whether to show less information |
Optimal

SetCrosshairEnabledโ
Enables/Disables the Crosshair
Viewport.SetCrosshairEnabled(is_enabled)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | is_enabled | Required parameter | No description provided |
Slow

SetHardwareCursorโ
Loads and sets a hardware cursor in the game from a PNG image
Note: due an engine limitation modifying an already set cursor image will not change the cursor until the game is restarted
Viewport.SetHardwareCursor(cursor_shape, cursor_path, hotspot?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| CursorType | cursor_shape | Required parameter | No description provided |
| Image Path | cursor_path | Required parameter | a PNG image relative to Assets/ |
| Vector2D | hotspot? | Vector(0, 0) | No description provided |
Optimal

SetInteractionToolTipEnabledโ
Enables/Disables the Interaction ToolTip
Viewport.SetInteractionToolTipEnabled(is_enabled)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | is_enabled | Required parameter | No description provided |
Optimal

SetMousePositionโ
Sets the mouse position
Viewport.SetMousePosition(new_position)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector2D | new_position | Required parameter | No description provided |
See also GetMousePosition.
Optimal

Subscribeโ
Subscribes to an Event
local ret = Viewport.Subscribe(event_name, callback)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | event_name | Required parameter | Event to subscribe to |
| function | callback | Required parameter | Callback to run on the event occurring |
Returns
| Type | Description |
|---|---|
| function | The function callback |
Optimal

Unsubscribeโ
Unsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback
Viewport.Unsubscribe(event_name, callback?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | event_name | Required parameter | Event to unsubscribe to |
| function | callback? | nil | Optional callback to specifically unsubscribe to |
๐ย Eventsโ
| Name | Description | |
|---|---|---|
Resize | Called when the screen is resized |

Resizeโ
Called when the screen is resized
Viewport.Subscribe("Resize", function(new_size)
-- Resize was called
end)
Arguments
| Type | Argument | Description |
|---|---|---|
| Vector2D | new_size | New new screen size |


