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