| 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 | { |
nothing calls this directly
no test coverage detected