Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- AbstractManager
- AsyncManager
- AutoSaveManager
- BaleTypeManager
- BrandColorManager
- ConnectionHoseManager
- DeferredLoadingManager
- DepthOfFieldManager
- FillTypeManager
- FruitTypeManager
- GameplayHintManager
- GroundTypeManager
- HelpLineManager
- MapManager
- PlaceableTypeManager
- SleepManager
- SplitTypeManager
- SprayTypeManager
- TensionBeltManager
- ToolTypeManager
- TreePlantManager
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
Foundation Reference
FruitTypeManager
DescriptionThis class handles all fruitTypes and fruitTypeCategoriesParent
AbstractManagerFunctions
- getFruitTypeByIndex
- getFruitTypeByName
- getFruitTypes
- getFruitTypesByCategoryNames
- initDataStructures
- loadMapData
- new
getFruitTypeByIndex
DescriptionGets a fruitType by indexDefinition
getFruitTypeByIndex(integer index)Arguments
integer | index | the fruit index |
table | fruit | the fruit object |
521 | function FruitTypeManager:getFruitTypeByIndex(index) |
522 | if index ~= nil then |
523 | return self.indexToFruitType[index] |
524 | end |
525 | return nil |
526 | end |
getFruitTypeByName
DescriptionGets a fruitType by index nameDefinition
getFruitTypeByName(string name)Arguments
string | name | the fruit index name |
table | fruit | the fruit object |
539 | function FruitTypeManager:getFruitTypeByName(name) |
540 | if name ~= nil then |
541 | name = name:upper() |
542 | return self.nameToFruitType[name] |
543 | end |
544 | return nil |
545 | end |
getFruitTypes
DescriptionGets a list of fruitTypesDefinition
getFruitTypes()Return Values
table | fruitTypes | a list of fruitTypes |
550 | function FruitTypeManager:getFruitTypes() |
551 | return self.fruitTypes |
552 | end |
getFruitTypesByCategoryNames
DescriptionGets a list of fruitTypes of the given category namesDefinition
getFruitTypesByCategoryNames(string name, string warning)Arguments
string | name | fruitType category index names |
string | warning | a warning text shown if a category is not found |
table | fruitTypes | list of fruitTypes |
633 | function FruitTypeManager:getFruitTypesByCategoryNames(names, warning) |
634 | local fruitTypes = {} |
635 | local alreadyAdded = {} |
636 | local categories = StringUtil.splitString(" ", names) |
637 | for _, categoryName in pairs(categories) do |
638 | categoryName = categoryName:upper() |
639 | local categoryIndex = self.categories[categoryName] |
640 | local categoryFruitTypes = self.categoryToFruitTypes[categoryIndex] |
641 | if categoryFruitTypes ~= nil then |
642 | for _, fruitType in ipairs(categoryFruitTypes) do |
643 | if alreadyAdded[fruitType] == nil then |
644 | table.insert(fruitTypes, fruitType) |
645 | alreadyAdded[fruitType] = true |
646 | end |
647 | end |
648 | else |
649 | if warning ~= nil then |
650 | print(string.format(warning, categoryName)) |
651 | end |
652 | end |
653 | end |
654 | return fruitTypes |
655 | end |
initDataStructures
DescriptionInitialize data structuresDefinition
initDataStructures()Code
35 | function FruitTypeManager:initDataStructures() |
36 | self.fruitTypes = {} |
37 | self.indexToFruitType = {} |
38 | self.nameToIndex = {} |
39 | self.nameToFruitType = {} |
40 | self.fruitTypeIndexToFillType = {} |
41 | self.fillTypeIndexToFruitTypeIndex = {} |
42 | |
43 | self.fruitTypeConverters = {} |
44 | self.converterNameToIndex = {} |
45 | self.nameToConverter = {} |
46 | |
47 | self.windrowFillTypes = {} |
48 | self.fruitTypeIndexToWindrowFillTypeIndex = {} |
49 | |
50 | self.numCategories = 0 |
51 | self.categories = {} |
52 | self.indexToCategory = {} |
53 | self.categoryToFruitTypes = {} |
54 | |
55 | self.weedFruitType = nil |
56 | |
57 | FruitType = self.nameToIndex |
58 | FruitType.UNKNOWN = 0 |
59 | FruitTypeCategory = self.categories |
60 | FruitTypeConverter = self.converterNameToIndex |
61 | end |
loadMapData
DescriptionLoad data on map loadDefinition
loadMapData()Return Values
boolean | true | if loading was successful else false |
73 | function FruitTypeManager:loadMapData(xmlFile, missionInfo, baseDirectory) |
74 | FruitTypeManager:superClass().loadMapData(self) |
75 | |
76 | self:loadDefaultTypes() |
77 | return XMLUtil.loadDataFromMapXML(xmlFile, "fruitTypes", baseDirectory, self, self.loadFruitTypes, missionInfo) |
78 | end |
new
DescriptionCreating managerDefinition
new()Return Values
table | instance | instance of object |
28 | function FruitTypeManager:new(customMt) |
29 | local self = AbstractManager:new(customMt or FruitTypeManager_mt) |
30 | return self |
31 | end |