the game crashes if I just make everything L
There could be many reasons behind the crash. It's probably one of the last unaddressable access errors in the log. I see invalid printf usage (which probably comes from `lvl_name = get_string(L, "name");`, which could've been freed somewhere) and issues with SDL (though I don't see any SDL code there).
I'm not entirely sure how to do that
Use tables. Store object-specific data in tables, which could then be stored in a global [object_id -> object_table] table. I'm rusty with my Lua API skills as well as I don't quite understand your code so I can't give the exact code for this. But I can say that it involves lua_getfield, lua_setfield, lua_getglobal and lua_setglobal, most of which were already used in your code.