Sprache Deutsch Language English

Script Dokumentation LS 2015 - PickupObjectsSellTrigger (Patch 1.3)

Script Dokumentation Übersicht

scripts/triggers/PickupObjectsSellTrigger.lua

Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1--[[ PickupObjectsSellTrigger class
2
3 Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved.
4--]]
5
6PickupObjectsSellTrigger = {}
7
8local PickupObjectsSellTrigger_mt = Class(PickupObjectsSellTrigger);
9
10function PickupObjectsSellTrigger:onCreate(id)
11 if g_currentMission:getIsServer() then
12 g_currentMission:addNonUpdateable(PickupObjectsSellTrigger:new(id));
13 end
14end
15
16function PickupObjectsSellTrigger:new(id, mt)
17 assert(g_currentMission:getIsServer());
18 if mt == nil then
19 mt = PickupObjectsSellTrigger_mt;
20 end
21 local self = {};
22 setmetatable(self, mt);
23
24 self.triggerId = id;
25 if g_currentMission:getIsServer() then
26 addTrigger(id, "triggerCallback", self);
27 end
28
29 self.eggSymbol = getChildAt(id, 0);
30
31 self.fillType = Fillable.FILLTYPE_EGG;
32 local fillTypeStr = getUserAttribute(id, "fillType");
33 if fillTypeStr ~= nil then
34 local fillTypeInt = Fillable.fillTypeNameToInt[fillTypeStr];
35 if fillTypeInt ~= nil then
36 self.fillType = fillTypeInt;
37 end
38 end
39
40 return self;
41end
42
43function PickupObjectsSellTrigger:delete()
44 if g_currentMission:getIsServer() then
45 removeTrigger(self.triggerId);
46 end
47end
48
49function PickupObjectsSellTrigger:triggerCallback(triggerId, otherActorId, onEnter, onLeave, onStay, otherShapeId)
50 if onEnter then
51 if g_currentMission.players[otherActorId] ~= nil then
52 local numObject = g_currentMission:getSiloAmount(self.fillType);
53 g_currentMission:setSiloAmount(self.fillType, 0);
54 local pricePerLiter = 1;
55 local desc = Fillable.fillTypeIndexToDesc[self.fillType];
56 if desc ~= nil then
57 pricePerLiter = desc.pricePerLiter;
58 end
59 local difficultyMultiplier = 2 ^ (3 - g_currentMission.missionStats.difficulty); -- 4, 2, 1
60 g_currentMission:addSharedMoney(numObject * pricePerLiter * difficultyMultiplier, "other");
61 g_currentMission:addMoneyChange(numObject * pricePerLiter * difficultyMultiplier, FSBaseMission.MONEY_TYPE_SINGLE, true);
62 if numObject > 0 then playSample(g_currentMission.cashRegistrySound, 1, 1, 0); end;
63 end
64 end
65end
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