-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlaceableExtendedProductionPoint.lua
1852 lines (1407 loc) · 85 KB
/
PlaceableExtendedProductionPoint.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--[[
Copyright (C) GtX (Andy), 2022
Author: GtX | Andy
Date: 14.02.2022
Revision: FS22-05
Contact:
https://forum.giants-software.com
https://github.com/GtX-Andy
Important:
Free for use in mods (FS22 Only) - no permission needed.
No modifications may be made to this script, including conversion to other game versions without written permission from GtX | Andy
Copying or removing any part of this code for external use without written permission from GtX | Andy is prohibited.
Frei verwendbar (Nur LS22) - keine erlaubnis nötig
Ohne schriftliche Genehmigung von GtX | Andy dürfen keine Änderungen an diesem Skript vorgenommen werden, einschließlich der Konvertierung in andere Spielversionen
Das Kopieren oder Entfernen irgendeines Teils dieses Codes zur externen Verwendung ohne schriftliche Genehmigung von GtX | Andy ist verboten.
]]
PlaceableExtendedProductionPoint = {}
PlaceableExtendedProductionPoint.MOD_NAME = g_currentModName
PlaceableExtendedProductionPoint.SPEC_NAME = string.format("%s.extendedProductionPoint", g_currentModName)
PlaceableExtendedProductionPoint.SPEC = string.format("spec_%s", PlaceableExtendedProductionPoint.SPEC_NAME)
local specEntryName = PlaceableExtendedProductionPoint.SPEC
local newUpdateInfoFunc = g_gameVersion >= 21 or g_maxModDescVersion >= 79
function PlaceableExtendedProductionPoint.prerequisitesPresent(specializations)
return SpecializationUtil.hasSpecialization(PlaceableInfoTrigger, specializations) and not SpecializationUtil.hasSpecialization(PlaceableProductionPoint, specializations)
end
function PlaceableExtendedProductionPoint.initSpecialization()
local inputFillTypes = g_storeManager:getSpecTypeByName("prodPointInputFillTypes")
if inputFillTypes ~= nil and inputFillTypes.loadFunc ~= nil and not inputFillTypes.extendedProductionAdded then
local oldLoadFunc = inputFillTypes.loadFunc
inputFillTypes.loadFunc = function(xmlFile, customEnvironment, baseDirectory)
local fillTypeNames = oldLoadFunc(xmlFile, customEnvironment, baseDirectory)
if fillTypeNames == nil and xmlFile:hasProperty("placeable.extendedProductionPoint") then
xmlFile:iterate("placeable.extendedProductionPoint.productions.production", function (_, key)
xmlFile:iterate(key .. ".inputs.input", function (_, inputKey)
local fillTypeName = xmlFile:getValue(inputKey .. "#fillType")
fillTypeNames = fillTypeNames or {}
fillTypeNames[fillTypeName] = true
end)
end)
end
return fillTypeNames
end
inputFillTypes.extendedProductionAdded = true
end
local outputFillTypes = g_storeManager:getSpecTypeByName("prodPointOutputFillTypes")
if outputFillTypes ~= nil and outputFillTypes.loadFunc ~= nil and not outputFillTypes.extendedProductionAdded then
local oldLoadFunc = outputFillTypes.loadFunc
outputFillTypes.loadFunc = function(xmlFile, customEnvironment, baseDirectory)
local fillTypeNames = oldLoadFunc(xmlFile, customEnvironment, baseDirectory)
if fillTypeNames == nil and xmlFile:hasProperty("placeable.extendedProductionPoint") then
xmlFile:iterate("placeable.extendedProductionPoint.productions.production", function (_, key)
xmlFile:iterate(key .. ".outputs.output", function (_, outputKey)
local fillTypeName = xmlFile:getValue(outputKey .. "#fillType")
fillTypeNames = fillTypeNames or {}
fillTypeNames[fillTypeName] = true
end)
end)
end
return fillTypeNames
end
outputFillTypes.extendedProductionAdded = true
end
end
function PlaceableExtendedProductionPoint.registerEvents(placeableType)
SpecializationUtil.registerEvent(placeableType, "onOutputFillTypesChanged")
SpecializationUtil.registerEvent(placeableType, "onProductionStatusChanged")
end
function PlaceableExtendedProductionPoint.registerFunctions(placeableType)
SpecializationUtil.registerFunction(placeableType, "outputsChanged", PlaceableExtendedProductionPoint.outputsChanged)
SpecializationUtil.registerFunction(placeableType, "productionStatusChanged", PlaceableExtendedProductionPoint.productionStatusChanged)
end
function PlaceableExtendedProductionPoint.registerOverwrittenFunctions(placeableType)
SpecializationUtil.registerOverwrittenFunction(placeableType, "setOwnerFarmId", PlaceableExtendedProductionPoint.setOwnerFarmId)
SpecializationUtil.registerOverwrittenFunction(placeableType, "collectPickObjects", PlaceableExtendedProductionPoint.collectPickObjects)
SpecializationUtil.registerOverwrittenFunction(placeableType, "canBuy", PlaceableExtendedProductionPoint.canBuy)
SpecializationUtil.registerOverwrittenFunction(placeableType, "updateInfo", PlaceableExtendedProductionPoint.updateInfo)
SpecializationUtil.registerOverwrittenFunction(placeableType, "getNeedMinuteChanged", PlaceableExtendedProductionPoint.getNeedMinuteChanged)
end
function PlaceableExtendedProductionPoint.registerEventListeners(placeableType)
SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableExtendedProductionPoint)
SpecializationUtil.registerEventListener(placeableType, "onDelete", PlaceableExtendedProductionPoint)
SpecializationUtil.registerEventListener(placeableType, "onFinalizePlacement", PlaceableExtendedProductionPoint)
SpecializationUtil.registerEventListener(placeableType, "onWriteStream", PlaceableExtendedProductionPoint)
SpecializationUtil.registerEventListener(placeableType, "onReadStream", PlaceableExtendedProductionPoint)
SpecializationUtil.registerEventListener(placeableType, "onMinuteChanged", PlaceableExtendedProductionPoint)
end
function PlaceableExtendedProductionPoint.registerXMLPaths(schema, basePath)
schema:setXMLSpecializationType("ExtendedProductionPoint")
ExtendedProductionPoint.registerXMLPaths(schema, basePath .. ".extendedProductionPoint")
schema:setXMLSpecializationType()
end
function PlaceableExtendedProductionPoint.registerSavegameXMLPaths(schema, basePath)
schema:setXMLSpecializationType("ExtendedProductionPoint")
ExtendedProductionPoint.registerSavegameXMLPaths(schema, basePath)
schema:setXMLSpecializationType()
end
function PlaceableExtendedProductionPoint:onLoad(savegame)
local spec = self[specEntryName]
if spec == nil then
Logging.error("[%s] Specialisation with name 'extendedProductionPoint' was not found in modDesc!", PlaceableExtendedProductionPoint.MOD_NAME)
self:setLoadingState(Placeable.LOADING_STATE_ERROR)
end
local productionPoint = ExtendedProductionPoint.new(self.isServer, self.isClient, self.baseDirectory)
productionPoint.owningPlaceable = self
productionPoint.customEnvironment = self.customEnvironment
if productionPoint:load(self.components, self.xmlFile, "placeable.extendedProductionPoint", self.customEnvironment, self.i3dMappings) then
spec.productionPoint = productionPoint
if not self.isServer or not productionPoint.collectRainWater then
SpecializationUtil.removeEventListener(self, "onMinuteChanged", PlaceableExtendedProductionPoint)
end
else
productionPoint:delete()
self:setLoadingState(Placeable.LOADING_STATE_ERROR)
end
self.spec_extendedProductionPoint = spec
end
function PlaceableExtendedProductionPoint:onDelete()
local spec = self[specEntryName]
if spec.productionPoint ~= nil then
spec.productionPoint:delete()
spec.productionPoint = nil
end
end
function PlaceableExtendedProductionPoint:onFinalizePlacement()
local spec = self[specEntryName]
if spec.productionPoint ~= nil then
spec.productionPoint:register(true)
spec.productionPoint:setOwnerFarmId(self:getOwnerFarmId())
spec.productionPoint:findStorageExtensions()
spec.productionPoint:updateFxState()
end
end
function PlaceableExtendedProductionPoint:updateInfo(superFunc, infoTable)
local spec = self[specEntryName]
-- Fix for changes made in game update 1.13.1 where placeable superFunc is no longer passed to the 'ProductionPoint' class.
-- This allows placeables to still work on older game versions if the user has not updated.
if spec.productionPoint ~= nil then
if newUpdateInfoFunc then
superFunc(self, infoTable)
spec.productionPoint:updateInfo(infoTable)
else
spec.productionPoint:updateInfo(superFunc, infoTable)
end
else
superFunc(self, infoTable)
end
end
function PlaceableExtendedProductionPoint:outputsChanged(outputs, state)
SpecializationUtil.raiseEvent(self, "onOutputFillTypesChanged", outputs, state)
end
function PlaceableExtendedProductionPoint:productionStatusChanged(production, status)
SpecializationUtil.raiseEvent(self, "onProductionStatusChanged", production, status)
end
function PlaceableExtendedProductionPoint:onReadStream(streamId, connection)
local spec = self[specEntryName]
if spec.productionPoint ~= nil then
local productionPointId = NetworkUtil.readNodeObjectId(streamId)
spec.productionPoint:readStream(streamId, connection)
g_client:finishRegisterObject(spec.productionPoint, productionPointId)
end
end
function PlaceableExtendedProductionPoint:onWriteStream(streamId, connection)
local spec = self[specEntryName]
if spec.productionPoint ~= nil then
NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(spec.productionPoint))
spec.productionPoint:writeStream(streamId, connection)
g_server:registerObjectInStream(connection, spec.productionPoint)
end
end
function PlaceableExtendedProductionPoint:onMinuteChanged(minute)
if self.isServer then
local spec = self[specEntryName]
if spec.productionPoint ~= nil and spec.productionPoint.isOwned and spec.productionPoint.collectRainWater then
local lastRainScale = g_currentMission.environment.weather:getRainFallScale(spec.productionPoint.collectSnow)
if lastRainScale > 0.05 then
spec.productionPoint:updateRainWaterCollector(lastRainScale)
end
end
end
end
function PlaceableExtendedProductionPoint:loadFromXMLFile(xmlFile, key)
local spec = self[specEntryName]
if spec.productionPoint ~= nil then
spec.productionPoint:loadFromXMLFile(xmlFile, key)
end
end
function PlaceableExtendedProductionPoint:saveToXMLFile(xmlFile, key, usedModNames)
local spec = self[specEntryName]
if spec.productionPoint ~= nil then
spec.productionPoint:saveToXMLFile(xmlFile, key, usedModNames)
end
end
function PlaceableExtendedProductionPoint:setOwnerFarmId(superFunc, farmId, noEventSend)
superFunc(self, farmId, noEventSend)
local spec = self[specEntryName]
if spec.productionPoint ~= nil then
spec.productionPoint:setOwnerFarmId(farmId)
end
end
function PlaceableExtendedProductionPoint:collectPickObjects(superFunc, node)
local spec = self[specEntryName]
if spec.productionPoint.loadingStation ~= nil then
for i = 1, #spec.productionPoint.loadingStation.loadTriggers do
local loadTrigger = spec.productionPoint.loadingStation.loadTriggers[i]
if node == loadTrigger.triggerNode then
return
end
end
end
for i = 1, #spec.productionPoint.unloadingStation.unloadTriggers do
local unloadTrigger = spec.productionPoint.unloadingStation.unloadTriggers[i]
if node == unloadTrigger.exactFillRootNode then
return
end
end
superFunc(self, node)
end
function PlaceableExtendedProductionPoint:canBuy(superFunc)
if not g_currentMission.productionChainManager:getHasFreeSlots() then
return false, g_i18n:getText("warning_maxNumOfProdPointsReached")
end
return superFunc(self)
end
function PlaceableExtendedProductionPoint:getNeedMinuteChanged(superFunc)
local spec = self[specEntryName]
if self.isServer and spec.productionPoint ~= nil and spec.productionPoint.collectRainWater then
return true
end
return superFunc(self)
end
------------------------------------------------------------------------------------------------------------------------------------
-- ExtendedProductionPoint (Creating a new class to keep this separate from Base Game factories that make no use of the features) --
------------------------------------------------------------------------------------------------------------------------------------
ExtendedProductionPoint = {}
ExtendedProductionPoint.DISTRIBUTION_NAMES = {
"keep",
"directSell",
"autoDeliver"
}
ExtendedProductionPoint.AUTO_OFF_PROD_STATUS = {
[ProductionPoint.PROD_STATUS.MISSING_INPUTS] = true,
[ProductionPoint.PROD_STATUS.NO_OUTPUT_SPACE] = true
}
local ExtendedProductionPoint_mt = Class(ExtendedProductionPoint, ProductionPoint)
InitObjectClass(ExtendedProductionPoint, "ExtendedProductionPoint")
function ExtendedProductionPoint.registerXMLPaths(schema, basePath)
ProductionPoint.registerXMLPaths(schema, basePath)
schema:register(XMLValueType.BOOL, basePath .. "#hiddenOnUI", "Future Use", false)
schema:register(XMLValueType.BOOL, basePath .. "#alwaysActive", "Maintains the active state for all productions useful for fruit trees etc where turning on/off is strange.", false)
-- Only when included with the mod
if ExtendedLoadingStation ~= nil and ExtendedLoadingStation.registerXMLPaths ~= nil then
ExtendedLoadingStation.registerXMLPaths(schema, basePath .. ".extendedLoadingStation")
end
schema:register(XMLValueType.BOOL, basePath .. ".productions.production(?)#autoOff", "(Disabled when 'alwaysActive=true') Automatically stops production when materials are missing or no output space, starting will also not be possible", false)
schema:register(XMLValueType.BOOL, basePath .. ".productions.production(?)#showAutoOffLitres", "When 'true' the ingredient name and minimum fill level or space required will also be displayed when trying to start production", true)
schema:register(XMLValueType.FLOAT, basePath .. ".rainWaterCollector#rainWaterPerMinute", "The value per minute add to the 'WATER' storage. This value is adjusted when only raining lightly", 0)
schema:register(XMLValueType.BOOL, basePath .. ".rainWaterCollector#collectSnow", "Add snow and rain to the 'WATER' storage", false)
ExtendedProductionPoint.registerDisplayXMLPaths(schema, basePath .. ".factoryNameDisplays", false)
ExtendedProductionPoint.registerDisplayXMLPaths(schema, basePath .. ".productions.production(?).nameDisplays", false)
schema:register(XMLValueType.NODE_INDEX, basePath .. ".productions.production(?).playerTrigger#node", "Player trigger to toggle the operation state of the production")
schema:register(XMLValueType.STRING, basePath .. ".productions.production(?).playerTrigger#menuAction", "Optional inputAction name used to open Factory UI")
ObjectChangeUtil.registerObjectChangeXMLPaths(schema, basePath .. ".productions.production(?).operatingObjectChanges")
SoundManager.registerSampleXMLPaths(schema, basePath .. ".productions.production(?).operatingSounds", "start(?)")
SoundManager.registerSampleXMLPaths(schema, basePath .. ".productions.production(?).operatingSounds", "stop(?)")
SoundManager.registerSampleXMLPaths(schema, basePath .. ".productions.production(?).operatingSounds", "work(?)")
ExtendedProductionPoint.registerProductionXMLPaths(schema, basePath .. ".productions.production(?).inputs.input(?)")
-- Input only as it is mainly for animals and these are not supported on OUTPUT as it is not a husbandry ;-)
schema:register(XMLValueType.NODE_INDEX, basePath .. ".productions.production(?).inputs.input(?).animatedVisibilityNodes.visibilityNode(?)#linkNode", "Link node")
schema:register(XMLValueType.STRING, basePath .. ".productions.production(?).inputs.input(?).animatedVisibilityNodes.visibilityNode(?)#clipNames", "Animation clip names. If more than one name is given then it will be random each time visibility changes")
schema:register(XMLValueType.STRING, basePath .. ".productions.production(?).inputs.input(?).animatedVisibilityNodes.visibilityNode(?)#characterFilename", "External mesh or combined file")
schema:register(XMLValueType.NODE_INDEX, basePath .. ".productions.production(?).inputs.input(?).animatedVisibilityNodes.visibilityNode(?)#skeletonNode", "Skeleton node index to attach animation to. Uses 'characterFilename' i3d if 'animationFilename' i3d is not provided.", "0")
schema:register(XMLValueType.STRING, basePath .. ".productions.production(?).inputs.input(?).animatedVisibilityNodes.visibilityNode(?)#animationFilename", "External animation file to link with mesh loaded from 'characterFilename'")
schema:register(XMLValueType.INT, basePath .. ".productions.production(?).inputs.input(?).animatedVisibilityNodes.visibilityNode(?)#clipTrack", "Track index", 0)
schema:register(XMLValueType.BOOL, basePath .. ".productions.production(?).inputs.input(?).animatedVisibilityNodes.visibilityNode(?)#randomStart", "Use a random starting point", true)
schema:register(XMLValueType.NODE_INDEX, basePath .. ".productions.production(?).inputs.input(?).animatedVisibilityNodes.visibilityNode(?)#meshNode", "Mesh node parent, all shape nodes will have shader adjusted recursively (tileAndMirrorShader)")
schema:register(XMLValueType.INT, basePath .. ".productions.production(?).inputs.input(?).animatedVisibilityNodes.visibilityNode(?)#tileU", "Shader tileU (atlasInvSizeAndOffsetUV)")
schema:register(XMLValueType.INT, basePath .. ".productions.production(?).inputs.input(?).animatedVisibilityNodes.visibilityNode(?)#tileV", "Shader tileV (atlasInvSizeAndOffsetUV)")
schema:register(XMLValueType.INT, basePath .. ".productions.production(?).inputs.input(?).animatedVisibilityNodes.visibilityNode(?)#numTilesU", "Shader numTilesU (atlasInvSizeAndOffsetUV)", 2)
schema:register(XMLValueType.INT, basePath .. ".productions.production(?).inputs.input(?).animatedVisibilityNodes.visibilityNode(?)#numTilesV", "Shader numTilesV (atlasInvSizeAndOffsetUV)", 2)
schema:register(XMLValueType.FLOAT, basePath .. ".productions.production(?).inputs.input(?).animatedVisibilityNodes.visibilityNode(?)#dirtFactor", "Shader dirt factor (RDT)", 0)
ExtendedProductionPoint.registerProductionXMLPaths(schema, basePath .. ".productions.production(?).outputs.output(?)")
ObjectChangeUtil.registerObjectChangeXMLPaths(schema, basePath .. ".productions.production(?).outputs.output(?).distributionObjectChanges.keep")
ObjectChangeUtil.registerObjectChangeXMLPaths(schema, basePath .. ".productions.production(?).outputs.output(?).distributionObjectChanges.directSell")
ObjectChangeUtil.registerObjectChangeXMLPaths(schema, basePath .. ".productions.production(?).outputs.output(?).distributionObjectChanges.autoDeliver")
schema:register(XMLValueType.NODE_INDEX, basePath .. ".animalInput#triggerNode", "Animal unloading trigger")
schema:register(XMLValueType.STRING, basePath .. ".animalInput#unloadSuccessText", "Optional success text shown after moving animals to factory", "Recommended English: Animals were successfully moved to %s!")
schema:register(XMLValueType.STRING, basePath .. ".animalInput#unloadConfirmationText", "Optional confirmation text used to confirm animal move", "Recommended English: Do you want to move %d animals (%s) to the %s?")
schema:register(XMLValueType.STRING, basePath .. ".animalInput#moveButtonText", "Optional text displayed on dialogue button", "Recommended English: Move to %s")
schema:register(XMLValueType.STRING, basePath .. ".animalInput.animal(?)#type", "Animal type name, for example: COW | PIG | SHEEP| CHICKEN")
schema:register(XMLValueType.STRING, basePath .. ".animalInput.animal(?)#fillType", "Fill type that each animal will be converted to 1 > 1")
end
function ExtendedProductionPoint.registerSavegameXMLPaths(schema, basePath)
ProductionPoint.registerSavegameXMLPaths(schema, basePath)
end
function ExtendedProductionPoint.registerProductionXMLPaths(schema, basePath)
ExtendedProductionPoint.registerDisplayXMLPaths(schema, basePath .. ".displays", true)
schema:register(XMLValueType.FLOAT, basePath .. ".fillMovers.fillMover(?)#minScaleY", "Fill plane min scale y")
schema:register(XMLValueType.FLOAT, basePath .. ".fillMovers.fillMover(?)#maxScaleY", "Fill plane max scale y")
FillPlane.registerXMLPaths(schema, basePath .. ".fillMovers.fillMover(?)")
FillPlaneUtil.registerFillPlaneXMLPaths(schema, basePath .. ".dynamicFillPlanes.dynamicFillPlane(?)")
schema:register(XMLValueType.NODE_INDEX, basePath .. ".visibilityNodeGroups.visibilityNodeGroup(?)#node", "Visibility nodes root node")
end
function ExtendedProductionPoint.registerDisplayXMLPaths(schema, basePath, production)
schema:register(XMLValueType.NODE_INDEX, basePath .. ".display(?)#node", "Display start node")
schema:register(XMLValueType.STRING, basePath .. ".display(?)#font", "Display font name")
schema:register(XMLValueType.BOOL, basePath .. ".display(?)#upperCase", "Display text upper case only", false)
schema:register(XMLValueType.STRING, basePath .. ".display(?)#alignment", "Display text alignment")
schema:register(XMLValueType.FLOAT, basePath .. ".display(?)#size", "Display text size", 0.03)
schema:register(XMLValueType.FLOAT, basePath .. ".display(?)#scaleX", "Display text x scale", 1)
schema:register(XMLValueType.FLOAT, basePath .. ".display(?)#scaleY", "Display text y scale", 1)
schema:register(XMLValueType.STRING, basePath .. ".display(?)#mask", "Display text mask. If display type 'TITLE' then optionally 'AUTO_MASK' can be used and the mask will be adjusted to the text length", "0000000")
schema:register(XMLValueType.FLOAT, basePath .. ".display(?)#emissiveScale", "Display emissive scale", 0.2)
schema:register(XMLValueType.COLOR, basePath .. ".display(?)#color", "Display text colour", "0.9 0.9 0.9 1")
schema:register(XMLValueType.COLOR, basePath .. ".display(?)#hiddenColor", "Display text hidden colour")
if production then
schema:register(XMLValueType.STRING, basePath .. ".display(?)#fillLevelColorType", "Percent & FillLevel options. NONE: No colour change | STANDARD: Text colour will change from 'green > red' | INVERTED: Text colour will change from 'red > green'", "NONE")
schema:register(XMLValueType.STRING, basePath .. ".display(?)#type", "Display type. Options: fillLevel | percent | capacity | title")
end
end
function ExtendedProductionPoint.new(isServer, isClient, baseDirectory, customMt)
local self = ProductionPoint.new(isServer, isClient, baseDirectory, customMt or ExtendedProductionPoint_mt)
self.extendedFeaturesByFillType = {}
self.distributionObjectChanges = {}
self.extendedFeaturesInteractionTriggers = {}
self.extendedFeaturesMenuAction = {}
self.xmlFilename = ""
self.collectSnow = true
self.collectRainWater = false
self.rainWaterCollected = 0
self.rainWaterPerMinute = 0
self.rainWaterThreshold = 5
self.hiddenOnUI = false
self.extendedFeaturesAlwaysActive = false
return self
end
function ExtendedProductionPoint:load(components, xmlFile, key, customEnvironment, i3dMappings)
self.xmlFilename = xmlFile:getFilename() -- Error protection for things like EffectManager, missing in base code
self.customEnvironment = customEnvironment -- Required by many things such as AnimationManager, and EffectManager, UnloadingStation and PalletSpawner
self.i3dMappings = i3dMappings -- Object change requires this to use mappings
local extendedLoadingStationKey = key .. ".extendedLoadingStation"
if xmlFile:hasProperty(extendedLoadingStationKey) then
if not xmlFile:hasProperty(key .. ".loadingStation") then
if ExtendedLoadingStation ~= nil then
self.loadingStation = ExtendedLoadingStation.new(self.isServer, self.isClient)
if self.loadingStation:load(components, xmlFile, extendedLoadingStationKey, customEnvironment, i3dMappings, components[1].node) then
self.loadingStation.owningPlaceable = self.owningPlaceable
self.loadingStation.useOwnerForAccess = true
self.loadingStation:register(true)
else
Logging.xmlError(xmlFile, "Unable to load loading station '%s'", extendedLoadingStationKey)
return false
end
else
Logging.xmlError(xmlFile, "Unable to load loading station '%s' ExtendedLoadingStation.lua was not loaded with mod '%s', visit 'www.github.com/GtX-Andy' for latest release.", extendedLoadingStationKey, customEnvironment)
return false
end
else
Logging.xmlError(xmlFile, "Unable to load extended loading station '%s' when '%s.loadingStation' is used!", extendedLoadingStationKey, key)
end
end
if not ExtendedProductionPoint:superClass().load(self, components, xmlFile, key, customEnvironment, i3dMappings) then
return false
end
local hasExtendedFeatures = false
local baseDirectory = self.baseDirectory
local function addExtendedFeatures(fillType, name, extendedFeatures)
if extendedFeatures ~= nil then
if self.extendedFeaturesByFillType[fillType] == nil then
self.extendedFeaturesByFillType[fillType] = {}
end
if self.extendedFeaturesByFillType[fillType][name] == nil then
self.extendedFeaturesByFillType[fillType][name] = extendedFeatures
else
for _, extendedFeature in pairs (extendedFeatures) do
table.insert(self.extendedFeaturesByFillType[fillType][name], extendedFeature)
end
end
hasExtendedFeatures = true
end
end
self:findStorageExtensions()
self.hiddenOnUI = xmlFile:getValue(key .. "#hiddenOnUI", false)
self.extendedFeaturesAlwaysActive = xmlFile:getValue(key .. "#alwaysActive", false)
-- This is only for name defined in the XML not for renaming
if self.isClient and self.name ~= nil then
self.extendedFeaturesFactoryNameDisplays = self:loadDisplays(xmlFile, key .. ".factoryNameDisplays", components, i3dMappings, self.name, "FACTORY_NAME")
end
xmlFile:iterate(key .. ".productions.production", function (productionIndex, productionKey)
local production = self.productions[productionIndex]
if production ~= nil then
production.extendedFeaturesAutoOff = false
if not self.extendedFeaturesAlwaysActive then
production.extendedFeaturesAutoOff = xmlFile:getValue(productionKey .. "#autoOff", false)
production.extendedFeaturesShowAutoOffLitres = xmlFile:getValue(productionKey .. "#showAutoOffLitres", true)
end
local triggerId = xmlFile:getValue(productionKey .. ".playerTrigger#node", nil, components, i3dMappings)
if triggerId ~= nil and self.extendedFeaturesInteractionTriggers[triggerId] == nil then
if self.extendedActivatable == nil then
self.extendedActivatable = ExtendedProductionPointActivatable.new(self)
end
if not self.hiddenOnUI then
local menuAction = xmlFile:getValue(productionKey .. ".playerTrigger#menuAction")
if menuAction ~= nil then
if InputAction[menuAction] then
self.extendedFeaturesMenuAction[triggerId] = menuAction
else
Logging.xmlWarning("Player trigger menu action '%s' not defined!", menuAction)
end
end
end
self.extendedFeaturesInteractionTriggers[triggerId] = production
addTrigger(triggerId, "productionInteractionTriggerCallback", self)
end
if self.isClient then
production.extendedFeaturesNameDisplays = self:loadDisplays(xmlFile, productionKey .. ".nameDisplays", components, i3dMappings, production.name, "PRODUCTION_NAME")
xmlFile:iterate(productionKey .. ".inputs.input", function (inputIndex, inputKey)
local input = production.inputs[inputIndex]
if input ~= nil then
local inputType = input.type
local displays, titleDisplays = self:loadDisplays(xmlFile, inputKey .. ".displays", components, i3dMappings, inputType, "INPUT_OUTPUT")
addExtendedFeatures(inputType, "displays", displays)
addExtendedFeatures(inputType, "titleDisplays", titleDisplays)
addExtendedFeatures(inputType, "fillMovers", self:loadFillMovers(xmlFile, inputKey, components, i3dMappings))
addExtendedFeatures(inputType, "dynamicFillPlanes", self:loadDynamicFillPlanes(xmlFile, inputKey, components, i3dMappings, inputType))
addExtendedFeatures(inputType, "visibilityNodeGroups", self:loadVisibilityNodeGroups(xmlFile, inputKey, components, i3dMappings))
addExtendedFeatures(inputType, "animatedVisibilityNodes", self:loadAnimatedVisibilityNodes(xmlFile, inputKey, components, i3dMappings))
end
end)
xmlFile:iterate(productionKey .. ".outputs.output", function (outputIndex, outputKey)
local output = production.outputs[outputIndex]
if output ~= nil and not output.sellDirectly then
local outputType = output.type
local displays, titleDisplays = self:loadDisplays(xmlFile, outputKey .. ".displays", components, i3dMappings, outputType, "INPUT_OUTPUT")
addExtendedFeatures(outputType, "displays", displays)
addExtendedFeatures(outputType, "titleDisplays", titleDisplays)
addExtendedFeatures(outputType, "fillMovers", self:loadFillMovers(xmlFile, outputKey, components, i3dMappings))
addExtendedFeatures(outputType, "dynamicFillPlanes", self:loadDynamicFillPlanes(xmlFile, outputKey, components, i3dMappings, outputType))
addExtendedFeatures(outputType, "visibilityNodeGroups", self:loadVisibilityNodeGroups(xmlFile, outputKey, components, i3dMappings))
local distributionKey = outputKey .. ".distributionObjectChanges"
if xmlFile:hasProperty(distributionKey) then
self.distributionObjectChanges[outputType] = {}
for i, distributionName in ipairs (ExtendedProductionPoint.DISTRIBUTION_NAMES) do
local objectChanges = {}
ObjectChangeUtil.loadObjectChangeFromXML(xmlFile, distributionKey .. "." .. distributionName, objectChanges, components, self)
if distributionName == "keep" then
ObjectChangeUtil.setObjectChanges(objectChanges, true)
end
self.distributionObjectChanges[outputType][i] = objectChanges
end
end
end
end)
if xmlFile:hasProperty(productionKey .. ".operatingObjectChanges") then
production.extendedFeaturesObjectChanges = {}
ObjectChangeUtil.loadObjectChangeFromXML(xmlFile, productionKey .. ".operatingObjectChanges", production.extendedFeaturesObjectChanges, components, self)
ObjectChangeUtil.setObjectChanges(production.extendedFeaturesObjectChanges, false)
end
production.extendedFeaturesSamples = {
start = g_soundManager:loadSampleFromXML(xmlFile, productionKey .. ".operatingSounds", "start", self.baseDirectory, components, 1, AudioGroup.ENVIRONMENT, i3dMappings, nil),
stop = g_soundManager:loadSampleFromXML(xmlFile, productionKey .. ".operatingSounds", "stop", self.baseDirectory, components, 1, AudioGroup.ENVIRONMENT, i3dMappings, nil),
work = g_soundManager:loadSampleFromXML(xmlFile, productionKey .. ".operatingSounds", "work", self.baseDirectory, components, 0, AudioGroup.ENVIRONMENT, i3dMappings, nil)
}
end
end
end)
local rainWaterPerMinute = xmlFile:getValue(key .. ".rainWaterCollector#rainWaterPerMinute", 0)
if rainWaterPerMinute > 0 then
if self.storage:getIsFillTypeSupported(FillType.WATER) then
self.collectSnow = xmlFile:getValue(key .. ".rainWaterCollector#collectSnow", self.collectSnow)
self.rainWaterPerMinute = rainWaterPerMinute
self.collectRainWater = true
else
Logging.info("Invalid use of 'rainWaterCollector', Fill type 'WATER' is missing from the storage!")
end
end
local animalLoadingTriggerNode = xmlFile:getValue(key .. ".animalInput#triggerNode", nil, components, i3dMappings)
if animalLoadingTriggerNode ~= nil then
local triggerValid = false
local animalSystem = g_currentMission.animalSystem
xmlFile:iterate(key .. ".animalInput.animal", function (_, animalTypeKey)
local animalTypeName = xmlFile:getString(animalTypeKey .. "#type")
local animalType = animalSystem:getTypeByName(animalTypeName)
if animalType ~= nil then
local fillTypeName = xmlFile:getString(animalTypeKey .. "#fillType")
local fillType = g_fillTypeManager:getFillTypeIndexByName(fillTypeName)
if fillType ~= nil and self.unloadingStation:getIsFillTypeSupported(fillType) then
if self.animalSubTypeToFillType == nil then
self.animalSubTypeToFillType = {}
self.fillTypeToAnimalSubType = {}
end
for _, subTypeIndex in ipairs (animalType.subTypes) do
self.animalSubTypeToFillType[subTypeIndex] = fillType
self.fillTypeToAnimalSubType[fillType] = subTypeIndex
end
if self.animalTypeToFillType == nil then
self.animalTypeToFillType = {}
self.fillTypeToAnimalType = {}
end
self.maxNumAnimals = (self.maxNumAnimals or 0) + self:getCapacity(fillType)
self.animalTypeToFillType[animalType.typeIndex] = fillType
self.fillTypeToAnimalType[fillType] = animalType.typeIndex
triggerValid = true
else
Logging.xmlError(xmlFile, "Production point unloadingStation does not support fillType with name '%s' or fillType is invalid for 'animalInput' type '%s'.", fillTypeName, animalTypeName)
end
else
Logging.xmlError(xmlFile, "Animal type '%s' invalid!", animalTypeName)
end
end)
if triggerValid then
local animalLoadingTrigger = AnimalLoadingTrigger.new(self.isServer, self.isClient)
animalLoadingTrigger.husbandry = self
animalLoadingTrigger.title = self.title
animalLoadingTrigger.isDealer = false
animalLoadingTrigger.isEnabled = true
animalLoadingTrigger.triggerNode = animalLoadingTriggerNode
addTrigger(animalLoadingTrigger.triggerNode, "triggerCallback", animalLoadingTrigger)
-- EXAMPLE L10N: "Animals were successfully moved to %s!"
local unloadSuccessText = xmlFile:getString(key .. ".animalInput#unloadSuccessText")
if unloadSuccessText ~= nil then
animalLoadingTrigger.unloadSuccessText = string.format(g_i18n:getText(unloadSuccessText, customEnvironment), self:getName())
end
-- EXAMPLE L10N: "Do you want to move %d animals (%s) to the %s?"
local unloadConfirmationText = xmlFile:getString(key .. ".animalInput#unloadConfirmationText")
if unloadConfirmationText ~= nil then
animalLoadingTrigger.unloadConfirmationText = g_i18n:getText(unloadConfirmationText, customEnvironment)
end
-- EXAMPLE L10N: "Move to %s"
local moveButtonText = xmlFile:getString(key .. ".animalInput#moveButtonText")
if moveButtonText ~= nil then
animalLoadingTrigger.moveButtonText = string.format(g_i18n:getText(moveButtonText, customEnvironment), self:getName())
else
animalLoadingTrigger.moveButtonText = g_i18n:getText("action_tip")
end
animalLoadingTrigger.showAnimalScreen = function (loadingTrigger, husbandry)
if loadingTrigger.loadingVehicle == nil then
return
end
local animalScreenController = AnimalScreenTrailerFarm.new(husbandry, loadingTrigger.loadingVehicle)
if animalScreenController ~= nil then
animalScreenController.getTargetName = function(controller)
local clusters = controller.trailer:getClusters()
if #clusters > 0 then
local subTypeIndex = clusters[1]:getSubTypeIndex()
local fillTypeIndex = controller.husbandry.animalSubTypeToFillType[subTypeIndex]
if fillTypeIndex ~= nil then
local fillType = g_fillTypeManager:getFillTypeByIndex(fillTypeIndex)
local fillLevel = controller.husbandry:getFillLevel(fillTypeIndex) or 0
local capacity = controller.husbandry:getCapacity(fillTypeIndex) or 0
return string.format("%s (%d / %d)", fillType.title, fillLevel, capacity)
end
end
return ""
end
animalScreenController.getSourceActionText = function(controller)
return loadingTrigger.moveButtonText
end
animalScreenController.getSourceMaxNumAnimals = function(controller, itemIndex)
local item = controller.sourceItems[itemIndex]
local husbandryFreeSlots = controller.husbandry:getNumOfFreeAnimalSlots(item:getSubTypeIndex())
return math.min(controller:getMaxNumAnimals(), item:getNumAnimals(), husbandryFreeSlots)
end
if loadingTrigger.unloadConfirmationText ~= nil then
animalScreenController.getApplySourceConfirmationText = function(controller, itemIndex, numItems)
local item = controller.sourceItems[itemIndex]
return string.format(loadingTrigger.unloadConfirmationText, numItems, item:getName(), controller.husbandry:getName())
end
end
if loadingTrigger.unloadSuccessText ~= nil then
animalScreenController.onAnimalMovedToFarm = function(controller, errorCode)
g_messageCenter:unsubscribe(AnimalMoveEvent, controller)
controller.actionTypeCallback(AnimalScreenBase.ACTION_TYPE_NONE, nil)
if errorCode == AnimalMoveEvent.MOVE_SUCCESS then
controller.sourceActionFinished(false, loadingTrigger.unloadSuccessText)
else
local mapping = AnimalScreenTrailerFarm.MOVE_TO_FARM_ERROR_CODE_MAPPING[errorCode]
controller.sourceActionFinished(mapping.isWarning, g_i18n:getText(mapping.text))
end
end
end
animalScreenController:init()
g_animalScreen:setController(animalScreenController)
g_gui:showGui("AnimalScreen")
end
end
animalLoadingTrigger.activatable.getIsActivatable = function (activatable)
local owner = activatable.owner or animalLoadingTrigger
if g_gui.currentGui == nil and owner.loadingVehicle ~= nil and owner.loadingVehicle:getNumOfAnimals() > 0 then
if owner.isPlayerInRange or owner.loadingVehicle.rootVehicle == g_currentMission.controlledVehicle then
if self.owningPlaceable:getOwnerFarmId() == g_currentMission:getFarmId() then
return g_currentMission:getHasPlayerPermission("tradeAnimals")
end
end
end
return false
end
self.animalLoadingTrigger = animalLoadingTrigger
if self.isClient then
local oldGetFillLevel = self.getFillLevel
self.getFillLevel = function(factory, fillTypeIndex)
if not factory.updatingProduction then
if factory.fillTypeToAnimalType ~= nil and factory.fillTypeToAnimalType[fillTypeIndex] then
return math.ceil(oldGetFillLevel(factory, fillTypeIndex) or 0)
end
end
return oldGetFillLevel(factory, fillTypeIndex)
end
local oldUpdateProduction = self.updateProduction
self.updateProduction = function(factory, ...)
factory.updatingProduction = true
oldUpdateProduction(factory, ...)
factory.updatingProduction = false
end
end
self.getClusterSystem = function(factory)
return {}
end
self.getClusters = function(factory)
return nil
end
self.getClusterById = function(factory, id)
return {}
end
self.getMaxNumOfAnimals = function(factory)
return factory.maxNumAnimals
end
self.getNumOfAnimals = function(factory)
local numAnimals = 0
for _, fillType in pairs(factory.animalTypeToFillType) do
numAnimals = numAnimals + math.ceil(factory:getFillLevel(fillType) or 0)
end
return numAnimals
end
self.getNumOfFreeAnimalSlots = function(factory, subTypeIndex)
local fillType = factory.animalSubTypeToFillType[subTypeIndex]
if fillType ~= nil then
return math.max((factory:getCapacity(fillType) or 0) - math.ceil(factory:getFillLevel(fillType) or 0), 0)
end
return 0
end
self.getSupportsAnimalSubType = function(factory, subTypeIndex)
return factory.animalSubTypeToFillType[subTypeIndex] ~= nil
end
self.addCluster = function(factory, cluster)
if factory.isServer and cluster ~= nil then
local fillType = factory.animalSubTypeToFillType[cluster.subTypeIndex]
if fillType ~= nil then
local movedAnimals = 0
local numAnimals = cluster.numAnimals
local unloadingStation = factory.unloadingStation
if unloadingStation ~= nil then
for _, targetStorage in pairs(unloadingStation.targetStorages) do
if unloadingStation:hasFarmAccessToStorage(factory.ownerFarmId, targetStorage) then
if targetStorage:getFreeCapacity(fillType) > 0 then
local oldTotalAnimals = targetStorage:getFillLevel(fillType)
targetStorage:setFillLevel(oldTotalAnimals + numAnimals, fillType, nil)
local newTotalAnimals = targetStorage:getFillLevel(fillType)
movedAnimals = movedAnimals + newTotalAnimals - oldTotalAnimals
end
if movedAnimals >= numAnimals - 0.001 then
movedAnimals = numAnimals
break
end
end
end
if movedAnimals > 0 then
cluster:changeNumAnimals(-movedAnimals)
end
end
end
end
end
end
end
if hasExtendedFeatures then
self.storage.setFillLevel = Utils.overwrittenFunction(self.storage.setFillLevel, function (storage, superFunc, fillLevel, fillType, fillInfo)
local oldFillLevel = storage.fillLevels[fillType]
superFunc(storage, fillLevel, fillType, fillInfo)
if oldFillLevel ~= nil then
self:updateExtendedFillLevelFeatures(fillType, storage.fillLevels[fillType], storage:getCapacity(fillType), oldFillLevel)
end
end)
for fillType, fillLevel in pairs(self.storage.fillLevels) do
self:updateExtendedFillLevelFeatures(fillType, fillLevel, self.storage:getCapacity(fillType), 0)
end
self.hasExtendedFeatures = true
end
-- Only requires update on load as this is just fill type title displays
for fillType, extendedFeatures in pairs(self.extendedFeaturesByFillType) do
if extendedFeatures.titleDisplays ~= nil then
for _, display in ipairs(extendedFeatures.titleDisplays) do
if display.func ~= nil then
display.func(_, _, fillType)
end
end
end
end
return true
end
function ExtendedProductionPoint:loadDisplays(xmlFile, key, components, i3dMappings, fillTypeIndex, displaysType)
local displays, titleDisplays
xmlFile:iterate(key .. ".display", function (_, displayKey)
local displayNode = xmlFile:getValue(displayKey .. "#node", nil, components, i3dMappings)
if displayNode ~= nil then
local fontName = xmlFile:getValue(displayKey .. "#font", "digit"):upper()
local fontMaterial = g_materialManager:getFontMaterial(fontName, self.customEnvironment)
if fontMaterial ~= nil then
local display = {
fillLevelColourType = 0,
displayNode = displayNode,
fontMaterial = fontMaterial,
upperCase = xmlFile:getValue(displayKey .. "#upperCase", false)
}
local alignmentStr = xmlFile:getValue(displayKey .. "#alignment", "RIGHT")
local alignment = RenderText["ALIGN_" .. alignmentStr:upper()] or RenderText.ALIGN_RIGHT
local size = xmlFile:getValue(displayKey .. "#size", 0.03)
local scaleX = xmlFile:getValue(displayKey .. "#scaleX", 1)
local scaleY = xmlFile:getValue(displayKey .. "#scaleY", 1)
local mask = xmlFile:getValue(displayKey .. "#mask", "0000000")
local emissiveScale = xmlFile:getValue(displayKey .. "#emissiveScale", 0.2)
local color = xmlFile:getValue(displayKey .. "#color", {0.9, 0.9, 0.9, 1}, true)
local hiddenColor = xmlFile:getValue(displayKey .. "#hiddenColor", nil, true)
if displaysType == "INPUT_OUTPUT" then
local fillLevelColourType = xmlFile:getValue(displayKey .. "#fillLevelColorType", "none"):upper()
if fillLevelColourType == "STANDARD" then
fillLevelColourType = 1
elseif fillLevelColourType == "INVERTED" then
fillLevelColourType = 2
else
fillLevelColourType = 0
end
-- Types: fillLevel | percent | capacity | title
local displayType = xmlFile:getValue(displayKey .. "#type", "fillLevel"):upper()
if displayType == "PERCENT" then
display.func = function(fillLevel, capacity)
local percent = capacity > 0 and (math.floor(fillLevel + 0.5) / capacity) or 0
if percent ~= display.lastValue then
local int, floatPart = math.modf(percent * 100)
local value = string.format(display.formatStr, int, math.abs(math.floor((floatPart + 1e-06) * 10 ^ display.formatPrecision)))
if display.fillLevelColourType == 0 then
display.fontMaterial:updateCharacterLine(display.characterLine, value)
else
local textColor = display.characterLine.textColor
if display.fillLevelColourType == 2 then
textColor[1], textColor[2], textColor[3] = MathUtil.lerp3(0, 1, 0, 1, 0, 0, percent)
else
textColor[1], textColor[2], textColor[3] = MathUtil.lerp3(1, 0, 0, 0, 1, 0, percent)
end
if display.hiddenColor == nil then
for i = 1, #display.characterLine.characters do
display.fontMaterial:setFontCharacterColor(display.characterLine.characters[i], textColor[1], textColor[2], textColor[3])
end
end
display.fontMaterial:updateCharacterLine(display.characterLine, value)
end
display.lastValue = percent
end
end
elseif displayType == "CAPACITY" then
display.func = function(_, capacity)
if capacity ~= display.lastValue then