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
PlaceableIncomePerHour
DescriptionSpecialization for placeablesFunctions
- getIncomePerHourFactor
- getNeedHourChanged
- getSpecValueIncomePerHour
- initSpecialization
- loadSpecValueIncomePerHour
- onHourChanged
- onLoad
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerOverwrittenFunctions
- registerXMLPaths
getIncomePerHourFactor
DescriptionDefinitiongetIncomePerHourFactor()Code
89 | function PlaceableIncomePerHour:getIncomePerHourFactor() |
90 | return 1 |
91 | end |
getNeedHourChanged
DescriptionDefinitiongetNeedHourChanged()Code
68 | function PlaceableIncomePerHour:getNeedHourChanged(superFunc) |
69 | return true |
70 | end |
getSpecValueIncomePerHour
DescriptionReturns value of income per hourDefinition
getSpecValueIncomePerHour(table storeItem, table realItem)Arguments
table | storeItem | store item |
table | realItem | real item |
integer | incomePerHour | income per hour |
113 | function PlaceableIncomePerHour.getSpecValueIncomePerHour(storeItem, realItem) |
114 | if storeItem.specs.incomePerHour == nil then |
115 | return nil |
116 | end |
117 | |
118 | local perMonth = storeItem.specs.incomePerHour * 24-- 24 hours in an un-adjusted month |
119 | return string.format("%s / %s", g_i18n:formatMoney(perMonth), g_i18n:getText("ui_month")) |
120 | end |
initSpecialization
DescriptionDefinitioninitSpecialization()Code
51 | function PlaceableIncomePerHour.initSpecialization() |
52 | g_storeManager:addSpecType("incomePerHour", "shopListAttributeIconIncomePerHour", PlaceableIncomePerHour.loadSpecValueIncomePerHour, PlaceableIncomePerHour.getSpecValueIncomePerHour, "placeable") |
53 | end |
loadSpecValueIncomePerHour
DescriptionLoads capacity spec valueDefinition
loadSpecValueIncomePerHour(integer xmlFile, string customEnvironment)Arguments
integer | xmlFile | id of xml object |
string | customEnvironment | custom environment |
table | capacityAndUnit | capacity and unit |
98 | function PlaceableIncomePerHour.loadSpecValueIncomePerHour(xmlFile, customEnvironment, baseDir) |
99 | if not xmlFile:hasProperty("placeable.incomePerHour") then |
100 | return nil |
101 | end |
102 | |
103 | local incomePerHour = xmlFile:getValue("placeable.incomePerHour", 0) |
104 | |
105 | return incomePerHour |
106 | end |
onHourChanged
DescriptionCalled if hour changedDefinition
onHourChanged()Code
74 | function PlaceableIncomePerHour:onHourChanged() |
75 | if self.isServer then |
76 | local ownerFarmId = self:getOwnerFarmId() |
77 | if ownerFarmId ~= FarmlandManager.NO_OWNER_FARM_ID then |
78 | local spec = self.spec_incomePerHour |
79 | local incomePerHour = spec.incomePerHour * self:getIncomePerHourFactor() * g_currentMission.environment.timeAdjustment |
80 | if incomePerHour ~= 0 then |
81 | g_currentMission:addMoney(incomePerHour, ownerFarmId, MoneyType.PROPERTY_INCOME, true) |
82 | end |
83 | end |
84 | end |
85 | end |
onLoad
DescriptionCalled on loadingDefinition
onLoad(table savegame)Arguments
table | savegame | savegame |
58 | function PlaceableIncomePerHour:onLoad(savegame) |
59 | local spec = self.spec_incomePerHour |
60 | local xmlFile = self.xmlFile |
61 | |
62 | spec.incomePerHour = xmlFile:getValue("placeable.incomePerHour", 0) |
63 | spec.incomePerHourFactor = 1 |
64 | 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 PlaceableIncomePerHour.prerequisitesPresent(specializations) |
19 | return true |
20 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
36 | function PlaceableIncomePerHour.registerEventListeners(placeableType) |
37 | SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableIncomePerHour) |
38 | SpecializationUtil.registerEventListener(placeableType, "onHourChanged", PlaceableIncomePerHour) |
39 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
24 | function PlaceableIncomePerHour.registerFunctions(placeableType) |
25 | SpecializationUtil.registerFunction(placeableType, "getIncomePerHourFactor", PlaceableIncomePerHour.getIncomePerHourFactor) |
26 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
30 | function PlaceableIncomePerHour.registerOverwrittenFunctions(placeableType) |
31 | SpecializationUtil.registerOverwrittenFunction(placeableType, "getNeedHourChanged", PlaceableIncomePerHour.getNeedHourChanged) |
32 | end |
registerXMLPaths
DescriptionDefinitionregisterXMLPaths()Code
43 | function PlaceableIncomePerHour.registerXMLPaths(schema, basePath) |
44 | schema:setXMLSpecializationType("IncomePerHour") |
45 | schema:register(XMLValueType.FLOAT, basePath .. ".incomePerHour", "Income per hour") |
46 | schema:setXMLSpecializationType() |
47 | end |