LUADOC - Farming Simulator 22

DebugPath

Functions

addPoint

Description
Definition
addPoint()
Code
63function DebugPath:addPoint(x, y, z)
64 local addPoint = true
65 if self.autoAddOffset ~= nil then
66 local p = self.points[#self.points]
67 if p ~= nil then
68 local distance = MathUtil.vector3Length(p[1]-x, p[2]-y, p[3]-z)
69 if distance < self.autoAddOffset then
70 addPoint = false
71 end
72 end
73 end
74
75 if addPoint then
76 table.insert(self.points, {x, y, z})
77 end
78
79 return self
80end

clear

Description
Definition
clear()
Code
90function DebugPath:clear()
91 self.points = {}
92end

delete

Description
Definition
delete()
Code
31function DebugPath:delete()
32end

draw

Description
Definition
draw()
Code
41function DebugPath:draw(forcedY)
42 if self.isVisible then
43 local r, g, b = unpack(self.color)
44
45 for k, p in ipairs(self.points) do
46 local np = self.points[k+1]
47 if np ~= nil then
48 local px, py, pz = p[1], p[2], p[3]
49 local npx, npy, npz = np[1], np[2], np[3]
50 if self.alignToGround then
51 py = getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, px, 0, pz) + 0.025
52 npy = getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, npx, 0, npz) + 0.025
53 end
54
55 drawDebugLine(px, forcedY or py, pz, r, g, b, npx, forcedY or npy, npz, r, g, b, self.solid)
56 end
57 end
58 end
59end

new

Description
Definition
new()
Code
16function DebugPath.new(color, alignToGround, autoAddOffset, solid, customMt)
17 local self = setmetatable({}, customMt or DebugPath_mt)
18
19 self.color = color or {1, 1, 1}
20 self.points = {}
21 self.isVisible = true
22 self.alignToGround = Utils.getNoNil(alignToGround, false)
23 self.autoAddOffset = autoAddOffset
24 self.solid = Utils.getNoNil(solid, true)
25
26 return self
27end

setColor

Description
Definition
setColor()
Code
96function DebugPath:setColor(r, g, b)
97 self.color[1] = r or self.color[1]
98 self.color[2] = g or self.color[2]
99 self.color[3] = b or self.color[3]
100
101 return self
102end

setVisible

Description
Definition
setVisible()
Code
84function DebugPath:setVisible(isVisible)
85 self.isVisible = isVisible
86end

update

Description
Definition
update()
Code
36function DebugPath:update(dt)
37end