Ir para o conteúdo principal
Version: latest - a1.156.0 ⚖️

📺 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
tableTable with the world <code>Position</code> and the <code>Direction</code> the screen point looks at with 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
Vector2DThe screen position, in pixels

Optimal

SetBloodScreenEnabled​

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

Parameters

TypeParameterDefaultDescription
booleanis_enabled Required parameter Whether to enable the Blood Screen effect

Optimal

SetBloodScreenIntensity​

If you don't want the Blood Screen to be overridden by the default damage effect, disable it first with Viewport.SetBloodScreenEnabled(false)
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 Whether to enable the Crosshair

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 Which cursor shape to replace
Image Pathcursor_path Required parameter a PNG image relative to Assets/
Vector2Dhotspot?Vector(0, 0)
Click point of the cursor image, in pixels

Optimal

SetInteractionToolTipEnabled​

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

Parameters

TypeParameterDefaultDescription
booleanis_enabled Required parameter Whether to enable the Interaction ToolTip

Optimal

SetMousePosition​

Sets the mouse position
Viewport.SetMousePosition(new_position)

Parameters

TypeParameterDefaultDescription
Vector2Dnew_position Required parameter The new mouse position

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_sizeThe new screen size