Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- AnimalLoadingTrigger
- BasketTrigger
- FillPlane
- FillTrigger
- InsideBuildingTrigger
- LoadTrigger
- LoadTriggerSetIsLoadingEv...
- LoanTrigger
- RainDropFactorTrigger
- ShopTrigger
- TransportMissionTrigger
- UnloadFeedingTrough
- UnloadTrigger
- WeighStation
- 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
UnloadFeedingTrough
ParentUnloadTriggerFunctions
- addFillUnitFillLevel
- initFillTypesFromFoodGroups
- load
- loadAnimalPlaces
- loadFillTypes
- new
- updateAnimalPlaces
addFillUnitFillLevel
DescriptionChanges fill levels from a toolDefinition
addFillUnitFillLevel(float deltaFillLevel, integer fillType, table fillInfo, integer toolType)Arguments
float | deltaFillLevel | |
integer | fillType | |
table | fillInfo | |
integer | toolType |
float | returns | the change delta |
102 | function UnloadFeedingTrough:addFillUnitFillLevel(farmId, fillUnitIndex, fillLevelDelta, fillTypeIndex, toolType, fillPositionData) |
103 | local foodMixture = g_animalFoodManager:getFoodMixtureByFillType(fillTypeIndex) |
104 | local delta = 0 |
105 | if foodMixture ~= nil then |
106 | for _, ingredient in ipairs(foodMixture.ingredients) do |
107 | local ingredientFillType = ingredient.fillTypes[1] |
108 | local ingredientFillLevel = fillLevelDelta * ingredient.weight |
109 | delta = delta + UnloadFeedingTrough:superClass().addFillUnitFillLevel(self, farmId, fillUnitIndex, ingredientFillLevel, ingredientFillType, toolType, fillPositionData) |
110 | end |
111 | else |
112 | delta = UnloadFeedingTrough:superClass().addFillUnitFillLevel(self, farmId, fillUnitIndex, fillLevelDelta, fillTypeIndex, toolType, fillPositionData) |
113 | end |
114 | |
115 | self:updateAnimalPlaces(delta) |
116 | return delta |
117 | end |
initFillTypesFromFoodGroups
DescriptionSetup fillTypes from animal food groupsDefinition
initFillTypesFromFoodGroups(table foodGroups)Arguments
table | foodGroups |
82 | function UnloadFeedingTrough:initFillTypesFromFoodGroups(foodGroups) |
83 | self.fillTypes = {} |
84 | for _, foodGroup in pairs(foodGroups) do |
85 | for _, fillTypeIndex in pairs(foodGroup.fillTypes) do |
86 | self.fillTypes[fillTypeIndex] = true |
87 | end |
88 | end |
89 | end |
load
DescriptionLoads elements of the classDefinition
load(table rootNode, string xmlFile, string xmlNode)Arguments
table | rootNode | of the object |
string | xmlFile | file to read |
string | xmlNode | xmlNode to read from |
bool | return | true if successful |
40 | function UnloadFeedingTrough:load(rootNode, xmlFile, xmlNode, target) |
41 | local returnValue = UnloadFeedingTrough:superClass().load(self, rootNode, xmlFile, xmlNode, target) |
42 | |
43 | if returnValue then |
44 | self:loadAnimalPlaces(rootNode, xmlFile, xmlNode) |
45 | end |
46 | return returnValue |
47 | end |
loadAnimalPlaces
DescriptionLoads animal placesDefinition
loadAnimalPlaces(table rootNode, string xmlFile, string xmlNode)Arguments
table | rootNode | of the object |
string | xmlFile | file to read |
string | xmlNode | xmlNode to read from |
54 | function UnloadFeedingTrough:loadAnimalPlaces(rootNode, xmlFile, xmlNode) |
55 | -- print(string.format("-- [UnloadFeedingTrough:loadAnimalPlaces] rootNode(%s) xmlFile(%s) xmlNode(%s)", tostring(rootNode), tostring(xmlFile), tostring(xmlNode))) |
56 | local animalPlacesNode = XMLUtil.getValueFromXMLFileOrUserAttribute(xmlFile, xmlNode, "animalPlacesNode", getXMLString, rootNode) |
57 | if animalPlacesNode ~= nil then |
58 | local animalPlaces = I3DUtil.indexToObject(rootNode, animalPlacesNode) |
59 | -- print(string.format("-- [UnloadFeedingTrough:loadAnimalPlaces] animalPlacesNode(%s) animalPlaces(%s)", tostring(animalPlacesNode), tostring(animalPlaces))) |
60 | if animalPlaces ~= nil and self.target~= nil and self.target.husbandryId ~= nil then |
61 | for i = 1, getNumOfChildren(animalPlaces) do |
62 | local animalPlaceId = getChildAt(animalPlaces, i - 1) |
63 | local animalPlace = addFeedingPlace(self.target.husbandryId, animalPlaceId, 0.0) |
64 | table.insert(self.animalPlaces, animalPlace) |
65 | end |
66 | end |
67 | end |
68 | end |
loadFillTypes
DescriptionOverriding Unload Trigger method with empty method. The animal husbandry module is taking care of setting up the filltypesDefinition
loadFillTypes(table rootNode, string xmlFile, string xmlNode)Arguments
table | rootNode | of the object |
string | xmlFile | file to read |
string | xmlNode | xmlNode to read from |
75 | function UnloadFeedingTrough:loadFillTypes(rootNode, xmlFile, xmlNode) |
76 | end |
new
DescriptionCreates a new instance of the classDefinition
new(bool isServer, bool isClient, table customMt)Arguments
bool | isServer | true if we are server |
bool | isClient | true if we are client |
table | customMt | meta table |
table | self | returns the instance |
25 | function UnloadFeedingTrough:new(isServer, isClient, customMt) |
26 | local self = UnloadTrigger:new(isServer, isClient, customMt or UnloadFeedingTrough_mt) |
27 | |
28 | self.animalPlaces = {} |
29 | self.notAllowedWarningText = string.format(g_i18n:getText("warning_inAdvanceFeedingLimitReached"), HusbandryModuleAnimal.TROUGH_CAPACITY) |
30 | |
31 | return self |
32 | end |
updateAnimalPlaces
DescriptionChanges animal places visualsDefinition
updateAnimalPlaces()Code
121 | function UnloadFeedingTrough:updateAnimalPlaces(delta) |
122 | if delta ~= nil and delta > 0 then |
123 | for _, animalPlace in pairs(self.animalPlaces) do |
124 | updateFeedingPlace(self.target.husbandryId, animalPlace, delta) |
125 | end |
126 | end |
127 | end |