IllustriousDonut

logistic-containers.lua

Mar 3rd, 2026 (edited)
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.13 KB | Source Code | 0 0
  1. -- Applies new sprites to all five logistic chests
  2. ---------------------------------------------------------------------------------------------------
  3. -- PATCH NOTE:
  4. -- This section used to reference base sound keys like `sounds.big_bush` and `sounds.plant`.
  5. -- Those keys are not consistent across Factorio versions/modpacks, which caused a data-stage crash:
  6. --   bad argument #1 to 'pairs' (table expected, got nil)
  7. -- To make this stable, we define the sound variations explicitly (two bush rustle sounds) and reuse
  8. -- that table for both `animation_sound` and `vehicle_impact_sound`.
  9. -- This avoids relying on `__base__/prototypes/entity/sounds.lua` keys entirely.
  10.  
  11. if settings.startup["bumble-bots-enable-flowers"].value then
  12.     local sounds = require("__base__/prototypes/entity/sounds.lua")
  13.     -- List of bush types
  14.     local bushTypes = {
  15.         "storage", "passive-provider", "active-provider",
  16.         "requester", "buffer"
  17.     }
  18.  
  19.     -- For circuit connections
  20.     local empty_sheet = {
  21.         filename = '__core__/graphics/empty.png',
  22.         width = 1,
  23.         height = 1,
  24.         frame_count = 1,
  25.         line_length = 1,
  26.         priority = "low",
  27.         scale = 0.5,
  28.         shift = util.by_pixel(0, 0)
  29.     }
  30.  
  31.     -- Circuit connection locations
  32.     bush_connector_template = {
  33.         connector_main = empty_sheet,
  34.         connector_shadow = empty_sheet,
  35.         wire_pins = empty_sheet,
  36.         wire_pins_shadow = empty_sheet,
  37.  
  38.         led_blue = {
  39.             filename = "__base__/graphics/entity/circuit-connector/hr-ccm-universal-04e-blue-LED-on-sequence.png",
  40.             frame_count = 32,
  41.             height = 60,
  42.             line_length = 8,
  43.             priority = "low",
  44.             scale = 0.5,
  45.             shift = util.by_pixel(0, 0),
  46.             width = 60
  47.         },
  48.  
  49.         led_blue_off = {
  50.             filename = "__base__/graphics/entity/circuit-connector/hr-ccm-universal-04f-blue-LED-off-sequence.png",
  51.             frame_count = 32,
  52.             height = 44,
  53.             line_length = 8,
  54.             priority = "low",
  55.             scale = 0.5,
  56.             shift = util.by_pixel(0, 0),
  57.             width = 46
  58.         },
  59.  
  60.         led_green = {
  61.             filename = "__base__/graphics/entity/circuit-connector/hr-ccm-universal-04h-green-LED-sequence.png",
  62.             frame_count = 32,
  63.             height = 46,
  64.             line_length = 8,
  65.             priority = "low",
  66.             scale = 0.5,
  67.             shift = util.by_pixel(0, 0),
  68.             width = 48
  69.         },
  70.  
  71.         led_red = {
  72.             filename = "__base__/graphics/entity/circuit-connector/hr-ccm-universal-04i-red-LED-sequence.png",
  73.             frame_count = 32,
  74.             height = 46,
  75.             line_length = 8,
  76.             priority = "low",
  77.             scale = 0.5,
  78.             shift = util.by_pixel(0, 0),
  79.             width = 48
  80.         },
  81.         wire_offsets = {
  82.             {
  83.                 red = util.by_pixel(13, -3),
  84.                 green = util.by_pixel(-16, 0)
  85.             }
  86.         },
  87.         wire_shadow_offsets = {
  88.             {
  89.                 red = util.by_pixel(9, 0.5),
  90.                 green = util.by_pixel(-12, 3.5)
  91.             }
  92.         },
  93.         light_offsets = {
  94.             {
  95.                 rg = util.by_pixel(3.5, 5),
  96.                 b = util.by_pixel(-3.5, 8.5)
  97.             }
  98.         }
  99.     }
  100.  
  101.     circuit_connector_definitions["bush"] = circuit_connector_definitions.create_single(
  102.         universal_connector_template,
  103.             {
  104.                 variation = 0,
  105.                 main_offset = util.by_pixel(0, 0),
  106.                 shadow_offset = util.by_pixel(0, 0),
  107.                 show_shadow = false
  108.             }
  109.         )
  110.  
  111.     -- Animations
  112.     local function get_animation(name)
  113.         return {
  114.             layers = {
  115.                 {
  116.                     filename = "__bumble-bots__/graphics/entity/logistic-bush/" .. name .. ".png",
  117.                     priority = "extra-high",
  118.                     width = 111,
  119.                     height = 99,
  120.                     frame_count = 10,
  121.                     shift = util.by_pixel(0, 0),
  122.                     scale = 0.333,
  123.                     hr_version = {
  124.                         filename = "__bumble-bots__/graphics/entity/logistic-bush/" .. name ..
  125.                             ".png",
  126.                         priority = "extra-high",
  127.                         width = 111,
  128.                         height = 99,
  129.                         frame_count = 10,
  130.                         shift = util.by_pixel(0, 0),
  131.                         scale = 0.333
  132.                     }
  133.                 }, {
  134.                     filename = "__bumble-bots__/graphics/entity/logistic-bush/bush-shadow.png",
  135.                     priority = "extra-high",
  136.                     width = 96,
  137.                     height = 44,
  138.                     repeat_count = 10,
  139.                     shift = util.by_pixel(8.5, 7.5),
  140.                     draw_as_shadow = true,
  141.                     scale = 0.333,
  142.                     hr_version = {
  143.                         filename = "__bumble-bots__/graphics/entity/logistic-bush/bush-shadow.png",
  144.                         priority = "extra-high",
  145.                         width = 96,
  146.                         height = 44,
  147.                         repeat_count = 10,
  148.                         shift = util.by_pixel(8.5, 7),
  149.                         draw_as_shadow = true,
  150.                         scale = 0.333
  151.                     }
  152.                 }
  153.             }
  154.         }
  155.     end
  156.  
  157.     local corpse = table.deepcopy(data.raw.corpse["passive-provider-chest-remnants"])
  158.     corpse.name = "logistic-bush-remnants"
  159.     corpse.animation = make_rotated_animation_variations_from_sheet(4, {
  160.         filename = "__bumble-bots__/graphics/entity/logistic-bush/bush-corpse.png",
  161.         priority = "extra-high",
  162.         line_length = 1,
  163.         width = 111,
  164.         height = 111,
  165.         frame_count = 1,
  166.         variation_count = 1,
  167.         axially_symmetrical = false,
  168.         direction_count = 1,
  169.         shift = util.by_pixel(0, 0),
  170.         scale = 0.3,
  171.         hr_version = {
  172.             filename = "__bumble-bots__/graphics/entity/logistic-bush/bush-corpse.png",
  173.             priority = "extra-high",
  174.             line_length = 1,
  175.             width = 111,
  176.             height = 111,
  177.             frame_count = 1,
  178.             variation_count = 1,
  179.             axially_symmetrical = false,
  180.             direction_count = 1,
  181.             shift = util.by_pixel(0, 0),
  182.             scale = 0.36
  183.         }
  184.     })
  185.     data:extend({corpse})
  186.  
  187.     -- Sounds
  188.     -- We define our own sound variations to avoid relying on base sound keys that may be missing.
  189.     -- These are the same bush rustle sounds already used for open/close.
  190.     local animation_sound = {
  191.       { filename = "__base__/sound/walking/plant/bush-small-1.ogg", volume = 1 },
  192.       { filename = "__base__/sound/walking/plant/bush-small-2.ogg", volume = 1 }
  193.     }
  194.  
  195.     for _, s in pairs(animation_sound) do
  196.       s.volume = 0.5 * settings.startup["bumble-bots-bush-volume"].value
  197.     end
  198.  
  199.     -- Apply changes to each type
  200.     for _, v in pairs(bushTypes) do
  201.         local bush = data.raw["logistic-container"][v.."-chest"]
  202.         bush.animation = get_animation(v)
  203.         bush.animation_sound = animation_sound
  204.         bush.open_sound = {
  205.             filename = "__base__/sound/walking/plant/bush-small-1.ogg",
  206.             volume = 1
  207.         }
  208.         bush.close_sound = {
  209.             filename = "__base__/sound/walking/plant/bush-small-2.ogg",
  210.             volume = 1
  211.         }
  212.         bush.vehicle_impact_sound = animation_sound
  213.         bush.circuit_wire_connection_point = circuit_connector_definitions["bush"].points
  214.         bush.circuit_connector_sprites = circuit_connector_definitions["bush"].sprites
  215.         bush.icon = "__bumble-bots__/graphics/icons/" .. v .. ".png"
  216.         bush.icon_size = 64
  217.         bush.icon_mipmaps = 1
  218.         bush.corpse = "logistic-bush-remnants"
  219.  
  220.         local bush_icon = data.raw["item"][v.."-chest"]
  221.         bush_icon.icon = "__bumble-bots__/graphics/icons/" .. v .. ".png"
  222.         bush_icon.icon_size = 64
  223.         bush_icon.icon_mipmaps = 1
  224.  
  225.     end
  226. end
  227.  
Advertisement
Add Comment
Please, Sign In to add comment