Function id (SOLVED)

Could someone please explain to me how the id object of a function work:

Gameobject Script:

planet.position(id)

Planet Lua Module:

local M = {}
M.offset_position = vmath.vector3()
M.offset_position.x = -200
M.offset_position.y = -200

function M.position(id)
   go.set_position(M.offset_position, id)
end
return M

My gameobject changes position but I don’t get my head around the id part.

1 Like

go.set_position() operates on a given object (current object if id is omitted), if you want to tell the function what other object you want to operate on, you use the id param.

id is a special variable - it’s a name of the object, e.g. “/my_gameobject” or the value returned by factory.create().

3 Likes

@sergey.lerg you mean it’s a name of object or instance (like an individual created from game object)?

Yes, the id you can pass to many of the go.* functions is the path or unique id of a game object instance or game object component.

2 Likes