Page 1 of 1
Error "Cannot serialise ttype=function"
Posted: Fri Jan 06, 2023 6:08 am
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?
Re: Error "Cannot serialise ttype=function"
Posted: Fri Jan 06, 2023 1:43 pm
by FuryoftheStars
Posting of at least some of your code (especially where the error occurs) may be required.
Re: Error "Cannot serialise ttype=function"
Posted: Fri Jan 06, 2023 3:39 pm
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"}
}),
Re: Error "Cannot serialise ttype=function"
Posted: Fri Jan 06, 2023 4:51 pm
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.