Script Dokumentation LS 2015 - Nightlight (Patch 1.3)
scripts/objects/Nightlight.lua
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1 | -- Nightlight class |
2 | -- |
3 | -- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved. |
4 | |
5 | Nightlight = {} |
6 | |
7 | local Nightlight_mt = Class(Nightlight); |
8 | |
9 | function Nightlight:onCreate(id) |
10 | g_currentMission:addNonUpdateable(Nightlight:new(id)); |
11 | end; |
12 | |
13 | function Nightlight:new(name) |
14 | local instance = {}; |
15 | setmetatable(instance, Nightlight_mt); |
16 | |
17 | instance.init = false; |
18 | if getNumOfChildren(name) == 2 then |
19 | instance.dayId = getChildAt(name, 0); |
20 | instance.nightId = getChildAt(name, 1); |
21 | instance.init = true; |
22 | end; |
23 | |
24 | g_currentMission.environment:addWeatherChangeListener(instance); |
25 | |
26 | return instance; |
27 | end; |
28 | |
29 | function Nightlight:delete() |
30 | if g_currentMission.environment ~= nil then |
31 | g_currentMission.environment:removeWeatherChangeListener(self); |
32 | end; |
33 | end; |
34 | |
35 | function Nightlight:weatherChanged() |
36 | if self.init then |
37 | setVisibility(self.dayId, g_currentMission.environment.isSunOn); |
38 | setVisibility(self.nightId, not g_currentMission.environment.isSunOn); |
39 | end; |
40 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de