I'm not a proffessional but i think because "anticipation" is a local variable the layout can't access it.
Try:
Lua Code:
lib.createAnticipation = function(self)
-- your code
self.anticipation = anticipation
end
lib.updateAnticipation = function(self, event)
if self.unit ~= "player" then return end
anticipation = self.anticipation
-- your code
end