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

Function Stream_newindex

engine/gamesys/src/gamesys/scripts/script_buffer.cpp:873–892  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

871 }
872
873 static int Stream_newindex(lua_State* L)
874 {
875 DM_LUA_STACK_CHECK(L, 0);
876 BufferStream* stream = CheckStream(L, 1);
877 int index = luaL_checkinteger(L, 2) - 1;
878 if (index < 0 || index >= (int)(stream->m_Count * stream->m_TypeCount))
879 {
880 if (stream->m_Count > 0)
881 {
882 return DM_LUA_ERROR("%s.%s only has valid indices between 1 and %d.", SCRIPT_LIB_NAME, SCRIPT_TYPE_NAME_BUFFERSTREAM, stream->m_Count * stream->m_TypeCount);
883 }
884 return DM_LUA_ERROR("%s.%s has no addressable indices, size is 0.", SCRIPT_LIB_NAME, SCRIPT_TYPE_NAME_BUFFERSTREAM);
885 }
886
887 uint32_t count = index / stream->m_TypeCount;
888 uint32_t component = index % stream->m_TypeCount;
889 stream->m_Set(stream->m_Data, count * stream->m_Stride + component, luaL_checknumber(L, 3));
890 dmBuffer::UpdateContentVersion(stream->m_Buffer);
891 return 0;
892 }
893
894
895 // Allocates and fills up an array of ints/floats from a table at the top of the stack. It pops the table before returning.

Callers

nothing calls this directly

Calls 4

CheckStreamFunction · 0.85
luaL_checkintegerFunction · 0.85
luaL_checknumberFunction · 0.85
UpdateContentVersionFunction · 0.85

Tested by

no test coverage detected