CVR Host Functions
TL;DR: ~95 hand-written host functions bound into the WASM CVR module name. Grouped by subsystem. Each table lists the import name, a brief purpose, and the access mask the binding enforces. When the Scope column is blank, the binding uses the 2-axis CheckAccess (Object + Owner).
Conventions
Section titled “Conventions”- Import module:
CVRunless stated otherwise. - Signature shape is summarized; see the exact C# in
CVR.CCK.Wasm/Scripting/Links/APIs/Bindings/*Bindings.cs(and the shipped mirror atCVR-GameFiles/WasmScripting/*Bindings.cs) for parameter types. - Object column: Avatar / Prop / World / Any — which content types may call.
- Owner column: Self / Other / Any.
- Scope column: Self / ExternalContent / Any — only applies when the binding targets a specific wrapped object.
- The shipped decompile (
CVR-GameFiles/) lags the CCK source by a build or two. Where they disagree, the CCK source is the intended surface; import names flagged [new] are in the CCK bindings but not yet in the shipped decompile.
Player
Section titled “Player”Source: CVR.CCK.Wasm/Scripting/Links/APIs/Bindings/PlayerBindings.cs. Read-only information about any player in the instance. CVR_Player_GetUserId still needs the world permission AccessUserIdentity; CVR_Player_GetUsername was released from the gate as of Preview.27-WASM.27.
| Function | Purpose | Object | Owner | Scope |
|---|---|---|---|---|
CVR_Player_GetAllPlayers | array of all Player handles including local | World | Any | — |
CVR_Player_GetRemotePlayers | array of remote-only handles | World | Any | — |
CVR_Player_GetUserId | user ID (string); redacted to Guid.Empty without AccessUserIdentity | World | Any | — |
CVR_Player_GetUsername | display name (string) | World | Any | — |
CVR_Player_GetNetworkId | 16-bit network ID (for send addressing) | World | Any | — |
CVR_Player_GetGameObject | root GameObject handle | World | Any | — |
CVR_Player_GetViewPoint | Transform at head position | World | Any | — |
CVR_Player_GetVoicePoint | Transform at mouth position | World | Any | — |
CVR_Player_GetInitialHeight | initial scaled height (m) | World | Any | — |
CVR_Player_GetCurrentHeight | current scaled height (m) | World | Any | — |
CVR_Player_GetGravity | current gravity vector | World | Any | — |
CVR_Player_SetOriginPosition | teleport a player (not implemented) | World | Any | — |
CVR_Player_SetOriginRotation | rotate player origin (not implemented) | World | Any | — |
CVR_Player_GetWornAvatar | Avatar currently worn by this player | World | Any | — |
CVR_Player_GetSpawnedProps | array of Prop handles this player spawned | World | Any | — |
[WIP]
CVR_Player_SetOriginPositionandCVR_Player_SetOriginRotationboth throwNotImplementedExceptionin the current binding. UseCVR_LocalPlayer_SetPosition/SetRotation/SetPositionAndRotationfor the local player only.The shipped decompile (
CVR-GameFiles/WasmScripting/PlayerBindings.cs) still exports the older property-style names (CVR_Player_UserId,CVR_Player_Username,CVR_Player_NetworkId,CVR_Player_GameObject,CVR_Player_ViewPoint,CVR_Player_VoicePoint,CVR_Player_Gravity) and implementsCVR_Player_GetWornAvatarasreturn 0L. The CCK source replaces these withGet*names and a realAvatarDescriptorlookup. Expect one or two builds of mismatch during the property→method rename rollout; the CCK shim always points at the current host names.
Author-facing names: the CCK stub CCKStubs/PlayerCCK.cs exposes these bindings as player.GetUserId(), player.GetUsername(), player.GetNetworkId(), player.GetGameObject(), player.GetViewPoint(), player.GetVoicePoint(), player.GetWornAvatar(), player.GetSpawnedProps(), etc. Prefer the method form (makes marshalling cost obvious). See API Conventions.
LocalPlayer
Section titled “LocalPlayer”Source: CVR.CCK.Wasm/Scripting/Links/APIs/Bindings/LocalPlayerBindings.cs. The local player. All setters modify your own client only. Getters have no access check; every setter calls CheckAccess(World, Any) so only world scripts can drive the local player. Reads fall through PlayerSetup.Instance / BetterBetterCharacterController.Instance; the SetPosition / SetVelocity / SetRotation / SetPositionAndRotation setters route through BetterBetterCharacterController.
| Function | Purpose | Object | Owner | Scope |
|---|---|---|---|---|
CVR_LocalPlayer_PlayerObject | Player handle for self | any | any | — |
CVR_LocalPlayer_GetPlaySpaceScale | VR play-space scale | any | any | — |
CVR_LocalPlayer_GetPlaySpaceOffset | VR play-space offset | any | any | — |
CVR_LocalPlayer_GetPosition | camera rig position | any | any | — |
CVR_LocalPlayer_SetPosition | teleport local player | World | Any | — |
CVR_LocalPlayer_GetVelocity | current rig velocity | any | any | — |
CVR_LocalPlayer_SetVelocity | set rig velocity (e.g. impulse) | World | Any | — |
CVR_LocalPlayer_GetRotation | rig rotation | any | any | — |
CVR_LocalPlayer_SetRotation | set rig rotation | World | Any | — |
CVR_LocalPlayer_SetPositionAndRotation [new] | atomic position + rotation + optional ground refresh | World | Any | — |
CVR_LocalPlayer_SignalDiscontinuity [new] | bump continuity version — avatar dynamics + remote interp skip interpolation on next tick | World | Any | — |
CVR_LocalPlayer_OffsetBy | relative offset — currently throws NotImplementedException | World | Any | — |
CVR_LocalPlayer_MoveTo | smooth move-to — currently throws NotImplementedException | World | Any | — |
CVR_LocalPlayer_SetImmobilized | disable locomotion | World | Any | — |
CVR_LocalPlayer_IgnoreCollision [new] | toggle Physics.IgnoreCollision against every player collider | World | Any | Self |
CVR_LocalPlayer_SetHeadHiddenCamera [new] | head-hiding hook fires when the camera’s OnPreCull runs | World | Any | Self |
CVR_LocalPlayer_Respawn [new] | RootLogic.Instance.Respawn(true) | World | Any | — |
Entries tagged [new] are in the CCK source (Preview.27-WASM.25 / .26) but not yet in the shipped decompile at CVR-GameFiles/WasmScripting/LocalPlayerBindings.cs. Guest calls to those names on older clients hit FillNonLinkedWithEmptyStubs and silently no-op.
Author-facing CCK stub: CCKStubs/LocalPlayerCCK.cs.
Avatar
Section titled “Avatar”Source: CVR.CCK.Wasm/Scripting/Links/APIs/Bindings/AvatarBindings.cs. Both ObjectContexts are allowed — an avatar script can inspect its wearer’s avatar; a world script can inspect any avatar in the instance. The collision-exclude setters are world-only.
| Function | Purpose | Object | Owner | Scope |
|---|---|---|---|---|
CVR_Avatar_GetAllAvatars | array of currently worn avatars | any | any | — |
CVR_Avatar_GetCurrentAvatar | avatar owning the calling VM (Avatar context) | any | any | — |
CVR_Avatar_GetWearer | Player wearing an avatar | any | any | — |
CVR_Avatar_GetName | display name (Player.AvatarMetadata.AssetName) | any | any | — |
CVR_Avatar_GetContentId | CVR content ID (for identification) | any | any | — |
CVR_Avatar_GetRootObject [new] | root GameObject handle | any | any | — |
CVR_Avatar_GetRootTransform [new] | root Transform handle | any | any | — |
CVR_Avatar_SetCollisionExcludeLayers [new] | set the LayerMask of layers the avatar’s colliders ignore | World | Any | — |
CVR_Avatar_GetCollisionExcludeLayers [new] | read the current exclude mask | any | any | — |
CVR_Avatar_ResetCollisionExcludeLayers [new] | clear the exclude mask | World | Any | — |
Entries tagged [new] landed in the CCK source with Preview.27-WASM.27 (CVR.Avatar bindings live). The shipped decompile at CVR-GameFiles/WasmScripting/AvatarBindings.cs still contains empty stubs for the five original entries — on older clients, GetAllAvatars / GetCurrentAvatar / GetWearer / GetName / GetContentId do not return data.
AvatarPoint
Section titled “AvatarPoint”Source: AvatarPointBindings.cs. Query named anchor points on an avatar (e.g. head, hand) in various reference frames.
| Function | Purpose | Object | Owner | Scope |
|---|---|---|---|---|
CVR_AvatarPoint_GetPointTransform | Transform for the named point | Any | Any | — |
CVR_AvatarPoint_GetPointPosition | world-space position | Any | Any | — |
CVR_AvatarPoint_GetLocalPointPosition | local-space (avatar-rooted) | Any | Any | — |
CVR_AvatarPoint_GetRelativePointPosition | relative to another reference transform | Any | Any | — |
CVR_AvatarPoint_GetPointRotation | world-space rotation | Any | Any | — |
CVR_AvatarPoint_GetLocalPointRotation | local-space | Any | Any | — |
CVR_AvatarPoint_GetRelativePointRotation | relative | Any | Any | — |
CVR_AvatarPoint_GetPointForward | world-space forward vector | Any | Any | — |
CVR_AvatarPoint_GetPointRight | world-space right vector | Any | Any | — |
CVR_AvatarPoint_GetPointUp | world-space up vector | Any | Any | — |
Source: CVR.CCK.Wasm/Scripting/Links/APIs/Bindings/WorldBindings.cs.
| Function | Purpose | Object | Owner | Scope |
|---|---|---|---|---|
CVR_World_GetCurrentWorld | World handle for the loaded world | any | any | — |
CVR_World_GetName | display name | any | any | — |
CVR_World_GetContentId | CVR content ID | any | any | — |
All three are registered but have empty bodies in the current decompile and in the CCK source — calls compile and return without writing to the provided output pointers. Treat
World.Name/World.ContentId/World.GetCurrentWorld()as forward-looking until a future preview fills in the implementations.
Source: CVR.CCK.Wasm/Scripting/Links/APIs/Bindings/PropBindings.cs. Spawned object (CCK CVRSpawnable).
| Function | Purpose | Object | Owner | Scope |
|---|---|---|---|---|
CVR_Prop_GetAllProps | all spawned props in the instance | any | any | — |
CVR_Prop_GetCurrentProp | the prop owning the calling VM (Prop context) | any | any | — |
CVR_Prop_GetSpawner | Player who spawned it | any | any | — |
CVR_Prop_GetName [new] | display name (PropData.ContentMetadata.AssetName) | any | any | — |
CVR_Prop_GetContentId | CVR content ID | any | any | — |
CVR_Prop_GetRootObject | root GameObject | any | any | — |
CVR_Prop_GetRootTransform [new] | root Transform | any | any | — |
CVR_Prop_Destroy | despawn the prop | World | Prop | Self | — |
CVR_Prop_SetCollisionExcludeLayers [new] | set the LayerMask of layers the prop’s colliders ignore | World | Any | — |
CVR_Prop_GetCollisionExcludeLayers [new] | read the current exclude mask | any | any | — |
CVR_Prop_ResetCollisionExcludeLayers [new] | clear the exclude mask | World | Any | — |
The shipped decompile still exposes the old name CVR_Prop_GetTransform; the CCK source renamed this to CVR_Prop_GetRootTransform and added the GetName + collision-exclude-layers functions (Preview.27-WASM.23).
CVR_Prop_Destroy widened in Preview.27-WASM.27 from (World, Any) to (World | Prop, Self) — a prop script can now delete its own CVRSpawnable without going through the world VM.
Portal
Section titled “Portal”Source: CVR.CCK.Wasm/Scripting/Links/APIs/Bindings/PortalBindings.cs. World portals between instances/worlds. Getters run with no access check; only the two mutators call CheckAccess(World, Any).
| Function | Purpose | Object | Owner | Scope |
|---|---|---|---|---|
CVR_Portal_GetPosition | world-space position | any | any | — |
CVR_Portal_GetRotation | world-space rotation | any | any | — |
CVR_Portal_SetPosition | move the portal (if unanchored) | World | Any | — |
CVR_Portal_SetRotation | rotate the portal | World | Any | — |
CVR_Portal_IsAnchored | is the portal stuck to a surface | any | any | — |
CVR_Portal_GetSpawner | Player who dropped it | any | any | — |
CVR_Portal_GetRootObject | root GameObject | any | any | — |
CVR_Portal_GetTransform | root Transform | any | any | — |
Networking
Section titled “Networking”Source: CVR.CCK.Wasm/Scripting/Links/APIs/Bindings/NetworkingBindings.cs. No CheckAccess call on any binding; every ObjectContext can send and receive. See Networking for details.
| Function | Purpose | Object | Owner | Scope |
|---|---|---|---|---|
CVR_Networking_SendMessage | send bytes to one or more players (SendType = Unreliable/UnreliableSequenced/Reliable) | any | any | — |
CVR_Networking_WillMessageBeDropped | returns 1 if queuedBytes + size > 65536 (64 KB queue limit) | any | any | — |
CVR_Networking_NetworkCloggedPercentage | bytesSent / 16384 as a float — fraction of the spike budget currently in flight | any | any | — |
CVR_Networking_GetInstanceOwner | Player handle of the authoritative owner | any | any | — |
CVR_Networking_GetPing | NetworkManager.Instance.GameNetworkPing | any | any | — |
CVR_Networking_GetServerStartTime [new] | Unix timestamp (ms) when the game server started | any | any | — |
CVR_Networking_GetServerUptime [new] | Game server uptime in ms | any | any | — |
Receive side: the host dispatches incoming payloads by calling the guest export CVR_Networking_OnReceiveMessage(senderHandle, msgPtr, msgLen) on every message addressed to the local client (WasmVM.CallOnReceiveMessage, WasmNetworkManager.OnReceiveMessage). The guest-side shim surfaces this as the Networking.OnReceiveMessage delegate.
Budget constants (from CVR-GameFiles/WasmScripting/WasmNetworkManager.cs):
| Constant | Value | Meaning |
|---|---|---|
MaxBytesPerSecond | 4096 | Sustained send budget, drained per second of wall clock. |
MaxBytesSendSpike | 16384 | Instantaneous cap on in-flight bytes. A message may go over the sustained rate if the spike budget allows, and is held in the queue until it fits. |
MaxBytesQueued | 65536 | Total bytes allowed in the send queue. WillMessageBeDropped returns true when adding the proposed size would cross this. |
FileStorage
Section titled “FileStorage”Source: FileStorageLinks.cs. World-only. Requires the FileStorageApiAllowed world permission. See File Storage.
| Function | Purpose | Object | Owner | Scope |
|---|---|---|---|---|
FileStorage_ReadInternal_Full | read whole file | World | Any | — |
FileStorage_ReadInternal_Partial | read range | World | Any | — |
FileStorage_WriteInternal_Full | overwrite file | World | Any | — |
FileStorage_WriteInternal_Partial | partial write | World | Any | — |
FileStorage_DeleteFileInternal | delete file | World | Any | — |
FileStorage_RenameFileInternal | rename within this world | World | Any | — |
FileStorage_FileExistsInternal | existence probe | World | Any | — |
FileStorage_GetFilesInternal | list filenames | World | Any | — |
FileStorage_GetFileSizeInternal | size in bytes | World | Any | — |
FileStorage_GetTotalSizeInternal | total used bytes | World | Any | — |
FileStorage_GetTotalCapacityInternal | current quota limit | World | Any | — |
The guest-facing shim WasmScripting.FileStorage (CCKStubs/FileStorageCCK.cs) does not wrap the bindings with permission-helper methods — call WorldPermissions.Request(new WorldPermissions { FileStorageApiAllowed = true, ... }) yourself, then check WorldPermissions.CurrentPermissions.FileStorageApiAllowed before calling ReadFile / WriteFile / etc. The earlier CanUseFileStorage() / RequestUseFileStorage() helpers were removed in Preview.27-WASM.25.
Source: CVR.CCK.Wasm/Scripting/Links/APIs/Bindings/UtilBindings.cs.
| Function | Purpose | Object | Owner | Scope |
|---|---|---|---|---|
CVR_Proxies_IsDestroyed | returns 1 if the wrapped object no longer exists | any | any | — |
CVR_Utils_GetEpochTime | monotonic tick counter from WasmManager.EpochTime (100 kHz) | any | any | — |
CVR_Utils_AddWasmBehaviour | attach a WasmBehaviour at runtime and call its LateInitialize | World | Any | Self |
CVR_Utils_AddWasmBehaviour enforces Scope=Self: you can only attach behaviours to objects inside your own content root.
WasmUtils
Section titled “WasmUtils”Source: CVR.CCK.Wasm/Scripting/Links/APIs/Bindings/WasmUtilsBindings.cs. Exposes the host’s own CVRScriptScopeContext / CVRScriptOwnerContext evaluation so scripts can branch on permission outcome before calling a scope-gated API. No CheckAccess.
| Function | Purpose | Object | Owner | Scope |
|---|---|---|---|---|
CVR_WasmUtils_GetScopeContext | returns the scope flag for a wrapped handle (None / Self / ExternalContent) | any | any | — |
CVR_WasmUtils_GetOwnerContext | returns the owner flag for this VM (None / Self / Other) | any | any | — |
The shim adds a third helper, WasmUtils.GetObjectContext(), that reads the value set at VM construction (CVRScriptObjectContext.Avatar / Prop / World). It is returned guest-side without a host call.
WorldSettings
Section titled “WorldSettings”Source: CVR.CCK.Wasm/Scripting/Links/APIs/Bindings/WorldSettingsBindings.cs. Local-only toggles that drive CVR’s own visibility managers. Both setters call CheckAccess(World, Any).
| Function | Purpose | Object | Owner | Scope |
|---|---|---|---|---|
CVR_WorldSettings_SetPropVisibility | SpawnableManager.SetSpawnableVisibility(v) — hides remote props + blocks local spawning | World | Any | — |
CVR_WorldSettings_SetPlayerVisibility | CVRPlayerManager.Instance.SetRemotePlayerVisibility(v) — hides remote players + mutes voice for the local user | World | Any | — |
Both entries are in the CCK bindings source but not in the shipped CVR-GameFiles/WasmScripting/ decompile — on a client without them, the imports are stubbed to no-op.
WorldPermissions
Section titled “WorldPermissions”Source: CVR.CCK.Wasm/Scripting/Links/APIs/Bindings/PermissionsBindings.cs. See World Permissions.
| Function | Purpose | Object | Owner | Scope |
|---|---|---|---|---|
WorldPermissions_RequestPermissions | marshals a WorldPermissionsMarshalStruct from guest memory and opens the CVR permission prompt | World | Any | — |
Manual UnityEngine bindings
Section titled “Manual UnityEngine bindings”Source: CVR-GameFiles/WasmBinder.LinksManual.UnityEngine/. These aren’t CVR_* but worth listing alongside — they augment/override the generated UnityEngine bindings.
| File | Covers |
|---|---|
ObjectLinksManual.cs | Object.op_Equality, GetHashCode, Equals, ToString, 11 Instantiate overloads (all check World, Any, Self), Destroy, DestroyImmediate (both World, Any, Self) |
DebugLinksManual.cs | debug_log / debug_logWarning / debug_logError / debug_logException — all imported from module unity, not UnityEngine. Debug.LogException routes to Debug.LogError with the message |
GameObjectLinksManual.cs | AddComponent, GetComponent with type routing |
GraphicsBufferLinksManual.cs | GraphicsBuffer marshaling |
Not shown here
Section titled “Not shown here”Any call through UnityEngine / TMPro / UnityEngine.AI / Audio / Rendering / UI / SceneManagement goes through a generated binding — see UnityEngine Surface. Anything not in either table is either stubbed (safe no-op) or rejected at CCKWasmModule compile time.
Source
Section titled “Source”CVR.CCK.Wasm/Scripting/Links/APIs/Bindings/*.cs— current CCK-side host binding implementations.CVR-GameFiles/WasmScripting/*Bindings.cs— shipped counterpart (usually one or two builds behind).CVR-GameFiles/WasmScripting/BindingManager.cs— registration order.CVR-GameFiles/WasmScripting/WasmNetworkManager.cs— networking budget constants + send/receive paths.CVR-GameFiles/WasmBinder.LinksManual.UnityEngine/*.cs— manual UnityEngine override bindings.
Related
Section titled “Related”- Permissions — what the masks mean.
- CCK WasmModule — the shim wrapping all of this in idiomatic C#.
- Not Exposed — dangerous APIs you’ll not find here.