Page 1 of 1

Attempt to call field 'teleport' (a nil value)

Posted: Wed Dec 07, 2016 1:25 am
by darkfrei
Hi all.

I'm tried to teleport some entity (literally, the copy of wooden box), but I get this error.

Code: Select all

myentity.teleport({0, 0})
Here was info, but no examples how to use it.
http://lua-api.factorio.com/0.14.21/Lua ... l.teleport

Note: Some entities may not be teleported. For instance, walls, rail signals or entities with fluid boxes won't allow teleportation and this method will always return false when used on any such entity.

Re: Attempt to call field 'teleport' (a nil value)

Posted: Wed Dec 07, 2016 11:13 am
by daniel34
Are you sure that myentity is a valid entity and not some other type?

This minimal console example works without problems in 0.14.21 and transfers a wooden chest including contents (hover over the entity with the mouse and enter):

Code: Select all

/c game.player.selected.teleport({0,0})
darkfrei wrote:literally, the copy of wooden box
Not sure what you mean by that, posting the code you used to get to myentity might help.

Re: Attempt to call field 'teleport' (a nil value)

Posted: Thu Dec 08, 2016 10:34 pm
by darkfrei
My bad, it was something like

Code: Select all

local goright = {myentity.position.x + 1/60, myentity.position.y}
myentity.teleport(goright) 
But this code works very good:

Code: Select all

local goright = {myentity.position.x + 1/60, myentity.position.y}
myentity.teleport({goright[1], goright[2]})