|
1 |
|
2 classes.default._properties = { name = "object", longname = "An object", desc = "You see nothing of interest" } |
|
3 |
|
4 function classes.default:_create(e) |
|
5 local obj = CreateObject(self, e.name); |
|
6 obj._room = e.room; |
|
7 return obj; |
|
8 end |
|
9 |
|
10 function classes.default:look (e) |
|
11 FSay(e.room, e.nick, "/me looks at "..(self._properties.prepend or "The ")..self._properties.name or "____"); |
|
12 PSay(e.room, e.nick, "", self._properties.desc); |
|
13 end |
|
14 |
|
15 function classes.default:_say(text, room) |
|
16 FSay(room or self._room, (self._properties.prepend or "The ")..self._properties.name, text); |
|
17 end |
|
18 |
|
19 function classes.default:_action(text, room) |
|
20 return self:_say("/me "..text, room); |
|
21 end |
|
22 |
|
23 function classes.default:_findobject(name, where) |
|
24 if not (self._contents and self._contents[where or "in"]) then return nil; end |
|
25 if self._properties.locked then return false; end |
|
26 return self._contents[where or "in"]:findobject(name); |
|
27 end |
|
28 |
|
29 function classes.default:_unlink(object) |
|
30 if not (self._contents and self._contents["in"]) then print("Attempt to _unlink on a non-container."); return nil; end |
|
31 if type(object) == "string" then object = self._contents["in"]:findobject(object); end |
|
32 if not object then return false; end |
|
33 if self._contents["in"]:remove(object) then |
|
34 return true; |
|
35 end |
|
36 end |
|
37 |
|
38 function classes.default:_get(i) |
|
39 if not (self._contents and self._contents["in"]) then print("Attempt for a non-container to _get"); return nil; end |
|
40 if not (i.container:_unlink(i.object)) then return false; end |
|
41 self._contents["in"]:add(i.object); |
|
42 return true; |
|
43 end |
|
44 |
|
45 classes.default["look in"] = |
|
46 function (self, e) |
|
47 local contents = {}; |
|
48 local contents2 = {}; |
|
49 if not (self._contents and self._contents["in"]) then e.person:_tell("That is not a container."); return; end |
|
50 contents = self._contents["in"]:getallobjects(); |
|
51 for o, exists in pairs(contents) do |
|
52 print("o"); |
|
53 table.insert(contents2, o._properties.longname or o._properties.name or "Something"); |
|
54 end |
|
55 e.person:_tell("You see: "..table.concat(contents2,", ")); |
|
56 end |