Setsafeenv

From GiderosMobile

Available since: Gideros 2011.6
Class: (global)

Description

Sets a safe environment to be used by the given function.

(varies) = setsafeenv(flags)

Gideros 2025.2 introduces a new global function setsafeenv(flags) which tells Luau the global environment is "safe" and so enables optimizations. flags parameter indicates which optimizations to enable, and you'll probably want them all by using -1 value.

flags can be a Lua function or a number that specifies the function at that stack level: Level 1 is the function calling setsafeenv. setsafeenv returns the given function.

As a special case, when f is 0 setsafeenv changes the environment of the running thread. In this case, setsafeenv returns no values.

Parameters

flags: (varies) function or number(call stack level)

Return values

Returns (varies) returns provided function or nil

Example

setsafeenv(-1)

Reference

https://github.com/gideros/gideros/blob/master/winrt_xaml/giderosgame/giderosgame.Shared/lua.h#L209