diff --git a/_map_handler/map_saving.lua b/_map_handler/map_saving.lua index 5c0c760..6dfe5aa 100644 --- a/_map_handler/map_saving.lua +++ b/_map_handler/map_saving.lua @@ -65,7 +65,7 @@ end function skywars.save_nodes_with_inventories(arena) local maps = skywars.load_table("maps") - maps[arena.name].always_to_be_reset_nodes = {} + initialize_map_data(maps, arena) skywars.overwrite_table("maps", maps) skywars.iterate_area_nodes(arena.min_pos, arena.max_pos, function(node, node_pos) @@ -85,9 +85,7 @@ function save_node(arena, pos, node, has_inventory) local serialized_pos = minetest.serialize(pos) if not arena then return end - if not maps then maps = {} end - if not maps[arena.name] then maps[arena.name] = {} end - if not maps[arena.name].changed_nodes then maps[arena.name].changed_nodes = {} end + initialize_map_data(maps, arena) -- If this block has not been changed yet then save it. if maps[arena.name].changed_nodes[serialized_pos] == nil then @@ -97,4 +95,13 @@ function save_node(arena, pos, node, has_inventory) maps[arena.name].changed_nodes[serialized_pos] = node skywars.overwrite_table("maps", maps) end +end + + + +function initialize_map_data(maps, arena) + if not maps then maps = {} end + if not maps[arena.name] then maps[arena.name] = {} end + if not maps[arena.name].changed_nodes then maps[arena.name].changed_nodes = {} end + if not maps[arena.name].always_to_be_reset_nodes then maps[arena.name].always_to_be_reset_nodes = {} end end \ No newline at end of file diff --git a/commands.lua b/commands.lua index 93fbf1b..476b009 100644 --- a/commands.lua +++ b/commands.lua @@ -866,10 +866,14 @@ ChatCmdBuilder.new("skywars", function(cmd) -- ! DEBUG CMDS ! -- -------------------- - cmd:sub("clearmapstable", - function(sender) - skywars.overwrite_table("maps", {}) - skywars.print_msg(sender, "Maps table reset!") + cmd:sub("clearchangednodes :arena", + function(sender, arena_name) + local maps = skywars.load_table("maps") + + maps[arena_name].changed_nodes = {} + skywars.overwrite_table("maps", maps) + + skywars.print_msg(sender, arena_name .. " changed nodes table reset!") end) @@ -977,7 +981,7 @@ end, { Debug (don't use them if you don't know what you're doing): - - clearmapstable: clears the changed nodes table of each map without resetting them + - clearchangednodes : clears the changed nodes table of each map without resetting them - getpos - test reset : tests the reset system, make sure your map is properly reset before using it, 'cause it will clear the maps table first