MCPcopy Create free account
hub / github.com/defold/defold / Vector3_newindex

Function Vector3_newindex

engine/script/src/script_vmath.cpp:318–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

316 }
317
318 static int Vector3_newindex(lua_State *L)
319 {
320 Vector3* v = (Vector3*)lua_touserdata(L, 1);
321
322 const char* key = luaL_checkstring(L, 2);
323 if (key[0] == 'x')
324 {
325 v->setX((float) luaL_checknumber(L, 3));
326 }
327 else if (key[0] == 'y')
328 {
329 v->setY((float) luaL_checknumber(L, 3));
330 }
331 else if (key[0] == 'z')
332 {
333 v->setZ((float) luaL_checknumber(L, 3));
334 }
335 else
336 {
337 return luaL_error(L, "%s.%s only has fields x, y, z.", SCRIPT_LIB_NAME, SCRIPT_TYPE_NAME_VECTOR3);
338 }
339 return 0;
340 }
341
342 static int Vector3_add(lua_State *L)
343 {

Callers

nothing calls this directly

Calls 6

lua_touserdataFunction · 0.85
luaL_checknumberFunction · 0.85
luaL_errorFunction · 0.85
setZMethod · 0.80
setXMethod · 0.45
setYMethod · 0.45

Tested by

no test coverage detected