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
NightIllumination
DescriptionClass for NightIllumination objects which are used for building windows that are illuminated at nightFunctions
delete
DescriptionRemove Object from WeatherChangeListenersDefinition
delete()Code
59 | function NightIllumination:delete() |
60 | if g_currentMission.environment ~= nil then |
61 | g_currentMission.environment:removeWeatherChangeListener(self) |
62 | end |
63 | end |
new
DescriptionCreating NightIllumination objectDefinition
new(integer name)Arguments
integer | name | ID of the node |
table | instance | Instance of object |
25 | function NightIllumination:new(id) |
26 | local self = {} |
27 | setmetatable(self, NightIllumination_mt) |
28 | |
29 | g_currentMission.environment:addWeatherChangeListener(self) |
30 | |
31 | self.id = id |
32 | self.windowsId = 0 |
33 | self.lightsId = 0 |
34 | |
35 | if getNumOfChildren(id) > 0 then |
36 | self.windowsId = getChildAt(id, 0) |
37 | end |
38 | if getNumOfChildren(id) > 1 then |
39 | self.lightsId = getChildAt(id, 1) |
40 | end |
41 | |
42 | self.lightIntensity = Utils.getNoNil(getUserAttribute(self.id, "lightIntensity"), 1.0) |
43 | |
44 | -- set windows to dark (using dashboardLightsShader) |
45 | if self.windowsId ~= 0 then |
46 | setShaderParameter(self.windowsId, "lightControl", 0, 0, 0, 0, false) |
47 | end |
48 | |
49 | -- make lights invisible |
50 | if self.lightsId ~= 0 then |
51 | setVisibility(self.lightsId, false) |
52 | end |
53 | |
54 | return self |
55 | end |
onCreate
DescriptionCreating NightIllumination objectDefinition
onCreate(integer id)Arguments
integer | id | ID of the node |
17 | function NightIllumination:onCreate(id) |
18 | g_currentMission:addNonUpdateable(NightIllumination:new(id)) |
19 | end |
weatherChanged
DescriptionChange illumination of night objectsDefinition
weatherChanged()Code
67 | function NightIllumination:weatherChanged() |
68 | if g_currentMission ~= nil and g_currentMission.environment ~= nil then |
69 | local isLightNeeded = not (g_currentMission.environment.isSunOn and not g_currentMission.environment.weather:getIsRaining()) |
70 | |
71 | if self.windowsId ~= 0 then |
72 | if isLightNeeded then |
73 | setShaderParameter(self.windowsId, "lightControl", self.lightIntensity, 0, 0, 0, false) |
74 | else |
75 | setShaderParameter(self.windowsId, "lightControl", 0, 0, 0, 0, false) |
76 | end |
77 | end |
78 | |
79 | if self.lightsId ~= 0 then |
80 | setVisibility(self.lightsId, isLightNeeded) |
81 | end |
82 | end |
83 | end |