MCPcopy Create free account
hub / github.com/crownengine/crown / lua_save_data_write_value

Function lua_save_data_write_value

src/lua/lua_api.cpp:695–719  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

693}
694
695static 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
721static void lua_save_data_write_root_table(lua_State *L, int i, StringStream &sjson)
722{

Callers 1

Calls 9

lua_typeFunction · 0.50
lua_tonumberFunction · 0.50
luaL_errorFunction · 0.50
is_vector3Method · 0.45
is_matrix4x4Method · 0.45

Tested by

no test coverage detected