Page 1 of 1

[Rseding91] [0.16.30] Character Corpse Position Issue

Posted: Fri Mar 16, 2018 4:15 pm
by Cooldude2606
Problem either with the position of the character corpse or the surface.find_entity function:
This will return nil.

Code: Select all

entity = surface.create_entity{name="character-corpse", position={0,0}} 
game.print(type(surface.find_entity(entity.name, entity.position)))
While this returns the transport belt entity.

Code: Select all

entity = surface.create_entity{name="transport-belt", position={0,0}}
game.print(type(surface.find_entity(entity.name, entity.position)))
Note, this one does return the entiy and not nil.

Code: Select all

local entity = surface.create_entity{name="character-corpse", position={0,0}} 
local o = entity.position 
game.print(type(surface.find_entities_filtered{area={{o.x-1,o.y-1},{o.x+1,o.y+1}},name='character-corpse'}[1])
Just a quality of life thing: could on_player_died event include the corpse entity so that this function does not need to be ran.

Re: [0.16.30] Character Corpse Position Issue

Posted: Fri Mar 16, 2018 4:30 pm
by Valansch
I found that find_entity doesnt work for any entity that doesnt have a hitbox. I tested it with:
  • defender
    destroyer
    distractor
    construction-robot
    acid-splash-purple
    behemoth-biter-corpse
    big-biter-corpse
    big-worm-corpse
    medium-biter-corpse
    medium-remnants
    medium-spitter-corpse
    medium-worm-corpse
    small-biter-corpse
    small-remnants
    small-spitter-corpse
    small-worm-corpse
    hidden-electric-energy-interface
    big-artillery-explosion
    big-explosion
    blood-explosion-big
    blood-explosion-huge
    blood-explosion-small
    explosion
    explosion-hit
    ground-explosion
    laser-bubble
    massive-explosion
    medium-explosion
    uranium-cannon-explosion
    uranium-cannon-shell-explosion
    water-splash
    fire-flame
    fire-flame-on-tree
    construction-robot
    straight-rail-remnants
    construction-robot
    logistic-robot

Re: [Rseding91] [0.16.30] Character Corpse Position Issue

Posted: Fri Mar 16, 2018 4:41 pm
by Rseding91
Thanks for the report. I've changed it so find_entity will match either the entity.position == position or entity.bounding_box.contains(position) for the next version of 0.16.