
local total_xp_gained = 0 

local update_original = HUDManager.update
function HUDManager:update(...)
	local new_total_exp = managers.experience:get_xp_dissected(true, 0, true)
	if new_total_exp > total_xp_gained then
		local xp_increase = new_total_exp - total_xp_gained
		total_xp_gained = new_total_exp
		managers.hud:show_hint({
			text = comma_value(xp_increase).." EXP gained"
		})
	end
	return update_original(self, ...)
end

function comma_value(amount)
  local formatted = amount
  while true do  
    formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1.%2')
    if (k==0) then
      break
    end
  end
  return formatted
end