May we help if this is your school project?
Ok, so here is only the description how to do it. Create a mug object. This object needs a boolean attribute like 'filled'. If you use this mug with your barrel object, set this attribute true. The description of the mug should run a script, where you check this attribute. If true, write 'The mug is filled with rum' otherwise 'An empty mug'.
For the pirate it's best to create 2 objects, the unconscious pirate and the conscious pirat. Make the conscious pirat invisible!
If you use the filled mug on the unconscious pirate, make him invisible and the other pirat object visible.