You can write a one liner that checks for a cap, if it's below certain amount it just leaves the cave (or whatever).

lua code:
if Self.Cap() < 200 then Walker.Goto("Leave") end


You'll of course need a proper label in Walker to make it work