LUADOC - Farming Simulator 19

FillPlane

Functions

delete

Description
Destructor
Definition
delete()
Code
34function FillPlane:delete()
35end

initDataStructures

Description
Init class members
Definition
initDataStructures()
Code
39function FillPlane:initDataStructures()
40 self.node = nil
41 self.maxCapacity = 0
42 self.moveMinY = 0
43 self.moveMaxY = 0
44 self.loaded = false
45 self.colorChange = false
46end

load

Description
Loads fill plane
Definition
load(table rootNode, string xmlFile, string xmlNode)
Arguments
tablerootNodeof the object
stringxmlFilefile to read
stringxmlNodexmlNode to read from
Code
53function FillPlane:load(rootNode, xmlFile, xmlNode)
54 local fillPlaneNodeStr = XMLUtil.getValueFromXMLFileOrUserAttribute(xmlFile, xmlNode, "node", getXMLString, rootNode)
55
56 if fillPlaneNodeStr ~= nil then
57 local fillPlaneNode = I3DUtil.indexToObject(rootNode, fillPlaneNodeStr)
58
59 if fillPlaneNode ~= nil then
60 self.node = fillPlaneNode
61 self.moveMinY = Utils.getNoNil(XMLUtil.getValueFromXMLFileOrUserAttribute(xmlFile, xmlNode, "minY", getXMLFloat, rootNode), 0)
62 self.moveMaxY = Utils.getNoNil(XMLUtil.getValueFromXMLFileOrUserAttribute(xmlFile, xmlNode, "maxY", getXMLFloat, rootNode), 0)
63 self.colorChange = Utils.getNoNil(XMLUtil.getValueFromXMLFileOrUserAttribute(xmlFile, xmlNode, "colorChange", getXMLBool, rootNode), false)
64 assert(self.moveMinY <= self.moveMaxY)
65 self.loaded = self.node ~= nil
66 local x, _, z = getTranslation(self.node)
67 setTranslation(self.node, x, self.moveMinY, z)
68 end
69 end
70end

new

Description
Creates a new instance of the class
Definition
new(table customMt)
Arguments
tablecustomMtmeta table
Return Values
tableselfreturns the instance
Code
23function FillPlane:new(customMt)
24 local self = {}
25 setmetatable(self, customMt or FillPlane_mt)
26
27 self:initDataStructures()
28
29 return self
30end

setColorScale

Description
Sets fill plane color shader
Definition
setColorScale(float[] a)
Arguments
float[]afloat array for r, g, b
Code
92function FillPlane:setColorScale(colorScale)
93 if self.loaded then
94 setShaderParameter(self.node, "colorScale", colorScale[1], colorScale[2], colorScale[3], 0, false)
95 end
96end

setState

Description
Changes fill levels visuals
Definition
setState(table instance)
Arguments
tableinstancetarget to check fillLevel
Return Values
booltrueif level has changed
Code
76function FillPlane:setState(state)
77 if self.loaded then
78 local delta = self.moveMaxY - self.moveMinY
79 local y = math.min(self.moveMinY + delta * state, self.moveMaxY)
80 local x, oldY, z = getTranslation(self.node)
81 setTranslation(self.node, x, y, z)
82
83 return oldY ~= y
84 end
85
86 return false
87end