Script Dokumentation LS 2015 - FillablePalletSellTrigger (Patch 1.3)
scripts/triggers/FillablePalletSellTrigger.lua
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1 | -- FillablePalletSellTrigger class |
2 | -- |
3 | -- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved. |
4 | |
5 | FillablePalletSellTrigger = {} |
6 | |
7 | local FillablePalletSellTrigger_mt = Class(FillablePalletSellTrigger); |
8 | |
9 | function FillablePalletSellTrigger:onCreate(id) |
10 | g_currentMission:addNonUpdateable(FillablePalletSellTrigger:new(id)); |
11 | end |
12 | |
13 | function FillablePalletSellTrigger:new(nodeId) |
14 | local self = {}; |
15 | setmetatable(self, FillablePalletSellTrigger_mt); |
16 | |
17 | self.triggerId = nodeId; |
18 | addTrigger(nodeId, "triggerCallback", self); |
19 | |
20 | return self; |
21 | end |
22 | |
23 | function FillablePalletSellTrigger:delete() |
24 | removeTrigger(self.triggerId); |
25 | end |
26 | |
27 | function FillablePalletSellTrigger:triggerCallback(triggerId, otherActorId, onEnter, onLeave, onStay, otherShapeId) |
28 | if onEnter then |
29 | -- this happens if a compound child of a deleted compound is entering |
30 | if otherActorId ~= 0 then |
31 | local object = g_currentMission:getNodeObject(otherActorId); |
32 | if object ~= nil then |
33 | if object:isa(FillablePallet) then |
34 | playSample(g_currentMission.cashRegistrySound, 1, 1, 0); |
35 | |
36 | if g_currentMission:getIsServer() then |
37 | local difficultyMultiplier = 2 ^ (3 - g_currentMission.missionStats.difficulty); |
38 | local baseValue = object:getValue(); |
39 | g_currentMission:addSharedMoney(baseValue * difficultyMultiplier, "other"); |
40 | g_currentMission:addMoneyChange(baseValue * difficultyMultiplier, FSBaseMission.MONEY_TYPE_SINGLE, true); |
41 | object:delete(); |
42 | end |
43 | |
44 | end |
45 | end |
46 | end |
47 | end |
48 | |
49 | end
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de