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

📺 Viewport

Work with screen properties and effects

🗿Static ClassClient Only🧑‍💻API Source

🗿 Static Functions​

DeprojectScreenToWorld: tableTransforms a 2D screen coordinates into 3D world-space location
GetMousePosition: Vector2DGets the current mouse screen location
GetViewportScale: floatGets the scale of viewport
GetViewportSize: Vector2DGets the size of viewport
ProjectWorldToScreen: Vector2DTransforms 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
Subscribe: functionSubscribes to an Event
UnsubscribeUnsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback

DeprojectScreenToWorldModerate​

Transforms a 2D screen coordinates into 3D world-space location

local ret = Viewport.DeprojectScreenToWorld(screen_position)
Parameters
NameTypeDescrição
screen_positionVector2DScreen position
Returns
TypeDescrição
tableTable with the world <code>Position</code> and the <code>Direction</code> the screen point looks at
Table keys
NameTypeDescrição
PositionVectorNo description provided
DirectionVectorNo description provided

GetMousePositionOptimal​

Gets the current mouse screen location

local ret = Viewport.GetMousePosition()
Returns
TypeDescrição
Vector2DThe current mouse screen location

See also SetMousePosition.

GetViewportScaleOptimal​

Gets the scale of viewport

local ret = Viewport.GetViewportScale()
Returns
TypeDescrição
floatThe scale of viewport

GetViewportSizeOptimal​

Gets the size of viewport

local ret = Viewport.GetViewportSize()
Returns
TypeDescrição
Vector2DThe size of viewport

ProjectWorldToScreenModerate​

Transforms a 3D world-space vector into 2D screen coordinates

local ret = Viewport.ProjectWorldToScreen(world_position)
Parameters
NameTypeDescrição
world_positionVectorWorld 3D position
Returns
TypeDescrição
Vector2DThe screen position, in pixels

SetBloodScreenEnabledOptimal​

Enables/Disables the Blood Screen effect

Viewport.SetBloodScreenEnabled(is_enabled)
Parameters
NameTypeDescrição
is_enabledbooleanWhether to enable the Blood Screen effect

SetBloodScreenIntensityOptimal​

Manually sets the Blood Screen intensity

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
NameTypeDescrição
intensityfloatFrom 0.0 to 1.0

SetBrandingBarSettingsOptimal​

Sets the Branding Bar settings (the bar with 'nanos world - closed alpha ver...')

Viewport.SetBrandingBarSettings(horizontal_alignment, vertical_alignment, is_lean?)
Parameters
NameTypeDescrição
horizontal_alignmentWidgetHorizontalAlignmentLeft, Center and Right supported
vertical_alignmentWidgetVerticalAlignmentBottom and Top supported
is_lean?booleanWhether to show less information Default false

SetCrosshairEnabledOptimal​

Enables/Disables the Crosshair

Viewport.SetCrosshairEnabled(is_enabled)
Parameters
NameTypeDescrição
is_enabledbooleanWhether to enable the Crosshair

SetHardwareCursorSlow​

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
NameTypeDescrição
cursor_shapeCursorTypeWhich cursor shape to replace
cursor_pathImage Patha PNG image relative to Assets/
hotspot?Vector2DClick point of the cursor image, in pixels Default Vector(0, 0)

SetInteractionToolTipEnabledOptimal​

Enables/Disables the Interaction ToolTip

Viewport.SetInteractionToolTipEnabled(is_enabled)
Parameters
NameTypeDescrição
is_enabledbooleanWhether to enable the Interaction ToolTip

SetMousePositionOptimal​

Sets the mouse position

Viewport.SetMousePosition(new_position)
Parameters
NameTypeDescrição
new_positionVector2DThe new mouse position

See also GetMousePosition.

SubscribeOptimal​

Subscribes to an Event

local ret = Viewport.Subscribe(event_name, callback)
Parameters
NameTypeDescrição
event_namestringEvent to subscribe to
callbackfunctionCallback to run on the event occurring
Returns
TypeDescrição
functionThe function callback

UnsubscribeOptimal​

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
NameTypeDescrição
event_namestringEvent to unsubscribe to
callback?functionOptional callback to specifically unsubscribe to Default nil

🚀 Events​

ResizeCalled when the screen is resized

Resize​

Called when the screen is resized

Viewport.Subscribe("Resize", function(new_size)
-- Resize was called
end)
Arguments
NameTypeDescrição
new_sizeVector2DThe new screen size