TheBiky88

Untitled

Aug 7th, 2026
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.52 KB | None | 0 0
  1. local M = {
  2.     entity = {},
  3.     item = {},
  4.     recipe = {},
  5.     tech = {},
  6. }
  7.  
  8. function M.item.set_weight(item_name, weight)
  9.     if not data.raw["item"][item_name] then
  10.         return
  11.     end
  12.     data.raw["item"][item_name].weight = weight
  13. end
  14.  
  15. function M.entity.add_crafting_category(entity_type, entity_name, category)
  16.     if not data.raw[entity_type] then
  17.         return
  18.     end
  19.     if not data.raw[entity_type][entity_name] then
  20.         return
  21.     end
  22.     local entity = data.raw[entity_type][entity_name]
  23.     if not entity.crafting_categories then
  24.         entity.crafting_categories = {}
  25.     end
  26.     entity.crafting_categories[#entity.crafting_categories + 1] = category
  27. end
  28.  
  29. function M.entity.add_lab_input(lab_name, input)
  30.     if not data.raw["lab"][lab_name] then
  31.         return
  32.     end
  33.     local lab = data.raw["lab"][lab_name]
  34.     if not lab.inputs then
  35.         lab.inputs = {}
  36.     end
  37.     lab.inputs[#lab.inputs + 1] = input
  38. end
  39.  
  40. function M.entity.set_crafting_speed(entity_type, entity_name, speed)
  41.     if not data.raw[entity_type] then
  42.         return
  43.     end
  44.     if not data.raw[entity_type][entity_name] then
  45.         return
  46.     end
  47.     local entity = data.raw[entity_type][entity_name]
  48.     entity.crafting_speed = speed
  49. end
  50.  
  51. function M.recipe.double_time(recipe_name)
  52.     if not data.raw["recipe"][recipe_name] then
  53.         return
  54.     end
  55.     local recipe = data.raw["recipe"][recipe_name]
  56.     recipe.energy_required = 2 * recipe.energy_required
  57. end
  58.  
  59. function M.recipe.is_centrifuging(recipe_name)
  60.     local recipe = data.raw["recipe"][recipe_name]
  61.     if not recipe or not recipe.categories then
  62.         return false
  63.     end
  64.     -- Don't include advanced-centrifuging-or-crafting
  65.     for _, category in pairs(recipe.categories) do
  66.         if category == "centrifuging" or category == "centrifuging-or-crafting" then
  67.             return true
  68.         end
  69.     end
  70.     return false
  71. end
  72.  
  73. function M.recipe.set_category(recipe_name, category)
  74.     if not data.raw["recipe"][recipe_name] then
  75.         return
  76.     end
  77.     data.raw["recipe"][recipe_name].categories = { category }
  78. end
  79.  
  80. function M.tech.add_effect(tech_name, effect)
  81.     if not data.raw["technology"][tech_name] then
  82.         return
  83.     end
  84.     local tech = data.raw["technology"][tech_name]
  85.     if not tech.effects then
  86.         tech.effects = {}
  87.     end
  88.     tech.effects[#tech.effects + 1] = effect
  89. end
  90.  
  91. function M.tech.add_ingredient(tech_name, ingredient)
  92.     if not data.raw["technology"][tech_name] or not data.raw["technology"][tech_name].unit then
  93.         return
  94.     end
  95.     local tech = data.raw["technology"][tech_name]
  96.     if not tech.unit.ingredients then
  97.         tech.unit.ingredients = {}
  98.     end
  99.     if M.tech.has_ingredient(tech, ingredient) then
  100.         return
  101.     end
  102.     tech.unit.ingredients[#tech.unit.ingredients + 1] = ingredient
  103. end
  104.  
  105. function M.tech.add_prerequisite(tech_name, prerequisite)
  106.     if not data.raw["technology"][tech_name] or not data.raw["technology"][prerequisite] then
  107.         return
  108.     end
  109.     local tech = data.raw["technology"][tech_name]
  110.     if not tech.prerequisites then
  111.         tech.prerequisites = {}
  112.     end
  113.     if M.tech.has_prerequisite(tech, prerequisite) then
  114.         return
  115.     end
  116.     tech.prerequisites[#tech.prerequisites + 1] = prerequisite
  117. end
  118.  
  119. function M.tech.has_prerequisite(tech, prerequisite)
  120.     if not tech.prerequisites then
  121.         return false
  122.     end
  123.     for _, extant in pairs(tech.prerequisites) do
  124.         if extant == prerequisite then
  125.             return true
  126.         end
  127.     end
  128.     return false
  129. end
  130.  
  131. function M.tech.has_ingredient(tech, ingredient)
  132.     if not tech.unit or not tech.unit.ingredients then
  133.         return false
  134.     end
  135.     for _, extant in pairs(tech.unit.ingredients) do
  136.         if extant[1] == ingredient[1] then
  137.             return true
  138.         end
  139.     end
  140.     return false
  141. end
  142.  
  143. function M.tech.delete_ingredient(tech_name, target)
  144.     if
  145.         not data.raw["technology"][tech_name]
  146.         or not data.raw["technology"][tech_name].unit
  147.         or not data.raw["technology"][tech_name].unit.ingredients
  148.     then
  149.         return false
  150.     end
  151.     local deleted = false
  152.     local new_ingredients = {}
  153.     for _, ingredient in pairs(data.raw["technology"][tech_name].unit.ingredients) do
  154.         if ingredient[1] == target then
  155.             deleted = true
  156.         else
  157.             new_ingredients[#new_ingredients + 1] = ingredient
  158.         end
  159.     end
  160.     if deleted then
  161.         data.raw["technology"][tech_name].unit.ingredients = new_ingredients
  162.     end
  163.     return deleted
  164. end
  165.  
  166. function M.tech.delete_prerequisite(tech_name, target)
  167.     if not data.raw["technology"][tech_name] or not data.raw["technology"][tech_name].prerequisites then
  168.         return false
  169.     end
  170.     local deleted = false
  171.     local new_prereqs = {}
  172.     for _, prerequisite in pairs(data.raw["technology"][tech_name].prerequisites) do
  173.         if prerequisite == target then
  174.             deleted = true
  175.         else
  176.             new_prereqs[#new_prereqs + 1] = prerequisite
  177.         end
  178.     end
  179.     if deleted then
  180.         data.raw["technology"][tech_name].prerequisites = new_prereqs
  181.     end
  182.     return deleted
  183. end
  184.  
  185. function M.tech.make_essential(tech_name)
  186.     if not data.raw["technology"][tech_name] then
  187.         return
  188.     end
  189.     data.raw["technology"][tech_name].essential = true
  190. end
  191.  
  192. function M.tech.requires_planet_sciences(tech_name)
  193.     if
  194.         not data.raw["technology"][tech_name]
  195.         or not data.raw["technology"][tech_name].unit
  196.         or not data.raw["technology"][tech_name].unit.ingredients
  197.     then
  198.         return false
  199.     end
  200.     local count = 0
  201.     for _, ingredient in pairs(data.raw["technology"][tech_name].unit.ingredients) do
  202.         if
  203.             ingredient[1] == "metallurgic-science-pack"
  204.             or ingredient[1] == "electromagnetic-science-pack"
  205.             or ingredient[1] == "agricultural-science-pack"
  206.         then
  207.             count = count + 1
  208.         end
  209.     end
  210.     return count == 3
  211. end
  212.  
  213. function M.tech.set_prerequisites(tech_name, prerequisites)
  214.     if not data.raw["technology"][tech_name] then
  215.         return
  216.     end
  217.     data.raw["technology"][tech_name].prerequisites = prerequisites
  218. end
  219.  
  220. function M.tech.set_trigger(tech_name, trigger)
  221.     if not data.raw["technology"][tech_name] then
  222.         return
  223.     end
  224.     local tech = data.raw["technology"][tech_name]
  225.     if tech.unit then
  226.         tech.unit = nil
  227.     end
  228.     tech.research_trigger = trigger
  229. end
  230.  
  231. return M
Advertisement
Add Comment
Please, Sign In to add comment