| 693 | } |
| 694 | |
| 695 | static void lua_save_data_write_value(lua_State *L, int i, StringStream &sjson, u32 depth) |
| 696 | { |
| 697 | LuaStack stack(L); |
| 698 | const int type = lua_type(L, i); |
| 699 | |
| 700 | if (type == LUA_TBOOLEAN) { |
| 701 | sjson << (stack.get_bool(i) ? "true" : "false"); |
| 702 | } else if (type == LUA_TNUMBER) { |
| 703 | sjson << (f64)lua_tonumber(L, i); |
| 704 | } else if (type == LUA_TSTRING) { |
| 705 | lua_save_data_write_string(sjson, L, i); |
| 706 | } else if (type == LUA_TLIGHTUSERDATA && stack.is_vector3(i)) { |
| 707 | lua_save_data_write_vector3(sjson, "vector3", stack.get_vector3(i)); |
| 708 | } else if (type == LUA_TLIGHTUSERDATA && stack.is_matrix4x4(i)) { |
| 709 | lua_save_data_write_matrix4x4(sjson, "matrix4x4", stack.get_matrix4x4(i)); |
| 710 | } else if (stack.has_metatable(i, "Vector3Box")) { |
| 711 | lua_save_data_write_vector3(sjson, "vector3box", stack.get_vector3box(i)); |
| 712 | } else if (stack.has_metatable(i, "Matrix4x4Box")) { |
| 713 | lua_save_data_write_matrix4x4(sjson, "matrix4x4box", stack.get_matrix4x4box(i)); |
| 714 | } else if (type == LUA_TTABLE) { |
| 715 | lua_save_data_write_table(L, i, sjson, depth, false, false); |
| 716 | } else { |
| 717 | luaL_error(L, "Unsupported save data value type"); |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | static void lua_save_data_write_root_table(lua_State *L, int i, StringStream &sjson) |
| 722 | { |
no test coverage detected