Error "Cannot serialise ttype=function"

Place to get help with not working mods / modding interface.
AlkoShrek
Manual Inserter
Manual Inserter
Posts: 2
Joined: Thu Jan 05, 2023 1:16 pm
Contact:

Error "Cannot serialise ttype=function"

Post by AlkoShrek »

When I try to add a corpse for my units, I get the error "Cannot serialize ttype=function". What causes it and how to fix it?
I added the corpses using a 1 frame death animation where 1 frame = 1 direction. Are there alternative working ways to add this?
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2768
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Error "Cannot serialise ttype=function"

Post by FuryoftheStars »

Posting of at least some of your code (especially where the error occurs) may be required.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
AlkoShrek
Manual Inserter
Manual Inserter
Posts: 2
Joined: Thu Jan 05, 2023 1:16 pm
Contact:

Re: Error "Cannot serialise ttype=function"

Post by AlkoShrek »

Made just like in vanilla

Code: Select all

function betonomeshalka_ultra_die_animation()
  return
  {
    layers=
    {
      {
        filenames =
        {
          "__alkashGun__/text/betonomeshalka-ultra-ded.png",
          "__alkashGun__/text/betonomeshalka-ultra-ded-2.png"
        },
        slice = 4,
        lines_per_file = 4,
        line_length = 4,
        width = 20,
        height = 26,
        frame_count = 1,
        direction_count = 32,
        shift= util.mul_shift(util.by_pixel(-2, -4))
      }
    }
  }
end

function add_betonomeshalka_ultra_die_animation(corpse)
  corpse.animation = betonomeshalka_ultra_die_animation
  corpse.dying_speed = 0.04
  corpse.time_before_removed = 15 * 60 * 60
--  There were "corpse.direction_shuffle" parameters here, but I cut them as unnecessary
  corpse.final_render_layer = "lower-object-above-shadow"

  return corpse
end         
...
After data:extend and the unit itself:

Code: Select all

  add_betonomeshalka_ultra_die_animation(
  {
    type = "corpse",
    name = "betonomeshalka-ultra-corpse",
    icon = "__alkashGun__/text/alpha.png",
    icon_size = 64, icon_mipmaps = 4,
    selectable_in_game = false,
    selection_box = {{-1, -1}, {1, 1}},
    subgroup="corpses",
    order = "error-npb",
    flags = {"placeable-neutral", "placeable-off-grid", "building-direction-8-way", "not-on-map"}
  }),
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3025
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Error "Cannot serialise ttype=function"

Post by boskid »

Code: Select all

corpse.animation = betonomeshalka_ultra_die_animation
Its not a function call so it does not store result of the function call. It stores reference to a function itself.
Post Reply

Return to “Modding help”