Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- AIConveyorBelt
- AIDrivable
- AIFieldWorker
- AIImplement
- AIJobVehicle
- AIVehicle
- AIVehicleObstacle
- AnimatedVehicle
- ArticulatedAxis
- Attachable
- AttacherJointControl
- AttacherJoints
- AutoLoader
- BaleGrab
- BaleLoader
- Baler
- BaleWrapper
- BaseMaterial
- BigBag
- BunkerSiloCompacter
- BunkerSiloInteractor
- CCTDrivable
- Combine
- ConnectionHoses
- ConveyorBelt
- Cover
- CrabSteering
- Crawlers
- CropSensor
- Cultivator
- Cutter
- Cylindered
- CylinderedFoldable
- Dashboard
- Dischargeable
- Drivable
- DynamicallyLoadedParts
- DynamicMountAttacher
- Enterable
- ExtendedAIVehicle
- ExtendedCombine
- ExtendedMotorized
- ExtendedMower
- ExtendedSowingMachine
- ExtendedSprayer
- ExtendedWearable
- FertilizingCultivator
- FertilizingSowingMachine
- FillTriggerVehicle
- FillUnit
- FillVolume
- Foldable
- FoliageBending
- ForageWagon
- FrontloaderAttacher
- FruitPreparer
- GroundAdjustedNodes
- GroundReference
- HeadlandAnimation
- Honk
- HookLiftContainer
- HookLiftTrailer
- IKChains
- InlineWrapper
- JigglingParts
- Leveler
- LicensePlates
- Lights
- LivestockTrailer
- Locomotive
- LogGrab
- ManureBarrel
- ManureSensor
- MixerWagon
- Motorized
- Mountable
- Mower
- Mulcher
- MultipleItemPurchase
- Pallet
- Pickup
- Pipe
- PlaceableAI
- PlaceableAnimatedObjects
- PlaceableBeehive
- PlaceableBeehivePalletSpa...
- PlaceableBunkerSilo
- PlaceableBuyingStation
- PlaceableCartridgePlayer
- PlaceableChargingStation
- PlaceableClearAreas
- PlaceableColorable
- PlaceableDeletedNodes
- PlaceableDoghouse
- PlaceableDynamicallyLoade...
- PlaceableFarmhouse
- PlaceableFence
- PlaceableFoliageAreas
- PlaceableGreenhouse
- PlaceableHighPressureWash...
- PlaceableHotspots
- PlaceableHusbandry
- PlaceableHusbandryAnimals
- PlaceableHusbandryFeeding...
- PlaceableHusbandryFence
- PlaceableHusbandryFood
- PlaceableHusbandryLiquidM...
- PlaceableHusbandryMilk
- PlaceableHusbandryPallets
- PlaceableHusbandryStraw
- PlaceableHusbandryWater
- PlaceableIncomePerHour
- PlaceableIndoorAreas
- PlaceableInfoTrigger
- PlaceableLeveling
- PlaceableLights
- PlaceableManureHeap
- PlaceablePlacement
- PlaceableProductionPoint
- PlaceableSellingStation
- PlaceableSilo
- PlaceableSiloExtension
- PlaceableSolarPanels
- PlaceableTipOcclusionArea...
- PlaceableTrainSystem
- PlaceableTriggerMarkers
- PlaceableVine
- PlaceableWardrobe
- PlaceableWeatherStation
- PlaceableWeighingStation
- PlaceableWindTurbine
- PlaceableWorkshop
- Plow
- PlowPacker
- PowerConsumer
- PowerTakeOffs
- PrecisionFarmingStatistic
- PushHandTool
- RandomlyMovingParts
- ReceivingHopper
- ReverseDriving
- Rideable
- RidgeMarker
- Roller
- Ropes
- RTKStation
- SaltSpreader
- SemiTrailerFront
- Shovel
- SlopeCompensation
- SmartAttach
- SoilSampler
- SowingMachine
- SpeedRotatingParts
- SplineVehicle
- Sprayer
- StonePicker
- StrawBlower
- StumpCutter
- SupportVehicle
- Suspensions
- Tedder
- TensionBeltObject
- TensionBelts
- TestAreas
- TipOccluder
- Trailer
- TreePlanter
- TreeSaplingPallet
- TreeSaw
- TurnOnVehicle
- VariableWorkWidth
- VehicleSettings
- VineCutter
- VineDetector
- VinePrepruner
- Washable
- WaterTrailer
- Wearable
- Weeder
- WeedSpotSpray
- Wheels
- WindBending
- Windrower
- Wipers
- WoodCrusher
- WoodHarvester
- WorkArea
- WorkMode
- WorkParticles
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
Honk
DescriptionSpecialization adding honk/horn functionality to a vehicleFunctions
- actionEventHonk
- getIsHonkAvailable
- initSpecialization
- onDelete
- onLeaveVehicle
- onLoad
- onRegisterActionEvents
- onUpdate
- playHonk
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- setHonkInput
actionEventHonk
DescriptionDefinitionactionEventHonk()Code
147 | function Honk.actionEventHonk(self, actionName, inputValue, callbackState, isAnalog) |
148 | self:setHonkInput() |
149 | end |
getIsHonkAvailable
DescriptionDefinitiongetIsHonkAvailable()Code
97 | function Honk:getIsHonkAvailable() |
98 | return true |
99 | end |
initSpecialization
DescriptionCalled on specialization initializingDefinition
initSpecialization()Code
23 | function Honk.initSpecialization() |
24 | local schema = Vehicle.xmlSchema |
25 | schema:setXMLSpecializationType("Honk") |
26 | SoundManager.registerSampleXMLPaths(schema, "vehicle.honk", "sound") |
27 | schema:setXMLSpecializationType() |
28 | end |
onDelete
DescriptionCalled on deletingDefinition
onDelete()Code
66 | function Honk:onDelete() |
67 | local spec = self.spec_honk |
68 | g_soundManager:deleteSample(spec.sample) |
69 | end |
onLeaveVehicle
DescriptionCalled on leaving the vehicleDefinition
onLeaveVehicle()Code
91 | function Honk:onLeaveVehicle() |
92 | self:playHonk(false, true) |
93 | end |
onLoad
DescriptionDefinitiononLoad()Code
50 | function Honk:onLoad(savegame) |
51 | local spec = self.spec_honk |
52 | |
53 | spec.inputPressed = false |
54 | spec.isPlaying = false |
55 | if self.isClient then |
56 | spec.sample = g_soundManager:loadSampleFromXML(self.xmlFile, "vehicle.honk", "sound", self.baseDirectory, self.components, 0, AudioGroup.VEHICLE, self.i3dMappings, self) |
57 | end |
58 | |
59 | if not self.isClient then |
60 | SpecializationUtil.removeEventListener(self, "onUpdate", Honk) |
61 | end |
62 | end |
onRegisterActionEvents
DescriptionDefinitiononRegisterActionEvents()Code
131 | function Honk:onRegisterActionEvents(isActiveForInput, isActiveForInputIgnoreSelection) |
132 | if self.isClient then |
133 | local spec = self.spec_honk |
134 | self:clearActionEventsTable(spec.actionEvents) |
135 | |
136 | if isActiveForInputIgnoreSelection and spec.sample ~= nil then |
137 | local _, actionEventId = self:addActionEvent(spec.actionEvents, InputAction.HONK, self, Honk.actionEventHonk, false, true, true, true, nil) |
138 | g_inputBinding:setActionEventTextPriority(actionEventId, GS_PRIO_VERY_LOW) |
139 | g_inputBinding:setActionEventActive(actionEventId, true) |
140 | g_inputBinding:setActionEventText(actionEventId, g_i18n:getText("action_honk")) |
141 | end |
142 | end |
143 | end |
onUpdate
DescriptionDefinitiononUpdate()Code
73 | function Honk:onUpdate(dt, isActiveForInput, isActiveForInputIgnoreSelection, isSelected) |
74 | if self.isClient and isActiveForInputIgnoreSelection then |
75 | local spec = self.spec_honk |
76 | if spec.inputPressed then |
77 | if not g_soundManager:getIsSamplePlaying(spec.sample) then |
78 | self:playHonk(true) |
79 | end |
80 | else |
81 | if spec.isPlaying then |
82 | self:playHonk(false) |
83 | end |
84 | end |
85 | spec.inputPressed = false |
86 | end |
87 | end |
playHonk
DescriptionDefinitionplayHonk()Code
110 | function Honk:playHonk(isPlaying, noEventSend) |
111 | HonkEvent.sendEvent(self, isPlaying, noEventSend) |
112 | local spec = self.spec_honk |
113 | |
114 | spec.isPlaying = isPlaying |
115 | if spec.sample ~= nil then |
116 | |
117 | if isPlaying then |
118 | if self:getIsActive() then |
119 | if self.isClient then |
120 | g_soundManager:playSample(spec.sample) |
121 | end |
122 | end |
123 | else |
124 | g_soundManager:stopSample(spec.sample) |
125 | end |
126 | end |
127 | end |
prerequisitesPresent
DescriptionDefinitionprerequisitesPresent()Code
17 | function Honk.prerequisitesPresent(specializations) |
18 | return SpecializationUtil.hasSpecialization(Drivable, specializations) |
19 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
40 | function Honk.registerEventListeners(vehicleType) |
41 | SpecializationUtil.registerEventListener(vehicleType, "onLoad", Honk) |
42 | SpecializationUtil.registerEventListener(vehicleType, "onDelete", Honk) |
43 | SpecializationUtil.registerEventListener(vehicleType, "onUpdate", Honk) |
44 | SpecializationUtil.registerEventListener(vehicleType, "onLeaveVehicle", Honk) |
45 | SpecializationUtil.registerEventListener(vehicleType, "onRegisterActionEvents", Honk) |
46 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
32 | function Honk.registerFunctions(vehicleType) |
33 | SpecializationUtil.registerFunction(vehicleType, "getIsHonkAvailable", Honk.getIsHonkAvailable) |
34 | SpecializationUtil.registerFunction(vehicleType, "setHonkInput", Honk.setHonkInput) |
35 | SpecializationUtil.registerFunction(vehicleType, "playHonk", Honk.playHonk) |
36 | end |
setHonkInput
DescriptionDefinitionsetHonkInput()Code
103 | function Honk:setHonkInput() |
104 | local spec = self.spec_honk |
105 | spec.inputPressed = true |
106 | end |