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
SiloExtensionPlaceable
ParentPlaceableFunctions
- finalizePlacement
- getSpecValueVolume
- load
- loadFromXMLFile
- loadSpecValueVolume
- readStream
- saveToXMLFile
- writeStream
finalizePlacement
DescriptionCalled if placeable is placedDefinition
finalizePlacement()Code
80 | function SiloExtensionPlaceable:finalizePlacement() |
81 | SiloExtensionPlaceable:superClass().finalizePlacement(self) |
82 | |
83 | local storageSystem = g_currentMission.storageSystem |
84 | local ownerFarmId = self:getOwnerFarmId() |
85 | local lastFoundUnloadingStations = storageSystem:getUnloadingStationsInRange(nil, self.storage, ownerFarmId) |
86 | local lastFoundLoadingStations = storageSystem:getLoadingStationsInRange(nil, self.storage, ownerFarmId) |
87 | |
88 | self.storage:setOwnerFarmId(self:getOwnerFarmId(), true) |
89 | storageSystem:addStorage(self.storage) |
90 | self.storage:register(true) |
91 | |
92 | storageSystem:addStorageToUnloadingStations(self.storage, lastFoundUnloadingStations) |
93 | storageSystem:addStorageToLoadingStations(self.storage, lastFoundLoadingStations) |
94 | end |
getSpecValueVolume
DescriptionReturns value of income per hourDefinition
getSpecValueVolume(table storeItem, table realItem)Arguments
table | storeItem | store item |
table | realItem | real item |
integer | incomePerHour | income per hour |
253 | function SiloExtensionPlaceable.getSpecValueVolume(storeItem, realItem) |
254 | if storeItem.specs.siloExtensionVolume == nil then |
255 | return nil |
256 | end |
257 | |
258 | return g_i18n:formatVolume(storeItem.specs.siloExtensionVolume) |
259 | end |
load
DescriptionLoad silo extensionDefinition
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 |
50 | function SiloExtensionPlaceable:load(xmlFilename, x,y,z, rx,ry,rz, initRandom) |
51 | if not SiloExtensionPlaceable:superClass().load(self, xmlFilename, x,y,z, rx,ry,rz, initRandom) then |
52 | return false |
53 | end |
54 | |
55 | local xmlFile = loadXMLFile("TempXML", xmlFilename) |
56 | local storageKey = "placeable.storage" |
57 | |
58 | self.foreignSilo = Utils.getNoNil(getXMLBool(xmlFile, storageKey.."#foreignSilo"), false) -- Shows as foreign silo in the menu |
59 | |
60 | if hasXMLProperty(xmlFile, storageKey) then |
61 | local storageNode = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, storageKey.."#node")) |
62 | if storageNode ~= nil then |
63 | self.storage = Storage:new(self.isServer, self.isClient) |
64 | self.storage:load(storageNode, xmlFile, storageKey) |
65 | self.storage.foreignSilo = self.foreignSilo |
66 | else |
67 | g_logManager:xmlWarning(xmlFilename, "Missing 'node' for storage '%s'!", storageKey) |
68 | end |
69 | else |
70 | g_logManager:xmlWarning(xmlFilename, "Missing 'storage' for siloExtension '%s'!", xmlFilename) |
71 | end |
72 | |
73 | delete(xmlFile) |
74 | |
75 | return true |
76 | 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 |
136 | function SiloExtensionPlaceable:loadFromXMLFile(xmlFile, key, resetVehicles) |
137 | if not SiloExtensionPlaceable:superClass().loadFromXMLFile(self, xmlFile, key, resetVehicles) then |
138 | return false |
139 | end |
140 | |
141 | if not self.storage:loadFromXMLFile(xmlFile, key..".storage") then |
142 | return false |
143 | end |
144 | |
145 | return true |
146 | end |
loadSpecValueVolume
DescriptionLoads capacity spec valueDefinition
loadSpecValueVolume(integer xmlFile, string customEnvironment)Arguments
integer | xmlFile | id of xml object |
string | customEnvironment | custom environment |
table | capacityAndUnit | capacity and unit |
244 | function SiloExtensionPlaceable.loadSpecValueVolume(xmlFile, customEnvironment) |
245 | return getXMLInt(xmlFile, "placeable.storage#capacityPerFillType") |
246 | end |
readStream
DescriptionCalled on client side on joinDefinition
readStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
100 | function SiloExtensionPlaceable:readStream(streamId, connection) |
101 | SiloExtensionPlaceable:superClass().readStream(self, streamId, connection) |
102 | if connection:getIsServer() then |
103 | local storageId = NetworkUtil.readNodeObjectId(streamId) |
104 | self.storage:readStream(streamId, connection) |
105 | g_client:finishRegisterObject(self.storage, storageId) |
106 | end |
107 | end |
saveToXMLFile
DescriptionGet save attributes and nodesDefinition
saveToXMLFile(string nodeIdent)Arguments
string | nodeIdent | node ident |
string | attributes | attributes |
string | nodes | nodes |
153 | function SiloExtensionPlaceable:saveToXMLFile(xmlFile, key, usedModNames) |
154 | SiloExtensionPlaceable:superClass().saveToXMLFile(self, xmlFile, key, usedModNames) |
155 | |
156 | self.storage:saveToXMLFile(xmlFile, key..".storage", usedModNames) |
157 | end |
writeStream
DescriptionCalled on server side on joinDefinition
writeStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
113 | function SiloExtensionPlaceable:writeStream(streamId, connection) |
114 | SiloExtensionPlaceable:superClass().writeStream(self, streamId, connection) |
115 | if not connection:getIsServer() then |
116 | NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(self.storage)) |
117 | self.storage:writeStream(streamId, connection) |
118 | g_server:registerObjectInStream(connection, self.storage) |
119 | end |
120 | end |