Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. local function getIngIndex (recipe, name)
  2.   for index, ingr in pairs (recipe.ingredients) do    
  3.     if ingr[1] == name or ingr.name == name then    
  4.       return index;    
  5.     end    
  6.   end  
  7.   return 0;
  8. end
  9.  
  10. local function hasIng (recipe, name)
  11.   return getIngIndex(recipe, name) ~= 0;
  12. end
  13.  
  14. local function tryRemoveWheel(recipe)
  15.   if recipe.ingredients then  
  16.     local wheelIndex = getIngIndex (recipe, 'iron-gear-wheel');
  17.     if hasIng(recipe, 'small-parts-01') and wheelIndex > 0 then    
  18.       table.remove(recipe.ingredients, wheelIndex);
  19.     end        
  20.   else  
  21.     if (recipe.normal) then    
  22.       tryRemoveWheel (recipe.normal);
  23.     end    
  24.     if (recipe.expensive) then    
  25.       tryRemoveWheel (recipe.expensive);
  26.     end    
  27.   end
  28. end
  29.  
  30. for _, recipe in pairs (data.raw["recipe"]) do      
  31.    tryRemoveWheel (recipe);
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement