natiny.script.to_handle

Lua
natiny.script.to_handle(value) -> number

Reads a value as a handle. A number is itself - which is what an engine handle is in Lua - and anything else is 0.

Parameters

Name Type Description
value any What to read

Returns

Type Description
number The handle, or 0 for anything that is not one

Example

Lua
local window = natiny.script.to_handle(natiny.script.get(mod, "game.window"))

if window ~= 0 then
    natiny.window.bind(window, draw_overlay)
end