Skip to content

Globals

Here you have properties and functions available to every script.

Some bindings are provided by dedicated modules. You can access these modules by requiring them in your script.

FunctionDescription
require(moduleName)Adding modules to be available to Lua script.
  • System
  • UnityEngine
  • UnityEngine.AI
  • UnityEngine.UI
  • CVR
  • CVR.Network
  • CVR.CCK
  • TextMeshPro
  • RCC
-- Top of your script
UnityEngine = require("UnityEngine") -- Access to UnityEngine bindings
CCK = require("CVR.CCK") -- Access to CCK component bindings
-- Usage in script
local coolVector = UnityEngine.NewVector3(1, 2, 3)
FunctionDescription
IsValid(object) : boolDetermines whether a given System object, Unity Object, or API Object (Like Player or Avatar) is null or not.
It uses Unity’s specific null check for Unity Objects to ensure accurate validation.
PropertyDescription
nameAccess to the attached gameObject name.
gameObjectAccess to the attached gameObject.
transformAccess to the attached transform.

Most MonoBehaviour Events are also available.

PropertyDescription
HashSHA512 hash of script text as Base64 string.
RunningOnServerTrue when running on server.
RunningOnClientTrue when running on client.
RunningInAvatarTrue when running on an avatar.
RunningInPropTrue when running on a prop.
RunningInWorldTrue when running in a world.
IsWornByMeDefined when running on an Avatar. True for the avatar wearer. False for others.
IsSpawnedByMeDefined when running on a Prop. True for the spawner. False for others.
BoundObjectsAccess to the Bound Objects assigned on the CVRLuaClientBehaviour script in editor.
ScriptReference to the currently running script. Example: Script.Destroy(“boom”)
StorageAccess to the local data persistence system.
APIDescriptionExample
PlayerAPIAccess to the PlayerAPI.Example: PlayerAPI.LocalPlayer.Respawn()
InstancesAPIAccess to the InstancesAPI.Example: print(InstancesAPI.Ping)
AvatarAPIAccess to the AvatarAPI.Example: print(AvatarAPI.LocalAvatar)
SpawnableAPIAccess to the SpawnableAPI.Example: print(#SpawnableAPI.AllSpawnables)
WorldAPIAccess to the WorldAPI.Example: print(WorldAPI.WorldID)