Skip to content

Commit

Permalink
added stats for manure and fuel trailers
Browse files Browse the repository at this point in the history
  • Loading branch information
TyKonKet committed Mar 16, 2021
1 parent 3f108c5 commit 938125d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/advancedStatsMain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,7 @@ function AdvancedStatsMain:onValidateVehicleTypes(vehicleTypeManager, addSpecial
addSpecializationBySpecialization("extendedWoodHarvester", "woodHarvester")

addSpecializationByVehicleType("extendedShovel", "shovel")

addSpecializationByVehicleType("extendedFillTriggerVehicle", "fuelTrailer")
addSpecializationByVehicleType("extendedFillTriggerVehicle", "manureTrailer")
end
43 changes: 43 additions & 0 deletions src/extendedSpecializations/FillTriggerVehicle.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---${title}

---@author ${author}
---@version r_version_r
---@date 16/03/2021

---@class ExtendedFillTriggerVehicle : AdvancedStatsExtendedSpecialization
ExtendedFillTriggerVehicle = {}
ExtendedFillTriggerVehicle.MOD_NAME = g_currentModName
ExtendedFillTriggerVehicle.SPEC_TABLE_NAME = string.format("spec_%s.extendedFillTriggerVehicle", ExtendedFillTriggerVehicle.MOD_NAME)

function ExtendedFillTriggerVehicle.prerequisitesPresent(specializations)
return SpecializationUtil.hasSpecialization(AdvancedStats, specializations)
end

function ExtendedFillTriggerVehicle.registerEventListeners(vehicleType)
SpecializationUtil.registerEventListener(vehicleType, "onLoadStats", ExtendedFillTriggerVehicle)
SpecializationUtil.registerEventListener(vehicleType, "onFillUnitFillLevelChanged", ExtendedFillTriggerVehicle)
end

function ExtendedFillTriggerVehicle:onLoadStats()
local spec = self:getAdvancedStatsSpecTable(ExtendedFillTriggerVehicle.SPEC_TABLE_NAME)

spec.hasAdvancedStats = true
spec.advancedStatisticsPrefix = "FillTriggerVehicle"

if self.isServer then
spec.advancedStatistics =
self:registerStats(
spec.advancedStatisticsPrefix,
{
{"LoadedLiters", AdvancedStats.UNITS.LITRE}
}
)
end
end

function ExtendedFillTriggerVehicle:onFillUnitFillLevelChanged(fillUnitIndex, fillLevelDelta, fillTypeIndex, toolType, fillPositionData, appliedDelta)
if self.isServer and appliedDelta > 0 then
local spec = self:getAdvancedStatsSpecTable(ExtendedFillTriggerVehicle.SPEC_TABLE_NAME)
self:updateStat(spec.advancedStatistics["LoadedLiters"], appliedDelta)
end
end
8 changes: 8 additions & 0 deletions src/modDesc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Changelog 2.1.0.0:
<specialization name="extendedWindrower" className="ExtendedWindrower" filename="extendedSpecializations/Windrower.lua" />
<specialization name="extendedWoodCrusher" className="ExtendedWoodCrusher" filename="extendedSpecializations/WoodCrusher.lua" />
<specialization name="extendedWoodHarvester" className="ExtendedWoodHarvester" filename="extendedSpecializations/WoodHarvester.lua" />
<specialization name="extendedFillTriggerVehicle" className="ExtendedFillTriggerVehicle" filename="extendedSpecializations/FillTriggerVehicle.lua" />
</specializations>

<extraSourceFiles>
Expand Down Expand Up @@ -569,6 +570,13 @@ Changelog 2.1.0.0:
<pl>Opryskano herbicydami</pl>
<ru>Обработано гербицидами</ru>
</text>
<text name="ass_FillTriggerVehicleLoadedLiters">
<en>Loaded</en>
<fr>chargés</fr>
<de>Geladen</de>
<pl>Załadowano</pl>
<ru>Загружено</ru>
</text>
<text name="ass_units_hectares">
<en>ha</en>
<fr>ha</fr>
Expand Down

0 comments on commit 938125d

Please sign in to comment.