Page 1 of 1

LuaControl Teleport() errors when same surface provided for entities

Posted: Sat Dec 22, 2018 10:30 pm
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 1034 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)

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

Posted: Sun Dec 23, 2018 1:12 am
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.

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

Posted: Sun Dec 23, 2018 11:33 am
by Muppet9010
Could the in game error and API description be updated for that as at present that isn't apparent?