Voxel Struct

advanced scripting

Voxel Play 4 · Scripting / API

Overview

The Voxel struct defines any voxel in Voxel Play 4 inside a chunk. It is implemented as a partial structure allowing additional fields in separate files.

Fields and Properties

Content and Type

  • ushort typeIndex - Index to the voxel definitions array. This is the stored value; the flags below are computed from it
  • bool hasContent - Property, returns true if the voxel is not empty
  • bool isEmpty - Property derived from typeIndex. Returns true when the voxel holds no content (holes included); setting it updates typeIndex accordingly
  • bool isHole - Property, true when typeIndex equals the reserved hole index; setting it to true turns the voxel into a hole
  • bool isSolid - Read-only property, true when the voxel is fully opaque
  • VoxelDefinition type - Returns the voxel definition object

Note: hasContent, isEmpty, isHole and isSolid are convenience properties computed from typeIndex and the opacity value. The struct does not store separate boolean flags.

Light Properties

  • byte opaque - Ranges 0-15 for opacity levels (0 = transparent, >0 = opaque with light reduction)
  • byte light - Sun light amount (0-15)
  • byte torchLight - Torch light amount (0-15)
  • int packedLight - Packed Sun and Torch light intensities
  • int lightOrTorch - Max of light and torchLight

Color / Tinting

  • byte red, byte green, byte blue - RGB tint values (255 when tinting is not enabled)
  • Color32 color - Retrieve/set tint color
  • bool isColored - Returns true if a non-white tint is applied
  • bool supportsTinting (static) - Whether tinting is enabled in the project

Water and Rotation

  • int GetWaterLevel() - Returns water amount (0-15)
  • void SetWaterLevel(int value) - Sets water amount
  • bool hasWater - Indicates water presence
  • int GetTextureRotation() - Returns rotation index (0=0, 1=90, 2=180, 3=270 degrees)
  • float GetTextureRotationDegrees() - Returns rotation in degrees
  • void SetTextureRotation(int value) - Sets rotation index

Methods

  • void Clear(byte light) - Clear voxel to empty state
  • static void Clear(Voxel[] voxels, byte light) - Clear array of voxels
  • void Set(VoxelDefinition type) - Set voxel type without tint
  • void Set(VoxelDefinition type, Color32 tintColor) - Set voxel type with tint color

Constants

  • Voxel.Empty - Represents an empty voxel
  • Voxel.Hole - Represents a hole voxel
  • int memorySize - Memory size per voxel (10 bytes with tinting, 7 without)
Was this page helpful?