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.
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().