Sleepless

Object GizmoExports

Client Exports

Last updated on

Client exports for opening the gizmo and reading the transform the player settled on. Option fields are documented on Call Options.

The resource also emits local events. They are not networked.

EventArgumentsWhen
object_gizmo:client:editStartedentityThe gizmo has opened.
object_gizmo:client:editFinishedresultThe gizmo has closed. result matches the useGizmo return.
AddEventHandler('object_gizmo:client:editFinished', function(result)
    if not result.confirmed then return end
    TriggerServerEvent('myresource:server:savedPlacement', result.position, result.rotation)
end)

useGizmo

Opens the gizmo on an entity and blocks until the player finishes, cancels, or the entity disappears.

local result = exports.object_gizmo:useGizmo(entity)
local result = exports.object_gizmo:useGizmo(entity, options)
local result = exports.object_gizmo:useGizmo(entity, distanceLimit)

Parameters

ParameterTypeDescription
entitynumberEntity handle to edit.
optionstable | numberCall options, or a distance limit in metres.

Returns

Always a table.

FieldTypeDescription
handlenumberThe entity that was edited.
positionvector3Entity coordinates when the gizmo closed. After a cancel with restore, this is the original position.
rotationvector3Entity rotation when the gizmo closed.
cancelledbooleantrue when the player cancelled, the gizmo was already open, or the entity was invalid.
confirmedbooleantrue when the player finished with the confirm control.

Calling useGizmo while one is already open returns immediately with cancelled = true and does not change the open edit.

Example

local result = exports.object_gizmo:useGizmo(object, {
    camera = 'gameplay',
    pivot = 'center',
    bounds = roomZone,
})

if result.confirmed then
    lib.print.info(result.position, result.rotation)
end

isGizmoActive

local active = exports.object_gizmo:isGizmoActive()

Returns

TypeDescription
booleantrue while a gizmo session is open.

cancelGizmo

Cancels the open gizmo. When restore-on-cancel is enabled, the entity returns to the transform it had when the gizmo opened.

exports.object_gizmo:cancelGizmo()

Does nothing if no gizmo is open.


confirmGizmo

Finishes the open gizmo and keeps the current transform.

exports.object_gizmo:confirmGizmo()

Does nothing if no gizmo is open.

On this page