Skip to main content
Version: bleeding-edge ๐Ÿฉธ

๐Ÿ“บ Viewport

Work with screen properties and effects.

๐Ÿ—ฟStatic ClassClient Only๐Ÿง‘โ€๐Ÿ’ปAPI Source

๐Ÿ—ฟย Static Functionsโ€‹

ReturnsNameDescription
tableDeprojectScreenToWorldTransforms a 2D screen coordinates into 3D world-space location
Vector2DGetMousePositionGets the current mouse screen location
floatGetViewportScaleGets the scale of viewport
Vector2DGetViewportSizeGets the size of viewport
Vector2DProjectWorldToScreenTransforms a 3D world-space vector into 2D screen coordinates
SetBloodScreenEnabledEnables/Disables the Blood Screen effect
SetBloodScreenIntensityManually sets the Blood Screen intensity
SetBrandingBarSettingsSets the Branding Bar settings (the bar with 'nanos world - closed alpha ver...')
SetCrosshairEnabledEnables/Disables the Crosshair
SetHardwareCursorLoads and sets a hardware cursor in the game from a PNG image
SetInteractionToolTipEnabledEnables/Disables the Interaction ToolTip
SetMousePositionSets the mouse position
functionSubscribeSubscribes to an Event
UnsubscribeUnsubscribes 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

TypeParameterDefaultDescription
Vector2Dscreen_position Required parameter Screen position

Returns

TypeDescription
tablewith this format

Optimal

GetMousePositionโ€‹

Gets the current mouse screen location
local ret = Viewport.GetMousePosition()

Returns

TypeDescription
Vector2DThe current mouse screen location

See also SetMousePosition.


Optimal

GetViewportScaleโ€‹

Gets the scale of viewport
local ret = Viewport.GetViewportScale()

Returns

TypeDescription
floatThe scale of viewport

Optimal

GetViewportSizeโ€‹

Gets the size of viewport
local ret = Viewport.GetViewportSize()

Returns

TypeDescription
Vector2DThe size of viewport

Moderate

ProjectWorldToScreenโ€‹

Transforms a 3D world-space vector into 2D screen coordinates
local ret = Viewport.ProjectWorldToScreen(world_position)

Parameters

TypeParameterDefaultDescription
Vectorworld_position Required parameter World 3D position

Returns

TypeDescription
Vector2DNo description provided

Optimal

SetBloodScreenEnabledโ€‹

Enables/Disables the Blood Screen effect
Viewport.SetBloodScreenEnabled(is_enabled)

Parameters

TypeParameterDefaultDescription
booleanis_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) before
Viewport.SetBloodScreenIntensity(intensity)

Parameters

TypeParameterDefaultDescription
floatintensity 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

TypeParameterDefaultDescription
WidgetHorizontalAlignmenthorizontal_alignment Required parameter Left, Center and Right supported
WidgetVerticalAlignmentvertical_alignment Required parameter Bottom and Top supported
booleanis_lean?false
Whether to show less information

Optimal

SetCrosshairEnabledโ€‹

Enables/Disables the Crosshair
Viewport.SetCrosshairEnabled(is_enabled)

Parameters

TypeParameterDefaultDescription
booleanis_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

TypeParameterDefaultDescription
CursorTypecursor_shape Required parameter No description provided
Image Pathcursor_path Required parameter a PNG image relative to Assets/
Vector2Dhotspot?Vector(0, 0)
No description provided

Optimal

SetInteractionToolTipEnabledโ€‹

Enables/Disables the Interaction ToolTip
Viewport.SetInteractionToolTipEnabled(is_enabled)

Parameters

TypeParameterDefaultDescription
booleanis_enabled Required parameter No description provided

Optimal

SetMousePositionโ€‹

Sets the mouse position
Viewport.SetMousePosition(new_position)

Parameters

TypeParameterDefaultDescription
Vector2Dnew_position Required parameter No description provided

See also GetMousePosition.


Optimal

Subscribeโ€‹

Subscribes to an Event
local ret = Viewport.Subscribe(event_name, callback)

Parameters

TypeParameterDefaultDescription
stringevent_name Required parameter Event to subscribe to
functioncallback Required parameter Callback to run on the event occurring

Returns

TypeDescription
functionThe 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

TypeParameterDefaultDescription
stringevent_name Required parameter Event to unsubscribe to
functioncallback?nil
Optional callback to specifically unsubscribe to

๐Ÿš€ย Eventsโ€‹

NameDescription
ResizeCalled when the screen is resized

Resizeโ€‹

Called when the screen is resized
Viewport.Subscribe("Resize", function(new_size)
-- Resize was called
end)

Arguments

TypeArgumentDescription
Vector2Dnew_sizeNew new screen size