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
BunkerSiloPlaceable
DescriptionClass for bgaFunctions
collectPickObjects
DescriptionCollect pick objectsDefinition
collectPickObjects(integer node)Arguments
integer | node | node id |
134 | function BunkerSiloPlaceable:collectPickObjects(node) |
135 | -- local foundNode = false |
136 | -- for _, unloadTrigger in ipairs(self.bga.bunker.unloadingStation.unloadTriggers) do |
137 | -- if node == unloadTrigger.exactFillRootNode then |
138 | -- foundNode = true |
139 | -- break |
140 | -- end |
141 | -- end |
142 | |
143 | if not foundNode then |
144 | BunkerSiloPlaceable:superClass().collectPickObjects(self, node) |
145 | end |
146 | end |
delete
DescriptionDeleting placeable siloDefinition
delete()Code
32 | function BunkerSiloPlaceable:delete() |
33 | for _, bunkerSilo in ipairs(self.bunkerSilos) do |
34 | bunkerSilo:delete() |
35 | end |
36 | |
37 | unregisterObjectClassName(self) |
38 | BunkerSiloPlaceable:superClass().delete(self) |
39 | end |
finalizePlacement
DescriptionCalled if placeable is placedDefinition
finalizePlacement()Code
85 | function BunkerSiloPlaceable:finalizePlacement() |
86 | BunkerSiloPlaceable:superClass().finalizePlacement(self) |
87 | |
88 | for _, bunkerSilo in ipairs(self.bunkerSilos) do |
89 | bunkerSilo:register(true) |
90 | end |
91 | end |
load
DescriptionLoad siloDefinition
load(string xmlFilename, float x, float y, float z, float rx, float ry, float rz, boolean initRandom)Arguments
string | xmlFilename | xml file name |
float | x | x world position |
float | y | z world position |
float | z | z world position |
float | rx | rx world rotation |
float | ry | ry world rotation |
float | rz | rz world rotation |
boolean | initRandom | initialize random |
boolean | success | success |
52 | function BunkerSiloPlaceable:load(xmlFilename, x,y,z, rx,ry,rz, initRandom) |
53 | if not BunkerSiloPlaceable:superClass().load(self, xmlFilename, x,y,z, rx,ry,rz, initRandom) then |
54 | return false |
55 | end |
56 | |
57 | local xmlFile = loadXMLFile("TempXML", xmlFilename) |
58 | |
59 | self.bunkerSilos = {} |
60 | |
61 | local i = 0 |
62 | while true do |
63 | local bunkerKey = string.format("placeable.bunkerSilos.bunkerSilo(%d)", i) |
64 | if not hasXMLProperty(xmlFile, bunkerKey) then |
65 | break |
66 | end |
67 | |
68 | local bunkerSilo = BunkerSilo:new(self.isServer, self.isClient) |
69 | if bunkerSilo:load(self.nodeId, xmlFile, bunkerKey) then |
70 | table.insert(self.bunkerSilos, bunkerSilo) |
71 | else |
72 | bunkerSilo:delete() |
73 | end |
74 | |
75 | i = i + 1 |
76 | end |
77 | |
78 | delete(xmlFile) |
79 | |
80 | return true |
81 | 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 |
154 | function BunkerSiloPlaceable:loadFromXMLFile(xmlFile, key, resetVehicles) |
155 | if not BunkerSiloPlaceable:superClass().loadFromXMLFile(self, xmlFile, key, resetVehicles) then |
156 | return false |
157 | end |
158 | |
159 | local i = 0 |
160 | while true do |
161 | local bunkerKey = string.format("%s.bunkerSilo(%d)", key, i) |
162 | if not hasXMLProperty(xmlFile, bunkerKey) then |
163 | break |
164 | end |
165 | |
166 | local index = getXMLInt(xmlFile, bunkerKey.."#index") |
167 | |
168 | if index ~= nil then |
169 | if self.bunkerSilos[index] ~= nil then |
170 | if not self.bunkerSilos[index]:loadFromXMLFile(xmlFile, bunkerKey) then |
171 | return false |
172 | end |
173 | else |
174 | g_logManager:warning("Could not load bunkersilo. Given 'index' '%d' is not defined!", index) |
175 | end |
176 | end |
177 | |
178 | i = i + 1 |
179 | end |
180 | |
181 | return true |
182 | end |
new
DescriptionCreating placeable siloDefinition
new(boolean isServer, boolean isClient, table customMt)Arguments
boolean | isServer | is server |
boolean | isClient | is client |
table | customMt | custom metatable |
table | instance | Instance of object |
22 | function BunkerSiloPlaceable:new(isServer, isClient, customMt) |
23 | local self = Placeable:new(isServer, isClient, customMt or BgaPlaceable_mt) |
24 | |
25 | registerObjectClassName(self, "BunkerSiloPlaceable") |
26 | |
27 | return self |
28 | end |
readStream
DescriptionCalled on client side on joinDefinition
readStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
105 | function BunkerSiloPlaceable:readStream(streamId, connection) |
106 | BunkerSiloPlaceable:superClass().readStream(self, streamId, connection) |
107 | if connection:getIsServer() then |
108 | for _, bunkerSilo in ipairs(self.bunkerSilos) do |
109 | local bunkerSiloId = NetworkUtil.readNodeObjectId(streamId) |
110 | bunkerSilo:readStream(streamId, connection) |
111 | g_client:finishRegisterObject(bunkerSilo, bunkerSiloId) |
112 | end |
113 | end |
114 | end |
saveToXMLFile
DescriptionGet save attributes and nodesDefinition
saveToXMLFile(string nodeIdent)Arguments
string | nodeIdent | node ident |
string | attributes | attributes |
string | nodes | nodes |
189 | function BunkerSiloPlaceable:saveToXMLFile(xmlFile, key, usedModNames) |
190 | BunkerSiloPlaceable:superClass().saveToXMLFile(self, xmlFile, key, usedModNames) |
191 | |
192 | for k, bunkerSilo in ipairs(self.bunkerSilos) do |
193 | local bunkerKey = string.format("%s.bunkerSilo(%d)", key, k-1) |
194 | setXMLInt(xmlFile, bunkerKey .. "#index", k) |
195 | bunkerSilo:saveToXMLFile(xmlFile, bunkerKey, usedModNames) |
196 | end |
197 | end |
writeStream
DescriptionCalled on server side on joinDefinition
writeStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
120 | function BunkerSiloPlaceable:writeStream(streamId, connection) |
121 | BunkerSiloPlaceable:superClass().writeStream(self, streamId, connection) |
122 | if not connection:getIsServer() then |
123 | for _, bunkerSilo in ipairs(self.bunkerSilos) do |
124 | NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(bunkerSilo)) |
125 | bunkerSilo:writeStream(streamId, connection) |
126 | g_server:registerObjectInStream(connection, bunkerSilo) |
127 | end |
128 | end |
129 | end |