shanemadden / factorio-deadlock-beltboxes-loaders

Other
8 stars 17 forks source link

CRash on deadlock.add_stack #39

Open RedRafe opened 5 days ago

RedRafe commented 5 days ago

Hi, before the update to 2.0, this is how I was calling to the API:

deadlock.add_stack('pipe', nil, 'deadlock-stacking-1', 64)

But now I'm getting this error on load:

   0.496 Script @__deadlock-beltboxes-loaders__/prototypes/shared.lua:13: DBL: Error: Can't create layered icon for item (pipe), base item defines icon but no icon_size
   0.496 Error ModManager.cpp:1741: Failed to load mod "redmew-data": __deadlock-beltboxes-loaders__/prototypes/create_stack.lua:124: attempt to index field '?' (a nil value)
stack traceback:
    __deadlock-beltboxes-loaders__/prototypes/create_stack.lua:124: in function 'create_stacking_recipes'
    __deadlock-beltboxes-loaders__/prototypes/public.lua:195: in function 'add_stack'
    ...ger-ores/vanilla/compatibility/deadlock/data-updates.lua:15: in main chunk
    [C]: in function 'require'
    __redmew-data__/danger-ores/vanilla/data-updates.lua:8: in main chunk
    [C]: in function 'require'
    __redmew-data__/data-updates.lua:11: in main chunk
   0.520 Loading mod core 0.0.0 (data.lua)
   0.534 Checksum for core: 3203360670
   0.550 Error ModManager.cpp:1741: Error in assignID: procession with name 'default-b' does not exist.

Source: default (utility-constants).

Can you have a loot at it maybe? Thanks

RedRafe commented 5 days ago

I believe this is due to new prototype definition, from Wube's src:

 {
    type = "item",
    name = "pipe",
    icon = "__base__/graphics/icons/pipe.png",
    subgroup = "energy-pipe-distribution",
    order = "a[pipe]-a[pipe]",
    inventory_move_sound = item_sounds.metal_small_inventory_move,
    pick_sound = item_sounds.metal_small_inventory_pickup,
    drop_sound = item_sounds.metal_small_inventory_move,
    place_result = "pipe",
    stack_size = 100,
    weight = 5 * kg,
    random_tint_color = item_tints.iron_rust
  }

icon_size now defaults to 64 but is not specified in prototype attributes. So maybe you'd want to fallback to that value if no icons found and only icon is specified without icon_size.

https://github.com/shanemadden/factorio-deadlock-beltboxes-loaders/blob/6a02c755217416076e5d65f4ffb6b7cda75a2b89/prototypes/create_stack.lua#L51-L55

Setting data.raw.item.pipe.icon_size = 64 before calling deadlock.add_stack('pipe', nil, 'deadlock-stacking-1', 64) does indeed fix the issue. Up to you