Sprache Deutsch Language English

Script Dokumentation LS 2015 - HotspotTrigger (Patch 1.3)

Script Dokumentation Übersicht

scripts/triggers/HotspotTrigger.lua

Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1-- HotspotTrigger class
2--
3-- HotspotTriggers consist of a trigger object and two rings (which are children of the trigger object) that rotate around their y axis at different speeds
4--
5-- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved.
6
7HotspotTrigger = {}
8
9local HotspotTrigger_mt = Class(HotspotTrigger);
10
11function HotspotTrigger:onCreate(id)
12 g_currentMission:addUpdateable(HotspotTrigger:new(id));
13 --print("Created HotspotTrigger, id: ", id);
14end;
15
16function HotspotTrigger:new(name)
17 local instance = {};
18 setmetatable(instance, HotspotTrigger_mt);
19
20 instance.triggerId = name;
21 addTrigger(name, "triggerCallback", instance);
22
23 instance.hotspotSymbol = getChildAt(name, 0);
24
25 local x, y, z = getTranslation(name);
26
27 -- put yourself on the pda map
28 instance.mapHotspot = g_currentMission.ingameMap:createMapHotspot(tostring(name), "dataS2/menu/hud/hud_pda_spot_yellow.png", x, z, g_currentMission.ingameMap.mapArrowWidth / 3, g_currentMission.ingameMap.mapArrowHeight / 3, false, true, false, 0);
29
30 instance.distanceToPlayer = 0;
31
32 instance.isEnabled = true;
33
34 return instance;
35end;
36
37function HotspotTrigger:delete()
38 removeTrigger(self.triggerId);
39 --print("HOTSPOT TRIGGER REMOVED: ", self.triggerId);
40end;
41
42function HotspotTrigger:update(dt)
43 rotate(self.hotspotSymbol, 0, 0.005 * dt, 0);
44end;
45
46function HotspotTrigger:triggerCallback(triggerId, otherId, onEnter, onLeave, onStay)
47 if onEnter and self.isEnabled and g_currentMission.controlledVehicle ~= nil then
48 if otherId == g_currentMission.controlledVehicle.components[1].node then -- only react if player enters while driving a vehicle
49 -- play trigger sound
50 if g_currentMission.hotspotSound ~= nil then
51 playSample(g_currentMission.hotspotSound, 1, 1, 0);
52 end;
53
54 -- tell the mission you've been triggered
55 g_currentMission:hotspotTouched(triggerId);
56
57 self.mapHotspot.visible = false;
58 self.mapHotspot.enabled = false;
59
60 self.isEnabled = false;
61 setVisibility(self.triggerId, false);
62 end;
63 end;
64end;
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
Script Dokumentation Übersicht