Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- AnimalHusbandry
- BeehivePlaceable
- BgaPlaceable
- BunkerSiloPlaceable
- BuyingStationPlaceable
- Doghouse
- FarmhousePlaceable
- GreenhousePlaceable
- HeatingPlantPlaceable
- HusbandryModuleWater
- Placeable
- SellingStationPlaceable
- SiloExtensionPlaceable
- SiloPlaceable
- SolarCollectorPlaceable
- WindTurbinePlaceable
- WoodSellStationPlaceable
- 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
Doghouse
ParentPlaceableFunctions
- canBuy
- delete
- drawActivate
- drawDogName
- finalizePlacement
- getCanBePlacedAt
- getIsActivatable
- isDoghouseRegistered
- loadFromXMLFile
- new
- onActivateObject
- playerInteractionTriggerCallback
- readStream
- readUpdateStream
- registerDoghouseToMission
- saveToXMLFile
- unregisterDoghouseToMission
- writeStream
- writeUpdateStream
canBuy
DescriptionReturns true if we can place a buildingDefinition
canBuy()Return Values
bool |
66 | function Doghouse:canBuy() |
67 | local canBuy = AnimalHusbandry:superClass().canBuy(self) |
68 | return canBuy and not self:isDoghouseRegistered(), g_i18n:getText("warning_onlyOneOfThisItemAllowedPerFarm") |
69 | end |
delete
DescriptionDelete instanceDefinition
delete()Code
32 | function Doghouse:delete() |
33 | self:unregisterDoghouseToMission() |
34 | |
35 | if self.isServer then |
36 | if self.dogBall ~= nil and not self.dogBall.isDeleted then -- Note: the dogBall might have been deleted by the server/client delete loop already |
37 | self.dogBall:delete() |
38 | self.dogBall = nil |
39 | end |
40 | if self.dog ~= nil and not self.dog.isDeleted then -- Note: the dogBall might have been deleted by the server/client delete loop already |
41 | self.dog:delete() |
42 | self.dog = nil |
43 | end |
44 | end |
45 | |
46 | if self.triggerNode ~= nil then |
47 | removeTrigger(self.triggerNode) |
48 | end |
49 | |
50 | unregisterObjectClassName(self) |
51 | |
52 | Doghouse:superClass().delete(self) |
53 | end |
drawActivate
DescriptionDraw HUD iconDefinition
drawActivate()Code
265 | function Doghouse:drawActivate() |
266 | g_currentMission:showFillDogBowlContext() |
267 | end |
drawDogName
DescriptionDefinitiondrawDogName()Code
222 | function Doghouse:drawDogName() |
223 | -- @Todo: adust text width |
224 | setTextColor(0.843, 0.745, 0.705, 1.0) |
225 | setTextAlignment(RenderText.ALIGN_CENTER) |
226 | local x,y,z = getWorldTranslation(self.namePlateNode) |
227 | local rx,ry,rz = getWorldRotation(self.namePlateNode) |
228 | renderText3D(x,y,z, rx,ry,rz, 0.04, self.dog.name) |
229 | setTextAlignment(RenderText.ALIGN_LEFT) |
230 | end |
finalizePlacement
DescriptionFinalize placementDefinition
finalizePlacement()Return Values
bool | returns | true if placement successful |
74 | function Doghouse:finalizePlacement() |
75 | Doghouse:superClass().finalizePlacement(self) |
76 | |
77 | -- dog specific information |
78 | local xmlFile = loadXMLFile("TempXML", self.configFileName) |
79 | |
80 | if xmlFile == 0 then |
81 | return false |
82 | end |
83 | |
84 | self.spawnNode = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.dogHouse.dog#node")) |
85 | if self.isServer then |
86 | local posX, posY, posZ = getWorldTranslation(self.spawnNode) |
87 | local xmlFilename = Utils.getFilename(getXMLString(xmlFile, "placeable.dogHouse.dog#xmlFilename"), self.baseDirectory) |
88 | self.dog = Dog:new(self.isServer, self.isClient) |
89 | self.dog:setOwnerFarmId(self:getOwnerFarmId(), true) |
90 | self.dog:load(self, xmlFilename, posX, posY, posZ) |
91 | self.dog:register() |
92 | end |
93 | |
94 | self:registerDoghouseToMission() |
95 | |
96 | self.namePlateNode = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.dogHouse.nameplate#node")) |
97 | |
98 | self.ballSpawnNode = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.dogHouse.ball#node")) |
99 | if self.isServer then |
100 | local dogBallFilename = Utils.getFilename(getXMLString(xmlFile, "placeable.dogHouse.ball#filename"), self.baseDirectory) |
101 | local x, y, z = getWorldTranslation(self.ballSpawnNode) |
102 | local rx, ry, rz = getWorldRotation(self.ballSpawnNode) |
103 | self.dogBall = DogBall:new(self.isServer, self.isClient) |
104 | self.dogBall:setOwnerFarmId(self:getOwnerFarmId(), true) |
105 | self.dogBall:load(dogBallFilename, x, y, z, rx, ry, rz, self) |
106 | self.dogBall:register() |
107 | end |
108 | |
109 | |
110 | -- player interaction trigger |
111 | self.triggerNode = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.dogHouse.playerInteractionTrigger#node")) |
112 | if self.triggerNode ~= nil then |
113 | addTrigger(self.triggerNode, "playerInteractionTriggerCallback", self) |
114 | end |
115 | |
116 | self.foodNode = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.dogHouse.bowl#foodNode")) |
117 | delete(xmlFile) |
118 | if self.foodNode ~= nil then |
119 | setVisibility(self.foodNode, false) |
120 | return true |
121 | end |
122 | return false |
123 | end |
getCanBePlacedAt
DescriptionReturns true if we can place a buildingDefinition
getCanBePlacedAt()Return Values
bool |
58 | function Doghouse:getCanBePlacedAt(x, y, z, distance, farmId) |
59 | local canBePlaced = Doghouse:superClass().getCanBePlacedAt(self, x, y, z, distance, farmId) |
60 | return canBePlaced and not self:isDoghouseRegistered() |
61 | end |
getIsActivatable
DescriptionChecks if doghouse can be activated and bowl is emptyDefinition
getIsActivatable()Return Values
bool | return | true if doghouse can be activated to fill bowl |
259 | function Doghouse:getIsActivatable() |
260 | return self.isActivatable |
261 | end |
isDoghouseRegistered
DescriptionReturns true if a doghouse is registeredDefinition
isDoghouseRegistered()Return Values
bool |
285 | function Doghouse:isDoghouseRegistered() |
286 | local dogHouse = g_currentMission:getDoghouse(self:getOwnerFarmId()) |
287 | return dogHouse ~= nil |
288 | end |
loadFromXMLFile
DescriptionLoading from attributes and nodesDefinition
loadFromXMLFile(integer xmlFile, string key, boolean resetVehicles)Arguments
integer | xmlFile | id of xml object |
string | key | key |
boolean | resetVehicles | reset vehicles |
boolean | success | success |
183 | function Doghouse:loadFromXMLFile(xmlFile, key, resetVehicles) |
184 | if not Doghouse:superClass().loadFromXMLFile(self, xmlFile, key, resetVehicles) then |
185 | return false |
186 | end |
187 | |
188 | return self.dog:loadFromXMLFile(xmlFile, key..".dog", resetVehicles) |
189 | end |
new
DescriptionCreating instance and initializing member variablesDefinition
new(boolean isServer, boolean isClient, table customMt)Arguments
boolean | isServer | is server |
boolean | isClient | is client |
table | customMt | custom meta table |
table | instance | Instance of object |
15 | function Doghouse:new(isServer, isClient, customMt) |
16 | local self = Placeable:new(isServer, isClient, customMt or Doghouse_mt) |
17 | |
18 | registerObjectClassName(self, "Doghouse") |
19 | |
20 | -- trigger |
21 | self.triggerNode = nil |
22 | self.isActivatable = false |
23 | self.activateText = g_i18n:getText("action_doghouseFillbowl") |
24 | |
25 | self.dirtyFlag = self:getNextDirtyFlag() |
26 | |
27 | return self |
28 | end |
onActivateObject
DescriptionCallback on bowl activatedDefinition
onActivateObject()Code
252 | function Doghouse:onActivateObject() |
253 | self:raiseActive() |
254 | end |
playerInteractionTriggerCallback
DescriptionCallback when interaction trigger is activatedDefinition
playerInteractionTriggerCallback(integer triggerId, integer otherId, boolean onEnter, boolean onLeave, boolean onStay)Arguments
integer | triggerId | id of trigger |
integer | otherId | id of actor |
boolean | onEnter | on enter |
boolean | onLeave | on leave |
boolean | onStay | on stay |
239 | function Doghouse:playerInteractionTriggerCallback(triggerId, otherId, onEnter, onLeave, onStay) |
240 | if g_currentMission.player ~= nil and otherId == g_currentMission.player.rootNode and g_currentMission.player.farmId == self:getOwnerFarmId() then |
241 | if onEnter then |
242 | self.isActivatable = true |
243 | elseif onLeave then |
244 | self.isActivatable = false |
245 | end |
246 | end |
247 | --self:raiseActive() |
248 | end |
readStream
DescriptionCalled on client side on joinDefinition
readStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
129 | function Doghouse:readStream(streamId, connection) |
130 | Doghouse:superClass().readStream(self, streamId, connection) |
131 | if connection:getIsServer() then |
132 | self.dog = NetworkUtil.readNodeObject(streamId) |
133 | if self.dog ~= nil then |
134 | self.dog.spawner = self |
135 | end |
136 | setVisibility(self.foodNode, streamReadBool(streamId)) |
137 | end |
138 | end |
readUpdateStream
DescriptionRead update network streamDefinition
readUpdateStream(integer streamId, integer timestamp, table connection)Arguments
integer | streamId | network stream identification |
integer | timestamp | |
table | connection | connection information |
158 | function Doghouse:readUpdateStream(streamId, timestamp, connection) |
159 | Doghouse:superClass().readUpdateStream(self, streamId, timestamp, connection) |
160 | if connection:getIsServer() then |
161 | setVisibility(self.foodNode, streamReadBool(streamId)) |
162 | end |
163 | end |
registerDoghouseToMission
DescriptionRegisters the doghouse to the mission game.Definition
registerDoghouseToMission()Return Values
bool | true | if registration went well |
293 | function Doghouse:registerDoghouseToMission() |
294 | if not self:isDoghouseRegistered() then |
295 | g_currentMission.doghouses[self] = self |
296 | return true |
297 | end |
298 | return false |
299 | end |
saveToXMLFile
DescriptionGet save attributes and nodesDefinition
saveToXMLFile(string nodeIdent)Arguments
string | nodeIdent | node ident |
string | attributes | attributes |
string | nodes | nodes |
196 | function Doghouse:saveToXMLFile(xmlFile, key, usedModNames) |
197 | Doghouse:superClass().saveToXMLFile(self, xmlFile, key, usedModNames) |
198 | |
199 | self.dog:saveToXMLFile(xmlFile, key..".dog", usedModNames) |
200 | end |
unregisterDoghouseToMission
DescriptionRegisters the doghouse to the mission game.Definition
unregisterDoghouseToMission()Return Values
bool | true | if registration went well |
304 | function Doghouse:unregisterDoghouseToMission() |
305 | g_currentMission.doghouses[self] = nil |
306 | return true |
307 | end |
writeStream
DescriptionCalled on server side on joinDefinition
writeStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
144 | function Doghouse:writeStream(streamId, connection) |
145 | Doghouse:superClass().writeStream(self, streamId, connection) |
146 | if not connection:getIsServer() then |
147 | NetworkUtil.writeNodeObject(streamId, self.dog) |
148 | streamWriteBool(streamId, getVisibility(self.foodNode)) |
149 | end |
150 | end |
writeUpdateStream
DescriptionWrite update network streamDefinition
writeUpdateStream(integer streamId, table connection, integer dirtyMask)Arguments
integer | streamId | network stream identification |
table | connection | connection information |
integer | dirtyMask |
170 | function Doghouse:writeUpdateStream(streamId, connection, dirtyMask) |
171 | Doghouse:superClass().writeUpdateStream(self, streamId, connection, dirtyMask) |
172 | if not connection:getIsServer() then |
173 | streamWriteBool(streamId, getVisibility(self.foodNode)) |
174 | end |
175 | end |