Fix bounds-checking on marker pages

This commit is contained in:
Hugues Ross 2020-06-27 13:45:44 -04:00
parent d3ea1cc54b
commit f528ac78bd
2 changed files with 3 additions and 3 deletions

View File

@ -279,9 +279,9 @@ minetest.register_on_player_receive_fields(function(player, name, fields)
audio.play_feedback("cartographer_write", player);
show_map_formspec(map, pos.x, pos.z, player:get_player_name(), data.page);
elseif k == "prev_button" then
show_map_formspec(map, pos.x, pos.z, player:get_player_name(), data.height_mode, data.page - 1);
show_map_formspec(map, pos.x, pos.z, player:get_player_name(), data.height_mode, math.max(data.page - 1, 1));
elseif k == "next_button" then
show_map_formspec(map, pos.x, pos.z, player:get_player_name(), data.height_mode, data.page + 1);
show_map_formspec(map, pos.x, pos.z, player:get_player_name(), data.height_mode, math.min(data.page + 1, math.ceil(markers.count() / 20)));
elseif k == "height_button" then
show_map_formspec(map, pos.x, pos.z, player:get_player_name(), not data.height_mode, data.page);
elseif k == "quit" then