Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- AIConveyorBelt
- AIDrivable
- AIFieldWorker
- AIImplement
- AIJobVehicle
- AIVehicle
- AIVehicleObstacle
- AnimatedVehicle
- ArticulatedAxis
- Attachable
- AttacherJointControl
- AttacherJoints
- AutoLoader
- BaleGrab
- BaleLoader
- Baler
- BaleWrapper
- BaseMaterial
- BigBag
- BunkerSiloCompacter
- BunkerSiloInteractor
- CCTDrivable
- Combine
- ConnectionHoses
- ConveyorBelt
- Cover
- CrabSteering
- Crawlers
- CropSensor
- Cultivator
- Cutter
- Cylindered
- CylinderedFoldable
- Dashboard
- Dischargeable
- Drivable
- DynamicallyLoadedParts
- DynamicMountAttacher
- Enterable
- ExtendedAIVehicle
- ExtendedCombine
- ExtendedMotorized
- ExtendedMower
- ExtendedSowingMachine
- ExtendedSprayer
- ExtendedWearable
- FertilizingCultivator
- FertilizingSowingMachine
- FillTriggerVehicle
- FillUnit
- FillVolume
- Foldable
- FoliageBending
- ForageWagon
- FrontloaderAttacher
- FruitPreparer
- GroundAdjustedNodes
- GroundReference
- HeadlandAnimation
- Honk
- HookLiftContainer
- HookLiftTrailer
- IKChains
- InlineWrapper
- JigglingParts
- Leveler
- LicensePlates
- Lights
- LivestockTrailer
- Locomotive
- LogGrab
- ManureBarrel
- ManureSensor
- MixerWagon
- Motorized
- Mountable
- Mower
- Mulcher
- MultipleItemPurchase
- Pallet
- Pickup
- Pipe
- PlaceableAI
- PlaceableAnimatedObjects
- PlaceableBeehive
- PlaceableBeehivePalletSpa...
- PlaceableBunkerSilo
- PlaceableBuyingStation
- PlaceableCartridgePlayer
- PlaceableChargingStation
- PlaceableClearAreas
- PlaceableColorable
- PlaceableDeletedNodes
- PlaceableDoghouse
- PlaceableDynamicallyLoade...
- PlaceableFarmhouse
- PlaceableFence
- PlaceableFoliageAreas
- PlaceableGreenhouse
- PlaceableHighPressureWash...
- PlaceableHotspots
- PlaceableHusbandry
- PlaceableHusbandryAnimals
- PlaceableHusbandryFeeding...
- PlaceableHusbandryFence
- PlaceableHusbandryFood
- PlaceableHusbandryLiquidM...
- PlaceableHusbandryMilk
- PlaceableHusbandryPallets
- PlaceableHusbandryStraw
- PlaceableHusbandryWater
- PlaceableIncomePerHour
- PlaceableIndoorAreas
- PlaceableInfoTrigger
- PlaceableLeveling
- PlaceableLights
- PlaceableManureHeap
- PlaceablePlacement
- PlaceableProductionPoint
- PlaceableSellingStation
- PlaceableSilo
- PlaceableSiloExtension
- PlaceableSolarPanels
- PlaceableTipOcclusionArea...
- PlaceableTrainSystem
- PlaceableTriggerMarkers
- PlaceableVine
- PlaceableWardrobe
- PlaceableWeatherStation
- PlaceableWeighingStation
- PlaceableWindTurbine
- PlaceableWorkshop
- Plow
- PlowPacker
- PowerConsumer
- PowerTakeOffs
- PrecisionFarmingStatistic
- PushHandTool
- RandomlyMovingParts
- ReceivingHopper
- ReverseDriving
- Rideable
- RidgeMarker
- Roller
- Ropes
- RTKStation
- SaltSpreader
- SemiTrailerFront
- Shovel
- SlopeCompensation
- SmartAttach
- SoilSampler
- SowingMachine
- SpeedRotatingParts
- SplineVehicle
- Sprayer
- StonePicker
- StrawBlower
- StumpCutter
- SupportVehicle
- Suspensions
- Tedder
- TensionBeltObject
- TensionBelts
- TestAreas
- TipOccluder
- Trailer
- TreePlanter
- TreeSaplingPallet
- TreeSaw
- TurnOnVehicle
- VariableWorkWidth
- VehicleSettings
- VineCutter
- VineDetector
- VinePrepruner
- Washable
- WaterTrailer
- Wearable
- Weeder
- WeedSpotSpray
- Wheels
- WindBending
- Windrower
- Wipers
- WoodCrusher
- WoodHarvester
- WorkArea
- WorkMode
- WorkParticles
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
PlaceableDoghouse
DescriptionSpecialization for placeablesFunctions
- canBuy
- dogInteractionTriggerCallback
- drawDogName
- getCanBePlacedAt
- getDog
- getNeedHourChanged
- getSpawnNode
- isDoghouseRegistered
- loadFromXMLFile
- onDelete
- onFinalizePlacement
- onHourChanged
- onLoad
- onReadStream
- onWriteStream
- prerequisitesPresent
- registerDoghouseToMission
- registerEventListeners
- registerFunctions
- registerOverwrittenFunctions
- registerSavegameXMLPaths
- registerXMLPaths
- saveToXMLFile
- setFoodBowlState
- setOwnerFarmId
- unregisterDoghouseToMission
canBuy
DescriptionDefinitioncanBuy()Code
329 | function PlaceableDoghouse:canBuy(superFunc) |
330 | local canBuy, warning = superFunc(self) |
331 | if not canBuy then |
332 | return false, warning |
333 | end |
334 | |
335 | if self:isDoghouseRegistered() then |
336 | return false, g_i18n:getText("warning_onlyOneOfThisItemAllowedPerFarm") |
337 | end |
338 | |
339 | return true, nil |
340 | end |
dogInteractionTriggerCallback
DescriptionDefinitiondogInteractionTriggerCallback()Code
216 | function PlaceableDoghouse:dogInteractionTriggerCallback(triggerId, otherId, onEnter, onLeave, onStay) |
217 | local spec = self.spec_doghouse |
218 | if spec.dog ~= nil then |
219 | if g_currentMission.player ~= nil and otherId == g_currentMission.player.rootNode and g_currentMission.player.farmId == self:getOwnerFarmId() then |
220 | if onEnter then |
221 | g_currentMission.activatableObjectsSystem:addActivatable(spec.activatable) |
222 | elseif onLeave then |
223 | g_currentMission.activatableObjectsSystem:removeActivatable(spec.activatable) |
224 | end |
225 | end |
226 | end |
227 | end |
drawDogName
DescriptionDefinitiondrawDogName()Code
231 | function PlaceableDoghouse:drawDogName() |
232 | local spec = self.spec_doghouse |
233 | if spec.dog ~= nil and spec.namePlateNode ~= nil then |
234 | -- @Todo: adust text width |
235 | setTextColor(0.843, 0.745, 0.705, 1.0) |
236 | setTextAlignment(RenderText.ALIGN_CENTER) |
237 | local x,y,z = getWorldTranslation(spec.namePlateNode) |
238 | local rx,ry,rz = getWorldRotation(spec.namePlateNode) |
239 | renderText3D(x,y,z, rx,ry,rz, 0.04, spec.dog.name) |
240 | setTextAlignment(RenderText.ALIGN_LEFT) |
241 | end |
242 | end |
getCanBePlacedAt
DescriptionDefinitiongetCanBePlacedAt()Code
319 | function PlaceableDoghouse:getCanBePlacedAt(superFunc, x, y, z, farmId) |
320 | if self:isDoghouseRegistered() then |
321 | return false, g_i18n:getText("warning_onlyOneOfThisItemAllowedPerFarm") |
322 | end |
323 | |
324 | return superFunc(self, x, y, z, farmId) |
325 | end |
getDog
DescriptionDefinitiongetDog()Code
307 | function PlaceableDoghouse:getDog() |
308 | return self.spec_doghouse.dog |
309 | end |
getNeedHourChanged
DescriptionDefinitiongetNeedHourChanged()Code
344 | function PlaceableDoghouse:getNeedHourChanged(superFunc) |
345 | return true |
346 | end |
getSpawnNode
DescriptionDefinitiongetSpawnNode()Code
313 | function PlaceableDoghouse:getSpawnNode() |
314 | return self.spec_doghouse.spawnNode |
315 | end |
isDoghouseRegistered
DescriptionReturns true if a doghouse is registeredDefinition
isDoghouseRegistered()Return Values
bool |
247 | function PlaceableDoghouse:isDoghouseRegistered() |
248 | local dogHouse = g_currentMission:getDoghouse(self:getOwnerFarmId()) |
249 | return dogHouse ~= nil |
250 | end |
loadFromXMLFile
DescriptionDefinitionloadFromXMLFile()Code
198 | function PlaceableDoghouse:loadFromXMLFile(xmlFile, key) |
199 | local spec = self.spec_doghouse |
200 | if spec.dog ~= nil then |
201 | spec.dog:loadFromXMLFile(xmlFile, key) |
202 | end |
203 | end |
onDelete
DescriptionDefinitiononDelete()Code
132 | function PlaceableDoghouse:onDelete() |
133 | local spec = self.spec_doghouse |
134 | |
135 | g_currentMission.activatableObjectsSystem:removeActivatable(spec.activatable) |
136 | |
137 | self:unregisterDoghouseToMission() |
138 | |
139 | if self.isServer then |
140 | if spec.dogBall ~= nil and not spec.dogBall.isDeleted then -- Note: the dogBall might have been deleted by the server/client delete loop already |
141 | spec.dogBall:delete() |
142 | spec.dogBall = nil |
143 | end |
144 | if spec.dog ~= nil and not spec.dog.isDeleted then -- Note: the dogBall might have been deleted by the server/client delete loop already |
145 | spec.dog:delete() |
146 | spec.dog = nil |
147 | end |
148 | end |
149 | |
150 | if spec.triggerNode ~= nil then |
151 | removeTrigger(spec.triggerNode) |
152 | end |
153 | end |
onFinalizePlacement
DescriptionDefinitiononFinalizePlacement()Code
157 | function PlaceableDoghouse:onFinalizePlacement() |
158 | local spec = self.spec_doghouse |
159 | |
160 | if self.isServer and spec.dog ~= nil then |
161 | spec.dog:finalizePlacement() |
162 | end |
163 | |
164 | self:registerDoghouseToMission() |
165 | end |
onHourChanged
DescriptionDefinitiononHourChanged()Code
350 | function PlaceableDoghouse:onHourChanged() |
351 | self:setFoodBowlState(false, true) |
352 | end |
onLoad
DescriptionCalled on loadingDefinition
onLoad(table savegame)Arguments
table | savegame | savegame |
84 | function PlaceableDoghouse:onLoad(savegame) |
85 | local spec = self.spec_doghouse |
86 | local xmlFile = self.xmlFile |
87 | |
88 | spec.spawnNode = xmlFile:getValue("placeable.dogHouse.dog#node", nil, self.components, self.i3dMappings) |
89 | if self.isServer then |
90 | local posX, posY, posZ = getWorldTranslation(spec.spawnNode) |
91 | local xmlFilename = Utils.getFilename(xmlFile:getValue("placeable.dogHouse.dog#xmlFilename"), self.baseDirectory) |
92 | spec.dog = Dog.new(self.isServer, self.isClient) |
93 | spec.dog:setOwnerFarmId(self:getOwnerFarmId(), true) |
94 | if spec.dog:load(self, xmlFilename, posX, posY, posZ) then |
95 | spec.dog:register() |
96 | else |
97 | Logging.xmlWarning(xmlFile, "Could not load dog!") |
98 | end |
99 | end |
100 | |
101 | spec.namePlateNode = xmlFile:getValue("placeable.dogHouse.nameplate#node", nil, self.components, self.i3dMappings) |
102 | |
103 | spec.ballSpawnNode = xmlFile:getValue("placeable.dogHouse.ball#node", nil, self.components, self.i3dMappings) |
104 | if self.isServer then |
105 | local dogBallFilename = Utils.getFilename(xmlFile:getValue("placeable.dogHouse.ball#filename"), self.baseDirectory) |
106 | local x, y, z = getWorldTranslation(spec.ballSpawnNode) |
107 | local rx, ry, rz = getWorldRotation(spec.ballSpawnNode) |
108 | spec.dogBall = DogBall.new(self.isServer, self.isClient) |
109 | spec.dogBall:setOwnerFarmId(self:getOwnerFarmId(), true) |
110 | spec.dogBall:load(dogBallFilename, x, y, z, rx, ry, rz, self) |
111 | spec.dogBall:register() |
112 | end |
113 | |
114 | -- player interaction trigger |
115 | spec.triggerNode = xmlFile:getValue("placeable.dogHouse.playerInteractionTrigger#node", nil, self.components, self.i3dMappings) |
116 | if spec.triggerNode ~= nil then |
117 | addTrigger(spec.triggerNode, "dogInteractionTriggerCallback", self) |
118 | end |
119 | |
120 | spec.foodNode = xmlFile:getValue("placeable.dogHouse.bowl#foodNode", nil, self.components, self.i3dMappings) |
121 | if spec.foodNode == nil then |
122 | Logging.xmlWarning(xmlFile, "Missing bowl food node in 'placeable.dogHouse.bowl#foodNode'!") |
123 | else |
124 | setVisibility(spec.foodNode, false) |
125 | end |
126 | |
127 | spec.activatable = PlaceableDoghouseActivatable.new(self) |
128 | end |
onReadStream
DescriptionDefinitiononReadStream()Code
169 | function PlaceableDoghouse:onReadStream(streamId, connection) |
170 | if connection:getIsServer() then |
171 | local spec = self.spec_doghouse |
172 | spec.dog = NetworkUtil.readNodeObject(streamId) |
173 | if spec.dog ~= nil then |
174 | spec.dog.spawner = self |
175 | end |
176 | if spec.foodNode ~= nil then |
177 | setVisibility(spec.foodNode, streamReadBool(streamId)) |
178 | end |
179 | end |
180 | end |
onWriteStream
DescriptionCalled on server side on joinDefinition
onWriteStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
186 | function PlaceableDoghouse:onWriteStream(streamId, connection) |
187 | if not connection:getIsServer() then |
188 | local spec = self.spec_doghouse |
189 | NetworkUtil.writeNodeObject(streamId, spec.dog) |
190 | if spec.foodNode ~= nil then |
191 | streamWriteBool(streamId, getVisibility(spec.foodNode)) |
192 | end |
193 | end |
194 | end |
prerequisitesPresent
DescriptionChecks if all prerequisite specializations are loadedDefinition
prerequisitesPresent(table specializations)Arguments
table | specializations | specializations |
boolean | hasPrerequisite | true if all prerequisite specializations are loaded |
21 | function PlaceableDoghouse.prerequisitesPresent(specializations) |
22 | return true |
23 | end |
registerDoghouseToMission
DescriptionRegisters the doghouse to the mission game.Definition
registerDoghouseToMission()Return Values
bool | true | if registration went well |
255 | function PlaceableDoghouse:registerDoghouseToMission() |
256 | if not self:isDoghouseRegistered() then |
257 | g_currentMission.doghouses[self] = self |
258 | return true |
259 | end |
260 | |
261 | return false |
262 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
50 | function PlaceableDoghouse.registerEventListeners(placeableType) |
51 | SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableDoghouse) |
52 | SpecializationUtil.registerEventListener(placeableType, "onDelete", PlaceableDoghouse) |
53 | SpecializationUtil.registerEventListener(placeableType, "onFinalizePlacement", PlaceableDoghouse) |
54 | SpecializationUtil.registerEventListener(placeableType, "onWriteStream", PlaceableDoghouse) |
55 | SpecializationUtil.registerEventListener(placeableType, "onReadStream", PlaceableDoghouse) |
56 | SpecializationUtil.registerEventListener(placeableType, "onHourChanged", PlaceableDoghouse) |
57 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
27 | function PlaceableDoghouse.registerFunctions(placeableType) |
28 | SpecializationUtil.registerFunction(placeableType, "dogInteractionTriggerCallback", PlaceableDoghouse.dogInteractionTriggerCallback) |
29 | SpecializationUtil.registerFunction(placeableType, "drawDogName", PlaceableDoghouse.drawDogName) |
30 | SpecializationUtil.registerFunction(placeableType, "isDoghouseRegistered", PlaceableDoghouse.isDoghouseRegistered) |
31 | SpecializationUtil.registerFunction(placeableType, "registerDoghouseToMission", PlaceableDoghouse.registerDoghouseToMission) |
32 | SpecializationUtil.registerFunction(placeableType, "unregisterDoghouseToMission", PlaceableDoghouse.unregisterDoghouseToMission) |
33 | SpecializationUtil.registerFunction(placeableType, "setFoodBowlState", PlaceableDoghouse.setFoodBowlState) |
34 | SpecializationUtil.registerFunction(placeableType, "getDog", PlaceableDoghouse.getDog) |
35 | SpecializationUtil.registerFunction(placeableType, "getSpawnNode", PlaceableDoghouse.getSpawnNode) |
36 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
41 | function PlaceableDoghouse.registerOverwrittenFunctions(placeableType) |
42 | SpecializationUtil.registerOverwrittenFunction(placeableType, "setOwnerFarmId", PlaceableDoghouse.setOwnerFarmId) |
43 | SpecializationUtil.registerOverwrittenFunction(placeableType, "canBuy", PlaceableDoghouse.canBuy) |
44 | SpecializationUtil.registerOverwrittenFunction(placeableType, "getCanBePlacedAt", PlaceableDoghouse.getCanBePlacedAt) |
45 | SpecializationUtil.registerOverwrittenFunction(placeableType, "getNeedHourChanged", PlaceableDoghouse.getNeedHourChanged) |
46 | end |
registerSavegameXMLPaths
DescriptionDefinitionregisterSavegameXMLPaths()Code
75 | function PlaceableDoghouse.registerSavegameXMLPaths(schema, basePath) |
76 | schema:setXMLSpecializationType("Doghouse") |
77 | Dog.registerSavegameXMLPaths(schema, basePath) |
78 | schema:setXMLSpecializationType() |
79 | end |
registerXMLPaths
DescriptionDefinitionregisterXMLPaths()Code
61 | function PlaceableDoghouse.registerXMLPaths(schema, basePath) |
62 | schema:setXMLSpecializationType("Doghouse") |
63 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".dogHouse.dog#node", "Dog link node") |
64 | schema:register(XMLValueType.STRING, basePath .. ".dogHouse.dog#xmlFilename", "Dog xml filename") |
65 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".dogHouse.nameplate#node", "Name plate node") |
66 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".dogHouse.ball#node", "Ball node") |
67 | schema:register(XMLValueType.STRING, basePath .. ".dogHouse.ball#filename", "Ball 3d file") |
68 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".dogHouse.playerInteractionTrigger#node", "Interaction trigger node") |
69 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".dogHouse.bowl#foodNode", "Food node in bowl") |
70 | schema:setXMLSpecializationType() |
71 | end |
saveToXMLFile
DescriptionDefinitionsaveToXMLFile()Code
207 | function PlaceableDoghouse:saveToXMLFile(xmlFile, key, usedModNames) |
208 | local spec = self.spec_doghouse |
209 | if spec.dog ~= nil then |
210 | spec.dog:saveToXMLFile(xmlFile, key, usedModNames) |
211 | end |
212 | end |
setFoodBowlState
DescriptionDefinitionsetFoodBowlState()Code
292 | function PlaceableDoghouse:setFoodBowlState(isFilled, noEventSend) |
293 | local spec = self.spec_doghouse |
294 | if spec.foodNode ~= nil then |
295 | PlaceableDoghouseFoodBowlStateEvent.sendEvent(self, isFilled, noEventSend) |
296 | |
297 | setVisibility(spec.foodNode, isFilled) |
298 | |
299 | if isFilled and spec.dog ~= nil then |
300 | spec.dog:onFoodBowlFilled(spec.foodNode) |
301 | end |
302 | end |
303 | end |
setOwnerFarmId
DescriptionDefinitionsetOwnerFarmId()Code
275 | function PlaceableDoghouse:setOwnerFarmId(superFunc, farmId, noEventSend) |
276 | superFunc(self, farmId, noEventSend) |
277 | |
278 | if self.isServer then |
279 | local spec = self.spec_doghouse |
280 | -- Note: we need to send events for the dog and the dogBall if we need to send one for the doghouse |
281 | if spec.dog ~= nil then |
282 | spec.dog:setOwnerFarmId(farmId, noEventSend) |
283 | end |
284 | if spec.dogBall ~= nil then |
285 | spec.dogBall:setOwnerFarmId(farmId, noEventSend) |
286 | end |
287 | end |
288 | end |
unregisterDoghouseToMission
DescriptionRegisters the doghouse to the mission game.Definition
unregisterDoghouseToMission()Return Values
bool | true | if registration went well |
267 | function PlaceableDoghouse:unregisterDoghouseToMission() |
268 | g_currentMission.doghouses[self] = nil |
269 | |
270 | return true |
271 | end |