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
PlaceableHotspots
DescriptionSpecialization for placeablesFunctions
- getHotspot
- onDelete
- onLoad
- onOwnerChanged
- onPostFinalizePlacement
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerXMLPaths
getHotspot
DescriptionDefinitiongetHotspot()Code
145 | function PlaceableHotspots:getHotspot(index) |
146 | local spec = self.spec_hotspots |
147 | return spec.mapHotspots[index or 1] |
148 | end |
onDelete
DescriptionDefinitiononDelete()Code
106 | function PlaceableHotspots:onDelete() |
107 | local spec = self.spec_hotspots |
108 | |
109 | g_messageCenter:unsubscribeAll(self) |
110 | if spec.mapHotspots ~= nil then |
111 | for _, hotspot in ipairs(spec.mapHotspots) do |
112 | g_currentMission:removeMapHotspot(hotspot) |
113 | hotspot:delete() |
114 | end |
115 | end |
116 | end |
onLoad
DescriptionCalled on loadingDefinition
onLoad(table savegame)Arguments
table | savegame | savegame |
53 | function PlaceableHotspots:onLoad(savegame) |
54 | local spec = self.spec_hotspots |
55 | |
56 | spec.mapHotspots = {} |
57 | self.xmlFile:iterate("placeable.hotspots.hotspot", function(_, key) |
58 | local hotspot = PlaceableHotspot.new() |
59 | hotspot:setPlaceable(self) |
60 | |
61 | local hotspotTypeName = self.xmlFile:getValue(key .. "#type", "UNLOADING") |
62 | local hotspotType = PlaceableHotspot.getTypeByName(hotspotTypeName) |
63 | if hotspotType == nil then |
64 | Logging.xmlWarning(self.xmlFile, "Unknown placeable hotspot type '%s'. Falling back to type 'UNLOADING'\nAvailable types: %s", hotspotTypeName, table.concatKeys(PlaceableHotspot.TYPE, " ")) |
65 | hotspotType = PlaceableHotspot.TYPE.UNLOADING |
66 | end |
67 | hotspot:setPlaceableType(hotspotType) |
68 | |
69 | local linkNode = self.xmlFile:getValue(key .. "#linkNode", nil, self.components, self.i3dMappings) or self.rootNode |
70 | if linkNode ~= nil then |
71 | local x, _, z = getWorldTranslation(linkNode) |
72 | hotspot:setWorldPosition(x, z) |
73 | end |
74 | |
75 | local teleportNode = self.xmlFile:getValue(key .. "#teleportNode", nil, self.components, self.i3dMappings) |
76 | if teleportNode ~= nil then |
77 | local x, y, z = getWorldTranslation(teleportNode) |
78 | hotspot:setTeleportWorldPosition(x, y, z) |
79 | end |
80 | |
81 | local worldPositionX, worldPositionZ = self.xmlFile:getValue(key .. "#worldPosition", nil) |
82 | if worldPositionX ~= nil then |
83 | hotspot:setWorldPosition(worldPositionX, worldPositionZ) |
84 | end |
85 | |
86 | local teleportX, teleportY, teleportZ = self.xmlFile:getValue(key .. "#teleportWorldPosition", nil) |
87 | if teleportX ~= nil then |
88 | if g_currentMission ~= nil then |
89 | teleportY = math.max(teleportY, getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, teleportX, 0, teleportZ)) |
90 | end |
91 | hotspot:setTeleportWorldPosition(teleportX, teleportY, teleportZ) |
92 | end |
93 | |
94 | local text = self.xmlFile:getValue(key.."#text", nil) |
95 | if text ~= nil then |
96 | text = g_i18n:convertText(text, self.customEnvironment) |
97 | hotspot:setName(text) |
98 | end |
99 | |
100 | table.insert(spec.mapHotspots, hotspot) |
101 | end) |
102 | end |
onOwnerChanged
DescriptionDefinitiononOwnerChanged()Code
133 | function PlaceableHotspots:onOwnerChanged() |
134 | local spec = self.spec_hotspots |
135 | if spec.mapHotspots ~= nil then |
136 | for _, hotspot in ipairs(spec.mapHotspots) do |
137 | hotspot:setOwnerFarmId(self.ownerFarmId) |
138 | hotspot:setVisible(self.ownerFarmId ~= AccessHandler.NOBODY) |
139 | end |
140 | end |
141 | end |
onPostFinalizePlacement
DescriptionDefinitiononPostFinalizePlacement()Code
120 | function PlaceableHotspots:onPostFinalizePlacement() |
121 | local spec = self.spec_hotspots |
122 | |
123 | -- Add now so that the hotspot does not show up during placement |
124 | for _, hotspot in ipairs(spec.mapHotspots) do |
125 | hotspot:setOwnerFarmId(self.ownerFarmId) |
126 | hotspot:setVisible(self.ownerFarmId ~= AccessHandler.NOBODY) |
127 | g_currentMission:addMapHotspot(hotspot) |
128 | end |
129 | end |
prerequisitesPresent
DescriptionChecks if all prerequisite specializations are loadedDefinition
prerequisitesPresent(table specializations)Arguments
table | specializations | specializations |
boolean | hasPrerequisite | true if all prerequisite specializations are loaded |
18 | function PlaceableHotspots.prerequisitesPresent(specializations) |
19 | return true |
20 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
30 | function PlaceableHotspots.registerEventListeners(placeableType) |
31 | SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableHotspots) |
32 | SpecializationUtil.registerEventListener(placeableType, "onDelete", PlaceableHotspots) |
33 | SpecializationUtil.registerEventListener(placeableType, "onPostFinalizePlacement", PlaceableHotspots) |
34 | SpecializationUtil.registerEventListener(placeableType, "onOwnerChanged", PlaceableHotspots) |
35 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
24 | function PlaceableHotspots.registerFunctions(placeableType) |
25 | SpecializationUtil.registerFunction(placeableType, "getHotspot", PlaceableHotspots.getHotspot) |
26 | end |
registerXMLPaths
DescriptionDefinitionregisterXMLPaths()Code
39 | function PlaceableHotspots.registerXMLPaths(schema, basePath) |
40 | schema:setXMLSpecializationType("Hotspots") |
41 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".hotspots.hotspot(?)#linkNode", "Node where hotspot is linked to") |
42 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".hotspots.hotspot(?)#teleportNode", "Node where player is teleported to. Teleporting is only available if this is set") |
43 | schema:register(XMLValueType.STRING, basePath .. ".hotspots.hotspot(?)#type", "Placeable hotspot type") |
44 | schema:register(XMLValueType.VECTOR_2, basePath .. ".hotspots.hotspot(?)#worldPosition", "Placeable world position") |
45 | schema:register(XMLValueType.VECTOR_3, basePath .. ".hotspots.hotspot(?)#teleportWorldPosition", "Placeable teleport world position") |
46 | schema:register(XMLValueType.STRING, basePath .. ".hotspots.hotspot(?)#text", "Placeable hotspot text") |
47 | schema:setXMLSpecializationType() |
48 | end |