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

Function Vector4_newindex

engine/script/src/script_vmath.cpp:479–505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

477 }
478
479 static int Vector4_newindex(lua_State *L)
480 {
481 Vector4* v = (Vector4*)lua_touserdata(L, 1);
482
483 const char* key = luaL_checkstring(L, 2);
484 if (key[0] == 'x')
485 {
486 v->setX((float) luaL_checknumber(L, 3));
487 }
488 else if (key[0] == 'y')
489 {
490 v->setY((float) luaL_checknumber(L, 3));
491 }
492 else if (key[0] == 'z')
493 {
494 v->setZ((float) luaL_checknumber(L, 3));
495 }
496 else if (key[0] == 'w')
497 {
498 v->setW((float) luaL_checknumber(L, 3));
499 }
500 else
501 {
502 return luaL_error(L, "%s.%s only has fields x, y, z, w.", SCRIPT_LIB_NAME, SCRIPT_TYPE_NAME_VECTOR4);
503 }
504 return 0;
505 }
506
507 static int Vector4_add(lua_State *L)
508 {

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected