Skip to content

DrawLine

The DrawLine function draws a line between two points in 3D space. This function is useful for visualizing connections or paths between points in the game world.

Parameters

  • x1 (number): The x-coordinate of the starting point.
  • y1 (number): The y-coordinate of the starting point.
  • z1 (number): The z-coordinate of the starting point.
  • x2 (number): The x-coordinate of the ending point.
  • y2 (number): The y-coordinate of the ending point.
  • z2 (number): The z-coordinate of the ending point.
  • 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).
  • thickness (number): The thickness of the line.

Example Usage in Lua

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

local api = ...

-- Function to draw a yellow line with specified thickness between two points
function DrawYellowLine(x1, y1, z1, x2, y2, z2, thickness)
    local r = 1.0
    local g = 1.0
    local b = 0.0
    local a = 1.0
    api.DrawLine(x1, y1, z1, x2, y2, z2, r, g, b, a, thickness)
    print("Drew a yellow line from (" .. x1 .. ", " .. y1 .. ", " .. z1 .. ") to (" .. x2 .. ", " .. y2 .. ", " .. z2 .. ") with thickness " .. thickness)
end

-- Example usage: Draw a yellow line from (0, 0, 0) to (10, 10, 10) with thickness 2
DrawYellowLine(0, 0, 0, 10, 10, 10, 2)