Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- 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
WeatherTypeManager
DescriptionThis class handles all weather typesParent
AbstractManagerFunctions
- addWeatherType
- getWeatherTypeByIndex
- getWeatherTypeByName
- getWeatherTypeIndexByName
- getWeatherTypeNameByIndex
- getWeatherTypes
- initDataStructures
- loadDefaultTypes
- new
addWeatherType
DescriptionAdds a new weather typeDefinition
addWeatherType(string name)Arguments
string | name | weather type name |
table | brandColor | brandColor object |
45 | function WeatherTypeManager:addWeatherType(name) |
46 | if not ClassUtil.getIsValidIndexName(name) then |
47 | print("Warning: '"..tostring(name).."' is not a valid name for a weather type. Ignoring it!") |
48 | return nil |
49 | end |
50 | |
51 | name = name:upper() |
52 | |
53 | local weatherType = {} |
54 | weatherType.index = #self.weatherTypes + 1 |
55 | weatherType.name = name |
56 | |
57 | table.insert(self.weatherTypes, weatherType) |
58 | self.nameToIndex[name] = weatherType.index |
59 | self.indexToName[weatherType.index] = name |
60 | |
61 | return weatherType |
62 | end |
getWeatherTypeByIndex
DescriptionDefinitiongetWeatherTypeByIndex()Code
98 | function WeatherTypeManager:getWeatherTypeByIndex(index) |
99 | if index ~= nil then |
100 | return self.weatherTypes[index] |
101 | end |
102 | return nil |
103 | end |
getWeatherTypeByName
DescriptionDefinitiongetWeatherTypeByName()Code
84 | function WeatherTypeManager:getWeatherTypeByName(name) |
85 | if name ~= nil then |
86 | if ClassUtil.getIsValidIndexName(name) then |
87 | local index = self.nameToIndex[name] |
88 | if index ~= nil then |
89 | return self.weatherTypes[index] |
90 | end |
91 | end |
92 | end |
93 | return nil |
94 | end |
getWeatherTypeIndexByName
DescriptionDefinitiongetWeatherTypeIndexByName()Code
72 | function WeatherTypeManager:getWeatherTypeIndexByName(name) |
73 | if name ~= nil then |
74 | if ClassUtil.getIsValidIndexName(name) then |
75 | name = name:upper() |
76 | return self.nameToIndex[name] |
77 | end |
78 | end |
79 | return nil |
80 | end |
getWeatherTypeNameByIndex
DescriptionDefinitiongetWeatherTypeNameByIndex()Code
107 | function WeatherTypeManager:getWeatherTypeNameByIndex(index) |
108 | if index ~= nil then |
109 | return self.indexToName[index] |
110 | end |
111 | return nil |
112 | end |
getWeatherTypes
DescriptionDefinitiongetWeatherTypes()Code
66 | function WeatherTypeManager:getWeatherTypes() |
67 | return self.weatherTypes |
68 | end |
initDataStructures
DescriptionInitialize data structuresDefinition
initDataStructures()Code
24 | function WeatherTypeManager:initDataStructures() |
25 | self.weatherTypes = {} |
26 | self.nameToIndex = {} |
27 | self.indexToName = {} |
28 | self:loadDefaultTypes() |
29 | |
30 | WeatherType = self.nameToIndex |
31 | end |
loadDefaultTypes
DescriptionDefinitionloadDefaultTypes()Code
35 | function WeatherTypeManager:loadDefaultTypes() |
36 | self:addWeatherType("SUN") |
37 | self:addWeatherType("CLOUDY") |
38 | self:addWeatherType("RAIN") |
39 | end |
new
DescriptionCreating managerDefinition
new()Return Values
table | instance | instance of object |
18 | function WeatherTypeManager:new(customMt) |
19 | return AbstractManager:new(customMt or WeatherTypeManager_mt) |
20 | end |