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

Function Vector_newindex

engine/script/src/script_vmath.cpp:230–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228 }
229
230 static int Vector_newindex(lua_State *L)
231 {
232 FloatVector* v = *(FloatVector**)lua_touserdata(L, 1);
233
234 int key = luaL_checkinteger(L, 2);
235 if (key > 0 && key <= v->size)
236 {
237 v->values[key-1] = (float)luaL_checknumber(L, 3);
238 }
239 else
240 {
241 if (v->size > 0)
242 {
243 return luaL_error(L, "%s.%s only has valid indices between 1 and %d.", SCRIPT_LIB_NAME, SCRIPT_TYPE_NAME_VECTOR, v->size);
244 }
245
246 return luaL_error(L, "%s.%s has no addressable indices, size is 0.", SCRIPT_LIB_NAME, SCRIPT_TYPE_NAME_VECTOR);
247 }
248 return 0;
249 }
250
251 static int Vector_tostring(lua_State *L)
252 {

Callers

nothing calls this directly

Calls 4

lua_touserdataFunction · 0.85
luaL_checkintegerFunction · 0.85
luaL_checknumberFunction · 0.85
luaL_errorFunction · 0.85

Tested by

no test coverage detected