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