Script v1.4.4.0
- Handtools
- Events
- Objects
- Placeables
- Triggers
- BaleDestroyerTrigger
- BasketTrigger
- ConveyorBeltTipTrigger
- FillTrigger
- GasStationTrigger
- LiquidManureFillTrigger
- LoanTrigger
- PickupObjectsSellTrigger
- ReceivingTipTrigger
- ShopTrigger
- SiloTrigger
- TipTrigger
- WaterTrailerFillTrigger
- WeighStation
- WoodSellTrigger
- Utils
- Vehicles
- Specializations
Engine v7.0.0.2
- General
- Entity
- Node
- Scenegraph
- Lighting
- Camera
- Shape
- Particle System
- Physics
- Spline
- Animation
- Overlays
- Sound
- Input
- XML
- Network
- Callbacks
- Text Rendering
- Terrain Detail
- Tire Track
- Editor
- Rendering
- String
- Math
- I3D
- Fillplanes
Foundation Reference
BaleDestroyerTrigger
DescriptionClass for bale destroy triggersFunctions
onCreate
DescriptiononCreate triggerDefinition
onCreate(integer id)Arguments
integer | id | id of trigger node |
15 | function BaleDestroyerTrigger:onCreate(id) |
16 | g_currentMission:addNonUpdateable(BaleDestroyerTrigger:new(id)); |
17 | end; |
new
DescriptionCreate bale destroyer trigger objectDefinition
new(integer id)Arguments
integer | id | id of trigger node |
table | instance | instance of destroyer trigger |
23 | function BaleDestroyerTrigger:new(id) |
24 | local self = {}; |
25 | setmetatable(self, BaleDestroyerTrigger_mt); |
26 | |
27 | self.triggerId = id; |
28 | addTrigger(id, "triggerCallback", self); |
29 | |
30 | self.isBaleDestroyerTrigger = true; |
31 | self.isEnabled = true; |
32 | |
33 | self.appearsOnPDA = Utils.getNoNil(getUserAttribute(id, "appearsOnPDA"), true) |
34 | if self.appearsOnPDA then |
35 | local mapPosition = id |
36 | local mapPositionIndex = getUserAttribute(id, "mapPositionIndex") |
37 | if mapPositionIndex ~= nil then |
38 | mapPosition = Utils.indexToObject(id, mapPositionIndex) |
39 | if mapPosition == nil then |
40 | mapPosition = id |
41 | end |
42 | end |
43 | |
44 | local x, _, z = getWorldTranslation(mapPosition) |
45 | self.mapHotspot = g_currentMission.ingameMap:createMapHotspot("baleSellTrigger", "", nil, getNormalizedUVs({8, 520, 240, 240}), {1,1,1,1}, x, z, nil, nil, false, false, false, 0, nil, MapHotspot.CATEGORY_TRIGGER) |
46 | end |
47 | |
48 | return self; |
49 | end; |
delete
DescriptionDeleting destroyer triggerDefinition
delete()Code
53 | function BaleDestroyerTrigger:delete() |
54 | removeTrigger(self.triggerId); |
55 | |
56 | if self.mapHotspot ~= nil then |
57 | g_currentMission.ingameMap:deleteMapHotspot(self.mapHotspot) |
58 | end |
59 | end; |
triggerCallback
DescriptionTrigger callbackDefinition
triggerCallback(integer triggerId, integer otherId, boolean onEnter, boolean onLeave, boolean onStay, integer otherShapeId)Arguments
integer | triggerId | id of trigger |
integer | otherId | id of actor |
boolean | onEnter | on enter |
boolean | onLeave | on leave |
boolean | onStay | on stay |
integer | otherShapeId | id of other actor |
69 | function BaleDestroyerTrigger:triggerCallback(triggerId, otherActorId, onEnter, onLeave, onStay, otherShapeId) |
70 | if self.isEnabled then |
71 | if onEnter then |
72 | -- this happens if a compound child of a deleted compound is entering |
73 | if otherActorId ~= 0 then |
74 | local object = g_currentMission:getNodeObject(otherActorId); |
75 | if object ~= nil then |
76 | if object:isa(Bale) and object:getCanBeSold() then |
77 | playSample(g_currentMission.cashRegistrySound, 1, 1, 0); |
78 | -- TODO: display a particle effect |
79 | |
80 | if g_currentMission:getIsServer() then |
81 | -- print("Bale stored: ", tostring(otherActorId)); |
82 | local difficultyMultiplier = g_currentMission.missionInfo.sellPriceMultiplier; |
83 | local baseValue = object:getValue(); |
84 | g_currentMission:addSharedMoney(baseValue * difficultyMultiplier, "soldBales"); |
85 | g_currentMission:addMoneyChange(baseValue * difficultyMultiplier, FSBaseMission.MONEY_TYPE_SINGLE, true, g_i18n:getText("finance_soldBales")); |
86 | object:delete(); |
87 | end; |
88 | |
89 | end; |
90 | else |
91 | if g_currentMission.nodeToVehicle[otherActorId] == nil then |
92 | -- there is nothing that could end up here, since physics objects are an object, thus this could only introduce bugs |
93 | -- delete(otherActorId); |
94 | end; |
95 | end; |
96 | end; |
97 | end; |
98 | end |
99 | end; |