--[[ fruitTypeParts Author: HoFFi (modding-welt.com) Description: - script to disable threshing other fruits than canola if rape seed knifes are activated - when threshing canola without knifes, you get less yield - script must be added to cutter Version: 1.0.0.0 Changelog: 2019-08-29 - initial release 2019-09-05 - bug fixing and improvement -------------------------------------------------------------------------------------------------- XML: Moddesc: .... This cutter is configured for canola ONLY!Dieses Schneidwerk ist NUR für RAPS konfiguriert! LossVerlust knifes equiptedRapsmesser aktiv knifes not equiptedRapsmesser inaktiv ]] fruitTypeParts = {}; fruitTypeParts.modDir = g_currentModDirectory; fruitTypeParts.currentModName = g_currentModName; function fruitTypeParts.prerequisitesPresent(specializations) return SpecializationUtil.hasSpecialization(Cutter, specializations); end; function fruitTypeParts.registerEventListeners(vehicleType) for _, spec in pairs({"onLoad", "onDelete", "onUpdate", "onDraw", "onReadStream", "onWriteStream"}) do SpecializationUtil.registerEventListener(vehicleType, spec, fruitTypeParts) end end function fruitTypeParts:onLoad(savegame) self.sideKnivesNode = I3DUtil.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.fruitTypeParts#sideKnivesNode"), self.i3dMappings); self.threshingLossPercentage = Utils.getNoNil(getXMLFloat(self.xmlFile, "vehicle.fruitTypeParts#threshingLossPercentage"), 10); self.lastFT = 0 end; function fruitTypeParts:onUpdate(dt) local spec = self.spec_cutter local attacherVehicle = self:getAttacherVehicle() self.lastFT = spec.lastValidInputFruitType self.currFT = spec.currentInputFruitType if self.sideKnivesNode ~= nil then if getVisibility(self.sideKnivesNode) then if self.currFT == FillType.BARLEY or self.currFT == FillType.COTTON or self.currFT == FillType.DRYGRASS or self.currFT == FillType.GRASS or self.currFT == FillType.GRASSWINDROW or self.currFT == FillType.MAIZE or self.currFT == FillType.OAT or self.currFT == FillType.POPPLAR or self.currFT == FillType.POTATO or self.currFT == FillType.SOYBEAN or self.currFT == FillType.STRAW or self.currFT == FillType.SUGARBEET or self.currFT == FillType.SUGARCANE or self.currFT == FillType.SUNFLOWER or self.currFT == FillType.WHEAT then if self:getIsTurnedOn() then self:setIsTurnedOn(false, true) if self:getIsActiveForInput(true) then g_currentMission:showBlinkingWarning(g_i18n:getText("FTPcanolaWarning"), 2000) end end if attacherVehicle ~= nil then attacherVehicle.spec_combine.threshingScale = 1 end else if attacherVehicle ~= nil then attacherVehicle.spec_combine.threshingScale = 1 end end else if self.lastFT == FillType.CANOLA then if attacherVehicle ~= nil then attacherVehicle.spec_combine.threshingScale = 1 - (self.threshingLossPercentage / 100) end else if attacherVehicle ~= nil then attacherVehicle.spec_combine.threshingScale = 1 end end end else if attacherVehicle ~= nil then attacherVehicle.spec_combine.threshingScale = 1 end end end; function fruitTypeParts:onDelete() end; function fruitTypeParts:onReadStream(streamId, connection) end; function fruitTypeParts:onWriteStream(streamId, connection) end; function fruitTypeParts:onDraw(isActiveForInput, isSelected) if self.isClient then if isSelected then if self:getAttacherVehicle() ~= nil then local attacherVehicle = self:getAttacherVehicle() text2 = (1 - attacherVehicle.spec_combine.threshingScale) * 100 else text2 = " " end if self.lastFT ~= 0 then local fruitType1 = g_fruitTypeManager:getFruitTypeByIndex(self.lastFT) text1 = fruitType1.fillType.title else text1 = " - " end if getVisibility(self.sideKnivesNode) then text3 = g_i18n:getText("FTPknifesON") else text3 = g_i18n:getText("FTPknifesOFF") end g_currentMission:addExtraPrintText(g_i18n:getText("statistic_fillType") .. ": " .. text1 .. " | " .. g_i18n:getText("FTPloss") .. ": " .. text2 .. "% | " .. text3) end end end