Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- AnimatedMapObject
- AnimatedObject
- AnimatedObjectEvent
- Bale
- Basketball
- Bga
- BgaSellStation
- BunkerSilo
- BuyingStation
- DigitalDisplay
- DogBall
- HelpIcons
- LoadingStation
- NightIllumination
- Nightlight2
- NightlightFlicker
- PhysicsObject
- Rotator
- SellingStation
- SimParticleSystem
- Storage
- StorageSystem
- SunAdmirer
- TourIcons
- UnloadingStation
- VehicleSellingPoint
- WildlifeSpawner
- Placeables
- 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
StorageSystem
Functions- addLoadingStation
- addStorage
- addStorageToLoadingStations
- addStorageToUnloadingStations
- addUnloadingStation
- getIsStationCompatible
- getLoadingStations
- getLoadingStationsInRange
- getStorages
- getStoragesInRange
- getUnloadingStations
- getUnloadingStationsInRange
- hasStorage
- new
- removeLoadingStation
- removeStorage
- removeStorageFromLoadingStations
- removeStorageFromUnloadingStations
- removeUnloadingStation
addLoadingStation
DescriptionDefinitionaddLoadingStation()Code
83 | function StorageSystem:addLoadingStation(station) |
84 | if station ~= nil then |
85 | self.loadingStations[station] = station |
86 | return true |
87 | end |
88 | |
89 | return false |
90 | end |
addStorage
DescriptionDefinitionaddStorage()Code
30 | function StorageSystem:addStorage(storage) |
31 | if storage ~= nil then |
32 | self.storages[storage] = storage |
33 | return true |
34 | end |
35 | |
36 | return false |
37 | end |
addStorageToLoadingStations
DescriptionDefinitionaddStorageToLoadingStations()Code
111 | function StorageSystem:addStorageToLoadingStations(storage, loadingStations, farmId) |
112 | local success = false |
113 | for _, loadingStation in pairs(loadingStations) do |
114 | if loadingStation:addSourceStorage(storage) then |
115 | success = true |
116 | end |
117 | end |
118 | |
119 | return success |
120 | end |
addStorageToUnloadingStations
DescriptionDefinitionaddStorageToUnloadingStations()Code
182 | function StorageSystem:addStorageToUnloadingStations(storage, unloadingStations) |
183 | local success = false |
184 | for _, unloadingStation in pairs(unloadingStations) do |
185 | if unloadingStation:addTargetStorage(storage) then |
186 | success = true; |
187 | end |
188 | end |
189 | |
190 | return success |
191 | end |
addUnloadingStation
DescriptionDefinitionaddUnloadingStation()Code
152 | function StorageSystem:addUnloadingStation(station) |
153 | if station ~= nil then |
154 | self.unloadingStations[station] = station |
155 | g_messageCenter:publish(MessageType.UNLOADING_STATIONS_CHANGED) |
156 | return true |
157 | end |
158 | |
159 | return false |
160 | end |
getIsStationCompatible
DescriptionDefinitiongetIsStationCompatible()Code
222 | function StorageSystem:getIsStationCompatible(station, storage, farmId) |
223 | local hasRadius = station.storageRadius ~= nil |
224 | local supportsExtension = station.supportsExtension == nil or station.supportsExtension |
225 | local canAccessTarget = self.accessHandler:canFarmAccess(farmId, station) |
226 | |
227 | if hasRadius and supportsExtension and canAccessTarget then |
228 | local distance = calcDistanceFrom(storage.rootNode, station.rootNode) |
229 | |
230 | if distance < station.storageRadius then |
231 | return true |
232 | end |
233 | end |
234 | |
235 | return false |
236 | end |
getLoadingStations
DescriptionDefinitiongetLoadingStations()Code
105 | function StorageSystem:getLoadingStations() |
106 | return self.loadingStations |
107 | end |
getLoadingStationsInRange
DescriptionDefinitiongetLoadingStationsInRange()Code
137 | function StorageSystem:getLoadingStationsInRange(stations, storage, farmId) |
138 | stations = stations or self.loadingStations |
139 | local stationsInRange = {} |
140 | |
141 | for station, _ in pairs(stations) do |
142 | if self:getIsStationCompatible(station, storage, farmId) and not station.isBuyingPoint then |
143 | table.insert(stationsInRange, station) |
144 | end |
145 | end |
146 | |
147 | return stationsInRange |
148 | end |
getStorages
DescriptionDefinitiongetStorages()Code
62 | function StorageSystem:getStorages() |
63 | return self.storages |
64 | end |
getStoragesInRange
DescriptionDefinitiongetStoragesInRange()Code
68 | function StorageSystem:getStoragesInRange(station, storages, farmId) |
69 | storages = storages or self.storages |
70 | local storagesInRange = {} |
71 | |
72 | for storage, _ in pairs(storages) do |
73 | if self:getIsStationCompatible(station, storage, farmId) then |
74 | table.insert(storagesInRange, storage) |
75 | end |
76 | end |
77 | |
78 | return storagesInRange |
79 | end |
getUnloadingStations
DescriptionDefinitiongetUnloadingStations()Code
176 | function StorageSystem:getUnloadingStations() |
177 | return self.unloadingStations |
178 | end |
getUnloadingStationsInRange
DescriptionDefinitiongetUnloadingStationsInRange()Code
208 | function StorageSystem:getUnloadingStationsInRange(stations, storage, farmId) |
209 | stations = stations or self.unloadingStations |
210 | local stationsInRange = {} |
211 | for station, _ in pairs(stations) do |
212 | if self:getIsStationCompatible(station, storage, farmId) then |
213 | table.insert(stationsInRange, station) |
214 | end |
215 | end |
216 | |
217 | return stationsInRange |
218 | end |
hasStorage
DescriptionDefinitionhasStorage()Code
52 | function StorageSystem:hasStorage(storage) |
53 | if storage ~= nil then |
54 | return self.storages[storage] ~= nil |
55 | end |
56 | |
57 | return false |
58 | end |
new
DescriptionDefinitionnew()Code
17 | function StorageSystem:new(accessHandler, customMt) |
18 | local self = setmetatable({}, customMt or StorageSystem_mt) |
19 | |
20 | self.accessHandler = accessHandler |
21 | self.loadingStations = {} |
22 | self.unloadingStations = {} |
23 | self.storages = {} |
24 | |
25 | return self |
26 | end |
removeLoadingStation
DescriptionDefinitionremoveLoadingStation()Code
94 | function StorageSystem:removeLoadingStation(station) |
95 | if station ~= nil then |
96 | self.loadingStations[station] = nil |
97 | return true |
98 | end |
99 | |
100 | return false |
101 | end |
removeStorage
DescriptionDefinitionremoveStorage()Code
41 | function StorageSystem:removeStorage(storage) |
42 | if storage ~= nil then |
43 | self.storages[storage] = nil |
44 | return true |
45 | end |
46 | |
47 | return false |
48 | end |
removeStorageFromLoadingStations
DescriptionDefinitionremoveStorageFromLoadingStations()Code
124 | function StorageSystem:removeStorageFromLoadingStations(storage, loadingStations) |
125 | local success = false |
126 | for _, loadingStation in pairs(loadingStations) do |
127 | if loadingStation:removeSourceStorage(storage) then |
128 | success = true |
129 | end |
130 | end |
131 | |
132 | return success |
133 | end |
removeStorageFromUnloadingStations
DescriptionDefinitionremoveStorageFromUnloadingStations()Code
195 | function StorageSystem:removeStorageFromUnloadingStations(storage, unloadingStations) |
196 | local success = false |
197 | for _, unloadingStation in pairs(unloadingStations) do |
198 | if unloadingStation:removeTargetStorage(storage) then |
199 | success = true; |
200 | end |
201 | end |
202 | |
203 | return success |
204 | end |
removeUnloadingStation
DescriptionDefinitionremoveUnloadingStation()Code
164 | function StorageSystem:removeUnloadingStation(station) |
165 | if station ~= nil then |
166 | self.unloadingStations[station] = nil |
167 | g_messageCenter:publish(MessageType.UNLOADING_STATIONS_CHANGED) |
168 | return true |
169 | end |
170 | |
171 | return false |
172 | end |