|
1 |
|
2 -- This is an example of one way of coding a class, using the { } constructor, see the fireplace for another method |
|
3 |
|
4 classes.obj_cat = |
|
5 { |
|
6 _properties = { name = "cat", longname = "a mother cat", desc = "You see at a furry object curled up in a corner. It watches comers and goers to this room as they pass." }, |
|
7 stroke = function (self, e) |
|
8 e.person:_say("/me strokes the "..self._properties.name); -- This message is said by the person who stroked the cat |
|
9 self:_say("/me purrs softly"); -- This message is said by 'self' which means the current object, the cat |
|
10 end, |
|
11 |
|
12 kill = function (self, e) |
|
13 e.person:_say("/me tries to hurt the cat"); |
|
14 self:_say("/me runs away before "..e.person.nick.." can catch it"); |
|
15 self:_say("Meeooooww!!!!"); |
|
16 end, |
|
17 |
|
18 hug = function (self, e) |
|
19 e.person:_say("/me hugs the cat"); |
|
20 self:_say("/me likes "..e.person.nick); |
|
21 end |
|
22 } |