mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
🐛 Fix warp list crashing if no warp found
This commit is contained in:
@@ -792,29 +792,30 @@ Event.on_nth_tick(math.floor(60/config.update_smoothing), function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if closest_warp then
|
||||||
|
-- Check the dist to the closest warp
|
||||||
|
local in_range = closest_warp.warp_id == warp_ids.spawn and closest_distance < rs2 or closest_distance < r2
|
||||||
|
if was_in_range and not in_range then
|
||||||
|
PlayerInRange:set(player, nil)
|
||||||
|
elseif not was_in_range and in_range then
|
||||||
|
PlayerInRange:set(player, closest_warp.warp_id)
|
||||||
|
end
|
||||||
|
|
||||||
-- Check the dist to the closest warp
|
-- Change the enabled state of the add warp button
|
||||||
local in_range = closest_warp.warp_id == warp_ids.spawn and closest_distance < rs2 or closest_distance < r2
|
local frame = Gui.get_left_element(player, warp_list_container)
|
||||||
if was_in_range and not in_range then
|
local add_warp_element = frame.container.header.alignment[add_new_warp.name]
|
||||||
PlayerInRange:set(player, nil)
|
local old_closest_warp_name = add_warp_element.tooltip[2] or closest_warp.name
|
||||||
elseif not was_in_range and in_range then
|
local was_able_to_make_warp = add_warp_element.enabled
|
||||||
PlayerInRange:set(player, closest_warp.warp_id)
|
local can_make_warp = closest_distance > mr2
|
||||||
|
if can_make_warp and not was_able_to_make_warp then
|
||||||
|
add_warp_element.enabled = true
|
||||||
|
add_warp_element.tooltip = {'warp-list.add-tooltip'}
|
||||||
|
elseif not can_make_warp and was_able_to_make_warp or old_closest_warp_name ~= closest_warp.name then
|
||||||
|
add_warp_element.enabled = false
|
||||||
|
add_warp_element.tooltip = {'warp-list.too-close', closest_warp.name}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Change the enabled state of the add warp button
|
|
||||||
local frame = Gui.get_left_element(player, warp_list_container)
|
|
||||||
local add_warp_element = frame.container.header.alignment[add_new_warp.name]
|
|
||||||
local old_closest_warp_name = add_warp_element.tooltip[2] or closest_warp.name
|
|
||||||
local was_able_to_make_warp = add_warp_element.enabled
|
|
||||||
local can_make_warp = closest_distance > mr2
|
|
||||||
if can_make_warp and not was_able_to_make_warp then
|
|
||||||
add_warp_element.enabled = true
|
|
||||||
add_warp_element.tooltip = {'warp-list.add-tooltip'}
|
|
||||||
elseif not can_make_warp and was_able_to_make_warp or old_closest_warp_name ~= closest_warp.name then
|
|
||||||
add_warp_element.enabled = false
|
|
||||||
add_warp_element.tooltip = {'warp-list.too-close', closest_warp.name}
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user