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

Place to get help with not working mods / modding interface.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

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

Post 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.
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

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

Post 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.
quick links: log file | graphical issues | wiki
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

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

Post 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]}) 
Post Reply

Return to “Modding help”