Voxel Struct
advanced scriptingVoxel 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 itbool hasContent- Property, returns true if the voxel is not emptybool isEmpty- Property derived fromtypeIndex. Returns true when the voxel holds no content (holes included); setting it updatestypeIndexaccordinglybool isHole- Property, true whentypeIndexequals the reserved hole index; setting it to true turns the voxel into a holebool isSolid- Read-only property, true when the voxel is fully opaqueVoxelDefinition 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 intensitiesint 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 colorbool isColored- Returns true if a non-white tint is appliedbool 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 amountbool hasWater- Indicates water presenceint GetTextureRotation()- Returns rotation index (0=0, 1=90, 2=180, 3=270 degrees)float GetTextureRotationDegrees()- Returns rotation in degreesvoid SetTextureRotation(int value)- Sets rotation index
Methods
void Clear(byte light)- Clear voxel to empty statestatic void Clear(Voxel[] voxels, byte light)- Clear array of voxelsvoid Set(VoxelDefinition type)- Set voxel type without tintvoid Set(VoxelDefinition type, Color32 tintColor)- Set voxel type with tint color
Constants
Voxel.Empty- Represents an empty voxelVoxel.Hole- Represents a hole voxelint memorySize- Memory size per voxel (10 bytes with tinting, 7 without)
Was this page helpful?
Suggest an improvement
Help us improve this documentation page.