From 241030e080c89fd18706bb27d4aa6f628005c0bb Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Mon, 1 Dec 2025 22:54:41 +0100 Subject: [PATCH] You're supposed to do it like this actually --- src/lua_voicelib.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lua_voicelib.c b/src/lua_voicelib.c index 9fd9e628d..06c4d20f4 100644 --- a/src/lua_voicelib.c +++ b/src/lua_voicelib.c @@ -100,6 +100,11 @@ static int voice_get(lua_State* L) return 1; } +static int voice_set(lua_State *L) +{ + return luaL_error(L, LUA_QL("kartvoice_t") " struct cannot be edited by Lua."); +} + static int voice_num(lua_State* L) { kartvoice_t* voice = *((kartvoice_t**)luaL_checkudata(L, 1, META_VOICE)); @@ -194,6 +199,9 @@ int LUA_VoiceLib(lua_State* L) lua_pushcfunction(L, voice_get); lua_setfield(L, -2, "__index"); + lua_pushcfunction(L, voice_set); + lua_setfield(L, -2, "__newindex"); + lua_pushcfunction(L, voice_num); lua_setfield(L, -2, "__len"); lua_pop(L, 1);