Page 1 of 1

LuaEntity::can_teleport(pos, surface)

Posted: Thu Jun 06, 2019 2:55 am
by Nexela
LuaEntity::can_teleport(position, surface)

Checks if the entity can be teleported to the pos/surface without actually moving the entity.

Re: LuaEntity::can_teleport(pos, surface)

Posted: Thu Jun 06, 2019 5:52 am
by Boodals
What is the use case?

Re: LuaEntity::can_teleport(pos, surface)

Posted: Thu Jun 06, 2019 11:34 pm
by Nexela
Picker dollies

I could fail a lot earlier on things that can't be teleported without having to restore everything, Mostly on stuff with fluidboxes that can't be mixed.

And this gave me another idea! it should also return true if the only thing stopping it from teleporting to that position is itself. (This should also apply to LuaEntity:teleport also)

Re: LuaEntity::can_teleport(pos, surface)

Posted: Sat Jun 08, 2019 8:23 am
by darkfrei
Can you just create same entity and destroy it?

Re: LuaEntity::can_teleport(pos, surface)

Posted: Sat Jun 08, 2019 9:40 am
by eradicator
Nexela wrote:
Thu Jun 06, 2019 11:34 pm
(This should also apply to LuaEntity:teleport also)
LuaEntity.teleport() already works fine for distances smaller than the entities bounding box. So can_teleport() wouldn't help you if you also need to know if the target position is non-colliding, because teleport doesn't care about collision.

Wouldn't it be more useful to have a LuaEntity.non_colliding_teleport() or Surface.find_non_colliding_position{ignored_entities={}}, then you can call that and if it succeeds you do whatever other special treatment the thing needs?

(Btw, i saw a funny bug in dollies on the arumba stream (one of the first three videos. Where he dollies around a PY tailings pond, but that is a compound entity so it only dollies half of it. You should not dolly anything if there's more than one entity at that position.)

Re: LuaEntity::can_teleport(pos, surface)

Posted: Sat Jun 08, 2019 5:09 pm
by Nexela
Yeah after posting and thinking it through some more it wasn't teleport that was the total issue it was can_place_entity. can_teleport would still be nice, but can_place needs the ignore entity check :P

Does nobody report bugs!!!!!!1111111one :P I'll fix the py thingie