objects/obj_cat.lua

Sat, 27 Mar 2010 17:43:08 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 27 Mar 2010 17:43:08 +0000
changeset 0
cc66ad6b0d75
permissions
-rw-r--r--

Initial commit (importing from old SVN repo which got lost)

0
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 -- This is an example of one way of coding a class, using the { } constructor, see the fireplace for another method
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 classes.obj_cat =
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 {
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
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." },
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 stroke = function (self, e)
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 e.person:_say("/me strokes the "..self._properties.name); -- This message is said by the person who stroked the cat
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 self:_say("/me purrs softly"); -- This message is said by 'self' which means the current object, the cat
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 end,
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 kill = function (self, e)
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 e.person:_say("/me tries to hurt the cat");
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 self:_say("/me runs away before "..e.person.nick.." can catch it");
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 self:_say("Meeooooww!!!!");
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 end,
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 hug = function (self, e)
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 e.person:_say("/me hugs the cat");
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 self:_say("/me likes "..e.person.nick);
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 end
cc66ad6b0d75 Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 }

mercurial