97Lukas90

soybean straw ls19

Jul 28th, 2021
1,103
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2. CanolaStraw
  3.  
  4. Specialization to allow straw for soybean
  5.  
  6. Author:     97Lukas90
  7. Date:       08.07.2021
  8. Version:    1.0
  9.  
  10. History:    v1.0 @06.08.2020 - initial implemation/tests in FS 19
  11.             v1.1 @08.07.2021 - first beta release to #HeilPika Discord
  12. ]]
  13.  
  14. SoybeanStraw = {};
  15.  
  16. function SoybeanStraw:loadFruitTypeWindrow(superFunc, fruitType, xmlFile, key)
  17.     local soybean = g_fruitTypeManager:getFruitTypeByName("soybean");
  18.  
  19.     if soybean ~= nil then
  20.         local windrowFillType = g_fillTypeManager:getFillTypeByName("straw");
  21.        
  22.         soybean.hasWindrow = true;
  23.         soybean.windrowName = windrowFillType.name;
  24.         soybean.windrowLiterPerSqm = 2.68;
  25.         self.windrowFillTypes[windrowFillType.index] = true;
  26.         self.fruitTypeIndexToWindrowFillTypeIndex[soybean.index] = windrowFillType.index;
  27.         self.fillTypeIndexToFruitTypeIndex[windrowFillType.index] = soybean.index;
  28.     end;
  29.    
  30.     if fruitType ~= nil and fruitType.name ~= "SOYBEAN" then
  31.         local windrowName = getXMLString(xmlFile, key .. ".windrow#name");
  32.         local windrowLitersPerSqm = getXMLFloat(xmlFile, key .. ".windrow#litersPerSqm");
  33.  
  34.         if windrowName == nil or windrowLitersPerSqm == nil then
  35.             return true;
  36.         end;
  37.  
  38.         local windrowFillType = g_fillTypeManager:getFillTypeByName(windrowName);
  39.  
  40.         if windrowFillType == nil then
  41.             print("Warning: Missing fillType '" .. tostring(windrowName) .. "' for windrow definition. Ignoring windrow!");
  42.  
  43.             return false;
  44.         end;
  45.  
  46.         fruitType.hasWindrow = true;
  47.         fruitType.windrowName = windrowFillType.name;
  48.         fruitType.windrowLiterPerSqm = windrowLitersPerSqm;
  49.         self.windrowFillTypes[windrowFillType.index] = true;
  50.         self.fruitTypeIndexToWindrowFillTypeIndex[fruitType.index] = windrowFillType.index;
  51.         self.fillTypeIndexToFruitTypeIndex[windrowFillType.index] = fruitType.index;
  52.     end;
  53.  
  54.     return true;
  55. end;
  56.  
  57. FruitTypeManager.loadFruitTypeWindrow = Utils.overwrittenFunction(FruitTypeManager.loadFruitTypeWindrow, SoybeanStraw.loadFruitTypeWindrow)
RAW Paste Data