Skip to content

DrawFilledCube

The DrawFilledCube function draws a filled cube in 3D space. This function is useful for visualizing solid cubic areas or regions in the game world.

Parameters

  • x (number): The x-coordinate of the cube's origin.
  • y (number): The y-coordinate of the cube's origin.
  • z (number): The z-coordinate of the cube's origin.
  • length (number): The length of the cube.
  • width (number): The width of the cube.
  • height (number): The height of the cube.
  • r (number): The red color component (0.0 to 1.0).
  • g (number): The green color component (0.0 to 1.0).
  • b (number): The blue color component (0.0 to 1.0).
  • a (number): The alpha (transparency) value (0.0 to 1.0).
  • facing_target (string, optional): The unit the cube should face.

Example Usage in Lua

Here is an example of how to use the DrawFilledCube function in Lua:

local api = ...

-- Function to draw a red filled cube with specified dimensions and color at the given coordinates
function DrawRedFilledCube(x, y, z, length, width, height)
    local r = 1.0
    local g = 0.0
    local b = 0.0
    local a = 1.0
    api.DrawFilledCube(x, y, z, length, width, height, r, g, b, a)
    print("Drew a red filled cube at (" .. x .. ", " .. y .. ", " .. z .. ") with dimensions " .. length .. "x" .. width .. "x" .. height)
end

-- Example usage: Draw a red filled cube at coordinates (10, 20, 30) with dimensions 5x5x5
DrawRedFilledCube(10, 20, 30, 5, 5, 5)