26 | function FarmlandStatisticCounter:loadFromItemsXML(xmlFile, key) |
27 | self.numSoilSamples = xmlFile:getInt(key .. "#numSoilSamples", self.numSoilSamples) |
28 | self.soilSampleCosts = xmlFile:getFloat(key .. "#soilSampleCosts", self.soilSampleCosts) |
29 | |
30 | self.usedLime = xmlFile:getFloat(key .. "#usedLime", self.usedLime) |
31 | self.usedLimeRegular = xmlFile:getFloat(key .. "#usedLimeRegular", self.usedLimeRegular) |
32 | |
33 | self.usedMineralFertilizer = xmlFile:getFloat(key .. "#usedMineralFertilizer", self.usedMineralFertilizer) |
34 | self.usedMineralFertilizerRegular = xmlFile:getFloat(key .. "#usedMineralFertilizerRegular", self.usedMineralFertilizerRegular) |
35 | |
36 | self.usedLiquidFertilizer = xmlFile:getFloat(key .. "#usedLiquidFertilizer", self.usedLiquidFertilizer) |
37 | self.usedLiquidFertilizerRegular = xmlFile:getFloat(key .. "#usedLiquidFertilizerRegular", self.usedLiquidFertilizerRegular) |
38 | |
39 | self.usedManure = xmlFile:getFloat(key .. "#usedManure", self.usedManure) |
40 | self.usedManureRegular = xmlFile:getFloat(key .. "#usedManureRegular", self.usedManureRegular) |
41 | |
42 | self.usedLiquidManure = xmlFile:getFloat(key .. "#usedLiquidManure", self.usedLiquidManure) |
43 | self.usedLiquidManureRegular = xmlFile:getFloat(key .. "#usedLiquidManureRegular", self.usedLiquidManureRegular) |
44 | |
45 | self.usedSeeds = xmlFile:getFloat(key .. "#usedSeeds", self.usedSeeds) |
46 | self.usedSeedsRegular = xmlFile:getFloat(key .. "#usedSeedsRegular", self.usedSeedsRegular) |
47 | |
48 | self.usedHerbicide = xmlFile:getFloat(key .. "#usedHerbicide", self.usedHerbicide) |
49 | self.usedHerbicideRegular = xmlFile:getFloat(key .. "#usedHerbicideRegular", self.usedHerbicideRegular) |
50 | |
51 | self.yield = xmlFile:getFloat(key .. "#yield", self.yield) |
52 | self.yieldRegular = xmlFile:getFloat(key .. "#yieldRegular", self.yieldRegular) |
53 | self.yieldWeight = xmlFile:getFloat(key .. "#yieldWeight", self.yieldWeight) |
54 | self.yieldBestPrice = xmlFile:getFloat(key .. "#yieldBestPrice", self.yieldBestPrice) |
55 | |
56 | self.usedFuel = xmlFile:getFloat(key .. "#usedFuel", self.usedFuel) |
57 | self.vehicleCosts = xmlFile:getFloat(key .. "#vehicleCosts", self.vehicleCosts) |
58 | |
59 | self.helperCosts = xmlFile:getFloat(key .. "#helperCosts", self.helperCosts) |
60 | end |
142 | function FarmlandStatisticCounter:onReadStream(streamId, connection) |
143 | self.numSoilSamples = streamReadUIntN(streamId, 16) |
144 | self.soilSampleCosts = streamReadFloat32(streamId) |
145 | |
146 | self.usedLime = streamReadFloat32(streamId) |
147 | self.usedLimeRegular = streamReadFloat32(streamId) |
148 | |
149 | self.usedMineralFertilizer = streamReadFloat32(streamId) |
150 | self.usedMineralFertilizerRegular = streamReadFloat32(streamId) |
151 | |
152 | self.usedLiquidFertilizer = streamReadFloat32(streamId) |
153 | self.usedLiquidFertilizerRegular = streamReadFloat32(streamId) |
154 | |
155 | self.usedManure = streamReadFloat32(streamId) |
156 | self.usedManureRegular = streamReadFloat32(streamId) |
157 | |
158 | self.usedLiquidManure = streamReadFloat32(streamId) |
159 | self.usedLiquidManureRegular = streamReadFloat32(streamId) |
160 | |
161 | self.usedSeeds = streamReadFloat32(streamId) |
162 | self.usedSeedsRegular = streamReadFloat32(streamId) |
163 | |
164 | self.usedHerbicide = streamReadFloat32(streamId) |
165 | self.usedHerbicideRegular = streamReadFloat32(streamId) |
166 | |
167 | self.yield = streamReadFloat32(streamId) |
168 | self.yieldRegular = streamReadFloat32(streamId) |
169 | self.yieldWeight = streamReadFloat32(streamId) |
170 | self.yieldBestPrice = streamReadFloat32(streamId) |
171 | |
172 | self.usedFuel = streamReadFloat32(streamId) |
173 | self.vehicleCosts = streamReadFloat32(streamId) |
174 | |
175 | self.helperCosts = streamReadFloat32(streamId) |
176 | end |
182 | function FarmlandStatisticCounter:onWriteStream(streamId, connection) |
183 | streamWriteUIntN(streamId, self.numSoilSamples, 16) |
184 | streamWriteFloat32(streamId, self.soilSampleCosts) |
185 | |
186 | streamWriteFloat32(streamId, self.usedLime) |
187 | streamWriteFloat32(streamId, self.usedLimeRegular) |
188 | |
189 | streamWriteFloat32(streamId, self.usedMineralFertilizer) |
190 | streamWriteFloat32(streamId, self.usedMineralFertilizerRegular) |
191 | |
192 | streamWriteFloat32(streamId, self.usedLiquidFertilizer) |
193 | streamWriteFloat32(streamId, self.usedLiquidFertilizerRegular) |
194 | |
195 | streamWriteFloat32(streamId, self.usedManure) |
196 | streamWriteFloat32(streamId, self.usedManureRegular) |
197 | |
198 | streamWriteFloat32(streamId, self.usedLiquidManure) |
199 | streamWriteFloat32(streamId, self.usedLiquidManureRegular) |
200 | |
201 | streamWriteFloat32(streamId, self.usedSeeds) |
202 | streamWriteFloat32(streamId, self.usedSeedsRegular) |
203 | |
204 | streamWriteFloat32(streamId, self.usedHerbicide) |
205 | streamWriteFloat32(streamId, self.usedHerbicideRegular) |
206 | |
207 | streamWriteFloat32(streamId, self.yield) |
208 | streamWriteFloat32(streamId, self.yieldRegular) |
209 | streamWriteFloat32(streamId, self.yieldWeight) |
210 | streamWriteFloat32(streamId, self.yieldBestPrice) |
211 | |
212 | streamWriteFloat32(streamId, self.usedFuel) |
213 | streamWriteFloat32(streamId, self.vehicleCosts) |
214 | |
215 | streamWriteFloat32(streamId, self.helperCosts) |
216 | end |
102 | function FarmlandStatisticCounter:reset() |
103 | self.numSoilSamples = 0 |
104 | self.soilSampleCosts = 0 |
105 | |
106 | self.usedLime = 0 |
107 | self.usedLimeRegular = 0 |
108 | |
109 | self.usedMineralFertilizer = 0 |
110 | self.usedMineralFertilizerRegular = 0 |
111 | |
112 | self.usedLiquidFertilizer = 0 |
113 | self.usedLiquidFertilizerRegular = 0 |
114 | |
115 | self.usedManure = 0 |
116 | self.usedManureRegular = 0 |
117 | |
118 | self.usedLiquidManure = 0 |
119 | self.usedLiquidManureRegular = 0 |
120 | |
121 | self.usedSeeds = 0 |
122 | self.usedSeedsRegular = 0 |
123 | |
124 | self.usedHerbicide = 0 |
125 | self.usedHerbicideRegular = 0 |
126 | |
127 | self.yield = 0 |
128 | self.yieldRegular = 0 |
129 | self.yieldWeight = 0 |
130 | self.yieldBestPrice = 0 |
131 | |
132 | self.usedFuel = 0 |
133 | self.vehicleCosts = 0 |
134 | |
135 | self.helperCosts = 0 |
136 | end |
64 | function FarmlandStatisticCounter:saveToXMLFile(xmlFile, key, usedModNames) |
65 | xmlFile:setInt(key .. "#numSoilSamples", self.numSoilSamples) |
66 | xmlFile:setFloat(key .. "#soilSampleCosts", self.soilSampleCosts) |
67 | |
68 | xmlFile:setFloat(key .. "#usedLime", self.usedLime) |
69 | xmlFile:setFloat(key .. "#usedLimeRegular", self.usedLimeRegular) |
70 | |
71 | xmlFile:setFloat(key .. "#usedMineralFertilizer", self.usedMineralFertilizer) |
72 | xmlFile:setFloat(key .. "#usedMineralFertilizerRegular", self.usedMineralFertilizerRegular) |
73 | |
74 | xmlFile:setFloat(key .. "#usedLiquidFertilizer", self.usedLiquidFertilizer) |
75 | xmlFile:setFloat(key .. "#usedLiquidFertilizerRegular", self.usedLiquidFertilizerRegular) |
76 | |
77 | xmlFile:setFloat(key .. "#usedManure", self.usedManure) |
78 | xmlFile:setFloat(key .. "#usedManureRegular", self.usedManureRegular) |
79 | |
80 | xmlFile:setFloat(key .. "#usedLiquidManure", self.usedLiquidManure) |
81 | xmlFile:setFloat(key .. "#usedLiquidManureRegular", self.usedLiquidManureRegular) |
82 | |
83 | xmlFile:setFloat(key .. "#usedSeeds", self.usedSeeds) |
84 | xmlFile:setFloat(key .. "#usedSeedsRegular", self.usedSeedsRegular) |
85 | |
86 | xmlFile:setFloat(key .. "#usedHerbicide", self.usedHerbicide) |
87 | xmlFile:setFloat(key .. "#usedHerbicideRegular", self.usedHerbicideRegular) |
88 | |
89 | xmlFile:setFloat(key .. "#yield", self.yield) |
90 | xmlFile:setFloat(key .. "#yieldRegular", self.yieldRegular) |
91 | xmlFile:setFloat(key .. "#yieldWeight", self.yieldWeight) |
92 | xmlFile:setFloat(key .. "#yieldBestPrice", self.yieldBestPrice) |
93 | |
94 | xmlFile:setFloat(key .. "#usedFuel", self.usedFuel) |
95 | xmlFile:setFloat(key .. "#vehicleCosts", self.vehicleCosts) |
96 | |
97 | xmlFile:setFloat(key .. "#helperCosts", self.helperCosts) |
98 | end |