Skip to content

FxVoxel ​

This module contains functions for creating and editing FoxelVoxel values.

Load ​

lua
FxVoxel = require "FxVoxel";

Functions ​

FunctionDescription
Create (Color, Material)Creates a voxel.
Flip (Voxel, Axis)Flips a voxel.
GetColor (Voxel)Returns the color of a voxel.
GetMaterial (Voxel)Returns the material of a voxel.
GetRotation (Voxel)Returns the rotation of a voxel.
GetShape (Voxel)Returns the shape of a voxel.
Rotate90 (Voxel, Axis, Steps)Rotates a voxel in 90° steps.
SetColor (Voxel, Value)Sets the color of a voxel.
SetMaterial (Voxel, Value)Sets the material of a voxel.
SetRotation (Voxel, Value)Sets the rotation of a voxel.
SetShape (Voxel, Value)Sets the shape of a voxel.

Create (Color, Material) ​

This function creates a voxel from the given color and material ItemIndex. All other properties are set to their default values.

Parameters ​

Returns ​

The created FoxelVoxel

Errors ​

Possible errors include FX_ITEM_INDEX_INVALID

Since ​

Version 1.0

Example ​

lua
voxel = FxVoxel.Create(10, 0);

Flip (Voxel, Axis) ​

This function flips a voxel along the given axis and returns the updated voxel.

Parameters ​

Returns ​

The updated FoxelVoxel

Errors ​

Possible errors include FX_VALUE_INVALID

Since ​

Version 1.0

Example ​

lua
-- flip voxel along x-axis
voxel = FxVoxel.Flip(voxel, 0);

GetColor (Voxel) ​

This function returns the color ItemIndex of the given voxel. This index can be used for example with FxColorPalette to get the color properties.

Parameters ​

Returns ​

The color ItemIndex of the voxel

Errors ​

Possible errors include FX_VALUE_INVALID

Since ​

Version 1.0

Example ​

lua
colorid = FxVoxel.GetColor(voxel); 
color = FxColorPalette.GetItemColor(colorid);

GetMaterial (Voxel) ​

This function returns the material of the given voxel. This index can be used for example with FxMaterialSet to get the material properties.

Parameters ​

Returns ​

The material ItemIndex of the voxel

Errors ​

Possible errors include FX_VALUE_INVALID

Since ​

Version 1.0

Example ​

lua
material = FxVoxel.GetMaterial(voxel); 
metallic = FxMaterialMap.GetItemMetallic(material);

GetRotation (Voxel) ​

This function returns the cube rotation of the given voxel.

Parameters ​

Returns ​

The CubeRotation of the voxel

Errors ​

Possible errors include FX_VALUE_INVALID

Since ​

Version 1.0

Example ​

lua
rotation = FxVoxel.GetRotation(voxel);

GetShape (Voxel) ​

This function returns the shape of the given voxel.

Parameters ​

Returns ​

The VoxelShape of the voxel

Errors ​

Possible errors include FX_VALUE_INVALID

Since ​

Version 1.0

Example ​

lua
shape = FxVoxel.GetShape(voxel);

Rotate90 (Voxel, Axis, Steps) ​

This function rotates the voxel around the given axis and returns the updated voxel.

Parameters ​

  • Voxel: The FoxelVoxel to rotate
  • Axis: The rotation Axis3D
  • Steps: The number of 90° rotation steps

Returns ​

The updated FoxelVoxel

Errors ​

Possible errors include FX_VALUE_INVALID

Since ​

Version 1.0

Example ​

lua
-- rotate voxel 180° around y-axis
voxel = FxVoxel.Rotate90(voxel, 1, 2);

SetColor (Voxel, Value) ​

This function changes the color of the given voxel and returns the updated voxel.

Parameters ​

Returns ​

The updated FoxelVoxel

Errors ​

Possible errors include FX_VALUE_INVALID, FX_ITEM_INDEX_INVALID

Since ​

Version 1.0

Example ​

lua
voxel = FxVoxel.SetColor(voxel, 100);

SetMaterial (Voxel, Value) ​

This function changes the material of the given voxel and returns the updated voxel.

Parameters ​

Returns ​

The updated FoxelVoxel

Errors ​

Possible errors include FX_VALUE_INVALID, FX_ITEM_INDEX_INVALID

Since ​

Version 1.0

Example ​

lua
voxel = FxVoxel.SetMaterial(voxel, 2);

SetRotation (Voxel, Value) ​

This function changes the rotation of the given voxel and returns the updated voxel.

Parameters ​

Returns ​

The updated FoxelVoxel

Errors ​

Possible errors include FX_VALUE_INVALID

Since ​

Version 1.0

Example ​

lua
voxel = FxVoxel.SetRotation(voxel, 15);

SetShape (Voxel, Value) ​

This function changes the shape of the given voxel and returns the updated voxel.

Parameters ​

Returns ​

The updated FoxelVoxel

Errors ​

Possible errors include FX_VALUE_INVALID

Since ​

Version 1.0

Example ​

lua
voxel = FxVoxel.SetShape(voxel, 2);