Advertisement
Guest User

data-final-fixes.lua

a guest
Nov 23rd, 2017
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. -- energy cost override
  2. local energyRequired = {
  3. ["crude-oil"] = 5, -- equals 2/s in quarry mk3
  4. ["uranium-ore"] = 35
  5. }
  6.  
  7. -- list of resources unavailable in quarries
  8. local resourceBlacklist = {
  9. ["ground-water"] = true,
  10. ["thorium-ore"] = true
  11. }
  12.  
  13. for k, resource in pairs(data.raw["resource"]) do
  14. -- check valid minable resource
  15. if not resource.minable or resourceBlacklist[resource.name] or string.find(resource.name, "infinite") then
  16. goto skipResource
  17. end
  18.  
  19. local energy = energyRequired[resource.name] or settings.startup["quarry-recipe-speed"].value * resource.minable.hardness * resource.minable.mining_time
  20.  
  21. local ingredients = {}
  22. -- resources requiring fluids for mining (e.g. uranium-ore)
  23. if resource.minable.required_fluid then
  24. table.insert(ingredients, {type="fluid", name=resource.minable.required_fluid, amount=resource.minable.fluid_amount})
  25. end
  26.  
  27. local recipeName = "quarry-"..resource.name
  28. -- generate recipe
  29. local recipe = {
  30. type = "recipe",
  31. name = recipeName,
  32. localised_name = {"recipe-name.quarry-recipe", {"autoplace-control-names." .. resource.name}},
  33. category = "quarry",
  34. ingredients = ingredients,
  35. icon = resource.icon,
  36. energy_required = energy,
  37. subgroup = "raw-resource",
  38. order = "a"
  39. }
  40.  
  41. if resource.minable.required_fluid then
  42. if resource.minable.result then
  43. recipe.results = { {type = "item", name = resource.minable.result, amount = resource.minable.fluid_amount, probability = 1 } }
  44. end
  45. elseif resource.minable.results then
  46. recipe.results = table.deepcopy(resource.minable.results)
  47. elseif resource.minable.result then
  48. recipe.results = { {type = "item", name = resource.minable.result, amount = 1, probability = 1} } -- fluids always are results?
  49. else
  50. goto skipResource
  51. end
  52.  
  53. -- fix icon and name
  54. if resource.minable.results and resource.minable.results[1].type then
  55. recipe.localised_name = { "recipe-name.quarry-recipe", {resource.minable.results[1].type.."-name." .. resource.minable.results[1].name} }
  56. local result = data.raw[resource.minable.results[1].type][resource.minable.results[1].name]
  57. if result then
  58. if result.icon then
  59. recipe.icon = result.icon
  60. elseif result.icons then
  61. recipe.icon = nil
  62. recipe.icons = result.icons
  63. end
  64. end
  65. end
  66.  
  67. -- add stone residue
  68. -- if settings.startup["quarry-stone-waste-percentage"].value >= 0.1 and recipe.results[1].name ~= "stone" then
  69. -- log("adding "..settings.startup["quarry-stone-waste-percentage"].value.."% stone waste to "..recipe.results[1].name)
  70. -- recipe.results[1].probability = 1 - settings.startup["quarry-stone-waste-percentage"].value / 100
  71. -- table.insert(recipe.results, {type = "item", name = "stone", amount = 1, probability = settings.startup["quarry-stone-waste-percentage"].value / 100} )
  72. --end
  73.  
  74. data:extend({recipe})
  75.  
  76. if settings.startup["quarry-enable-prod"].value then
  77. -- allow productivity
  78. table.insert(data.raw.module["productivity-module"].limitation, recipeName)
  79. table.insert(data.raw.module["productivity-module-2"].limitation, recipeName)
  80. table.insert(data.raw.module["productivity-module-3"].limitation, recipeName)
  81. end
  82.  
  83. ::skipResource::
  84.  
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement