From e3941a7b71ec5d1322201e0c61d150242cebd9f4 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Sun, 16 Jan 2022 18:16:56 +0100 Subject: [PATCH] Add max_waypoints setting --- init.lua | 1 + src/fields.lua | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index c9ad417..38404ad 100644 --- a/init.lua +++ b/init.lua @@ -25,6 +25,7 @@ i3 = { settings = { debug_mode = false, max_favs = 6, + max_waypoints = 30, min_fs_version = 4, item_btn_size = 1.1, drop_bag_on_die = true, diff --git a/src/fields.lua b/src/fields.lua index 6f299a3..d64e413 100644 --- a/src/fields.lua +++ b/src/fields.lua @@ -174,12 +174,19 @@ local function inv_fields(player, data, fields) return elseif fields.waypoint_add then + local max_waypoints = i3.settings.max_waypoints + + if #data.waypoints >= max_waypoints then + play_sound(name, "i3_cannot", 0.8) + return msg(name, fmt("Waypoints limit reached (%u)", max_waypoints)) + end + local pos = player:get_pos() for _, v in ipairs(data.waypoints) do if vec_eq(vec_round(pos), vec_round(str_to_pos(v.pos))) then play_sound(name, "i3_cannot", 0.8) - return msg(name, "You already set a waypoint at this position") + return msg(name, S"You already set a waypoint at this position") end end