Add max_waypoints setting

This commit is contained in:
Jean-Patrick Guerrero 2022-01-16 18:16:56 +01:00
parent 5e8ecf9903
commit e3941a7b71
2 changed files with 9 additions and 1 deletions

View File

@ -25,6 +25,7 @@ i3 = {
settings = { settings = {
debug_mode = false, debug_mode = false,
max_favs = 6, max_favs = 6,
max_waypoints = 30,
min_fs_version = 4, min_fs_version = 4,
item_btn_size = 1.1, item_btn_size = 1.1,
drop_bag_on_die = true, drop_bag_on_die = true,

View File

@ -174,12 +174,19 @@ local function inv_fields(player, data, fields)
return return
elseif fields.waypoint_add then 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() local pos = player:get_pos()
for _, v in ipairs(data.waypoints) do for _, v in ipairs(data.waypoints) do
if vec_eq(vec_round(pos), vec_round(str_to_pos(v.pos))) then if vec_eq(vec_round(pos), vec_round(str_to_pos(v.pos))) then
play_sound(name, "i3_cannot", 0.8) 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
end end