on_entity_damaged damage_type returns __self = 0

Place to get help with not working mods / modding interface.
BubstyBoy
Burner Inserter
Burner Inserter
Posts: 11
Joined: Tue Aug 15, 2023 3:24 pm
Contact:

on_entity_damaged damage_type returns __self = 0

Post by BubstyBoy »

Whenever on_entity_damaged is called, if I try to get the damage type, it just returns this:

Code: Select all

  damage_type = {
    __self = 0
  },
does anyone know why it does this or how to get the damage type from it? Thanks!
User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 416
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: on_entity_damaged damage_type returns __self = 0

Post by Stringweasel »

Is that while printing it using serpent? Or logging it? Looks like a LuaObject, which can't be printed.

Of you show your code it would be easier to help.
Alt-F4 Author | Factorio Modder
My Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby
Official Contributor to Space Exploration
BubstyBoy
Burner Inserter
Burner Inserter
Posts: 11
Joined: Tue Aug 15, 2023 3:24 pm
Contact:

Re: on_entity_damaged damage_type returns __self = 0

Post by BubstyBoy »

It is being logged in factorio-current.log
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2768
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: on_entity_damaged damage_type returns __self = 0

Post by FuryoftheStars »

damage_type is a custom Lua object. You'll need to assign it to a var and then pull the specific value from it you are interested in.

https://lua-api.factorio.com/latest/cla ... otype.html
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
BubstyBoy
Burner Inserter
Burner Inserter
Posts: 11
Joined: Tue Aug 15, 2023 3:24 pm
Contact:

Re: on_entity_damaged damage_type returns __self = 0

Post by BubstyBoy »

Ok, thank you!
Post Reply

Return to “Modding help”