diff --git a/Radar.lua b/Radar.lua index 8474444..7bc9e1e 100644 --- a/Radar.lua +++ b/Radar.lua @@ -165,42 +165,42 @@ local function GetNodeInfo(objectId) return nodes[objectId] end +-- Define the crystal shape once, outside of the function +local baseSize = 1.5 +local height = 3 +local halfHeight = height / 2 + +local crystal_shape = { + -- Lines from v1 to v2, v3, v4, v5 + {0, 0, 0, -baseSize, -baseSize, halfHeight}, + {0, 0, 0, baseSize, -baseSize, halfHeight}, + {0, 0, 0, baseSize, baseSize, halfHeight}, + {0, 0, 0, -baseSize, baseSize, halfHeight}, + + -- Lines between v2-v3, v3-v4, v4-v5, v5-v2 + {-baseSize, -baseSize, halfHeight, baseSize, -baseSize, halfHeight}, + { baseSize, -baseSize, halfHeight, baseSize, baseSize, halfHeight}, + { baseSize, baseSize, halfHeight, -baseSize, baseSize, halfHeight}, + {-baseSize, baseSize, halfHeight, -baseSize, -baseSize, halfHeight}, + + -- Lines from v2, v3, v4, v5 to v6 + {-baseSize, -baseSize, halfHeight, 0, 0, height}, + { baseSize, -baseSize, halfHeight, 0, 0, height}, + { baseSize, baseSize, halfHeight, 0, 0, height}, + {-baseSize, baseSize, halfHeight, 0, 0, height}, +} + +-- Modify the DrawCrystalNode function local function DrawCrystalNode(draw, nx, ny, nz, color) - draw:SetColor(unpack(color)) + draw:SetColor(color) draw:SetWidth(2) draw:SetAlpha(200) - local baseSize = 1.5 - local height = 3 local bobHeight = math.sin(GetTime() * 4) * 0.5 local baseZ = nz + 5 + bobHeight - -- Bottom pyramid - local v1 = {nx, ny, baseZ} - local v2 = {nx - baseSize, ny - baseSize, baseZ + height/2} - local v3 = {nx + baseSize, ny - baseSize, baseZ + height/2} - local v4 = {nx + baseSize, ny + baseSize, baseZ + height/2} - local v5 = {nx - baseSize, ny + baseSize, baseZ + height/2} - - -- Top pyramid - local v6 = {nx, ny, baseZ + height} - - -- Draw bottom pyramid - draw:Line(v1[1], v1[2], v1[3], v2[1], v2[2], v2[3]) - draw:Line(v1[1], v1[2], v1[3], v3[1], v3[2], v3[3]) - draw:Line(v1[1], v1[2], v1[3], v4[1], v4[2], v4[3]) - draw:Line(v1[1], v1[2], v1[3], v5[1], v5[2], v5[3]) - - draw:Line(v2[1], v2[2], v2[3], v3[1], v3[2], v3[3]) - draw:Line(v3[1], v3[2], v3[3], v4[1], v4[2], v4[3]) - draw:Line(v4[1], v4[2], v4[3], v5[1], v5[2], v5[3]) - draw:Line(v5[1], v5[2], v5[3], v2[1], v2[2], v2[3]) - - -- Draw top pyramid - draw:Line(v2[1], v2[2], v2[3], v6[1], v6[2], v6[3]) - draw:Line(v3[1], v3[2], v3[3], v6[1], v6[2], v6[3]) - draw:Line(v4[1], v4[2], v4[3], v6[1], v6[2], v6[3]) - draw:Line(v5[1], v5[2], v5[3], v6[1], v6[2], v6[3]) + -- Use the pre-defined crystal_shape and position offsets + draw:Array(crystal_shape, nx, ny, baseZ) -- Draw a small sphere at the top for emphasis draw:Circle(nx, ny, baseZ + height + 0.5, 0.3) @@ -226,7 +226,7 @@ local function DrawNode(draw, nodeInfo, nx, ny, nz, objectId) DrawCrystalNode(draw, nx, ny, nz, color) if Builder:GetConfig("draw_lines") == "yes" then - draw:SetColor(unpack(color)) + draw:SetColor(color) draw:Line(px, py, pz, nx, ny, nz) end