LuaEntity::can_teleport(pos, surface)

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
Nexela
Smart Inserter
Smart Inserter
Posts: 1822
Joined: Wed May 25, 2016 11:09 am
Contact:

LuaEntity::can_teleport(pos, surface)

Post by Nexela »

LuaEntity::can_teleport(position, surface)

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

Boodals
Fast Inserter
Fast Inserter
Posts: 129
Joined: Sun Feb 11, 2018 7:10 pm
Contact:

Re: LuaEntity::can_teleport(pos, surface)

Post by Boodals »

What is the use case?

Nexela
Smart Inserter
Smart Inserter
Posts: 1822
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: LuaEntity::can_teleport(pos, surface)

Post 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)

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2883
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: LuaEntity::can_teleport(pos, surface)

Post by darkfrei »

Can you just create same entity and destroy it?

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5201
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: LuaEntity::can_teleport(pos, surface)

Post 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.)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Nexela
Smart Inserter
Smart Inserter
Posts: 1822
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: LuaEntity::can_teleport(pos, surface)

Post 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

Post Reply

Return to “Modding interface requests”