LuaControl Teleport() errors when same surface provided for entities

Bugs that are actually features.
Post Reply
User avatar
Muppet9010
Filter Inserter
Filter Inserter
Posts: 278
Joined: Sat Dec 09, 2017 6:01 pm
Contact:

LuaControl Teleport() errors when same surface provided for entities

Post by Muppet9010 »

When using the LuaControl.Teleport() function on an entity (ie: car) and the current surface is provided it returns a custom Factorio error message:
error.GIF
error.GIF (35 KiB) Viewed 720 times
However, if no surface is specified there is no error and the command runs correctly. The surface argument is optional in the documentation.

Also the error message itself doesn't match up with working usage and what the API documentation says.

API function link:
https://lua-api.factorio.com/latest/Lua ... l.teleport

Sample erroring code:

Code: Select all

/c
local surface = game.player.surface
local startPos = {x = 1, y = 1}
local treeEntity = surface.create_entity{name="car", position = startPos}
local newPos = {x = 2, y = 2}
treeEntity.teleport(newPos, surface)
Sample working code (same intended result):

Code: Select all

/c
local surface = game.player.surface
local startPos = {x = 1, y = 1}
local treeEntity = surface.create_entity{name="car", position = startPos}
local newPos = {x = 2, y = 2}
treeEntity.teleport(newPos)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaControl Teleport() errors when same surface provided for entities

Post by Rseding91 »

Thanks for the report however that's working as intended. You can't specify the surface for anything except players. For players, it's an optional argument.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Muppet9010
Filter Inserter
Filter Inserter
Posts: 278
Joined: Sat Dec 09, 2017 6:01 pm
Contact:

Re: LuaControl Teleport() errors when same surface provided for entities

Post by Muppet9010 »

Could the in game error and API description be updated for that as at present that isn't apparent?

Post Reply

Return to “Not a bug”