LUADOC - Farming Simulator 22

DebugFlag

Functions

create

Description
Definition
create()
Code
80function DebugFlag:create(x, y, z, dirX, dirZ)
81 self.x, self.y, self.z = x, y, z
82 self.dirX, self.dirZ = dirX, dirZ
83
84 return self
85end

draw

Description
Definition
draw()
Code
51function DebugFlag:draw()
52 local x, y, z = self.x, self.y, self.z
53 local tx = x + self.dirX * self.flagLength
54 local tz = z + self.dirZ * self.flagLength
55
56 local r = self.r
57 local g = self.g
58 local b = self.b
59
60 drawDebugLine(x, y, z, r, g, b, x, y+self.height, z, r, g, b)
61
62 local posYStart = y + self.height - self.flagHeight
63 local posYEnd = y + self.height
64 for i=1, self.numSectionsZ do
65 local offset = self.flagLength * (i / self.numSectionsZ)
66 local lx = x + self.dirX * offset
67 local lz = z + self.dirZ * offset
68 drawDebugLine(lx, posYStart, lz, r, g, b, lx, posYEnd, lz, r, g, b)
69 end
70
71 for i=0, self.numSectionsY do
72 local offset = self.flagHeight * (i / self.numSectionsY)
73 local ly = posYStart + offset
74 drawDebugLine(x, ly, z, r, g, b, tx, ly, tz, r, g, b)
75 end
76end

new

Description
Definition
new()
Code
16function DebugFlag.new(r, g, b, customMt)
17 local self = setmetatable({}, customMt or DebugFlag_mt)
18
19 self.x, self.y, self.z = 0, 0, 0
20 self.dirX, self.dirZ = 0, 1
21 self.r = r or 0
22 self.g = g or 0
23 self.b = b or 0
24
25 self.height = 4
26 self.flagHeight = 0.7
27 self.flagLength = 1
28
29 self.numSectionsY = 4
30 self.numSectionsZ = 6
31
32 return self
33end