It seems like the "more correct" way to handle this is to check whether the
character has a zombie costume first. Catching and discarding all
exceptions doesn't always bite you in the ass later, but it doesn't have a
great track record either, and it's not really "good practice."


On Tue, May 7, 2013 at 8:16 PM, Nick Scripp <notifications@github.com>wrote:

> In src/items/consumables/tacomeat.lua:
>
> > @@ -0,0 +1,20 @@
> > +return{
> > +    name = 'tacomeat',
> > +    type = 'consumable',
> > +    MAX_ITEMS = 10,
> > +    use = function( consumable, player )
> > +        local Timer = require('vendor/timer')
> > +        local sound = require('vendor/TEsound')
> > +        for i=1,10 do
> > +            Timer.add(i, function ()
> > +                player.health = player.health - 1
> > +                sound.play('/audio/sfx/damage.ogg')
> > +            end)
> > +        end
> > +        Timer.add(10, function ()
> > +            pcall(player.character.setCostume, player.character, 'zombie')
>
> I used pcall because not every character has a 'zombie' costume.
> character:setCostume throws an error when the costume doesn't exist.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/hawkthorne/hawkthorne-journey/pull/1372/files#r4127694>
> .
>