diff -r 000000000000 -r cc66ad6b0d75 def_occupant.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/def_occupant.lua Sat Mar 27 17:43:08 2010 +0000 @@ -0,0 +1,70 @@ + +occupant = +{ + _properties = {}, + _default = function (self, e) + PSay(e.room, e.nick, " ", ""); + end, + sit = function (self, e) + self:_action("sits down"); + end, + reload = function (self, e) + local success, message = pcall(dofile, "bot.lua"); + if not success then self:_tell(string.format("Error reloading: %s", message)); end + end, + refresh = function (self, e) + classes = nil; + dofile("bot.lua"); + end, + who = function (self, e) + local p = {}; + for nick, t in pairs(self.room.people) do + table.insert(p, nick.." ("..(t.jid or "Unknown JID")..")\n"); + end + self:_tell("People in "..self.room._properties.name..":\n"..table.concat(p, ",")); + end, + allwho = function (self, e) + local p = {}; + for jid, t in pairs(people) do + table.insert(p, t.nick.." ("..jid..") in "..t.room._properties.name.."\n"); + end + PSay(e.room, e.nick, " ", "People in MOO:\n"..table.concat(p, ",")); + end, + _say = function (self, text, who) + BroadcastMessage(self.room.people, self.nick , text, who); + end, + _action = function (self, text, who) + return self:_say("/me "..text, who); + end, + _tell = function (self, text) + SendMessage(self.jid, self.occjid, text or "", "groupchat"); + end, + i = function (self, e) + local contents = {}; + local contents2 = {}; + contents = self._contents["in"]:getallobjects(); + for o, exists in pairs(contents) do + table.insert(contents2, o._properties.longname or o._properties.name or "Something"); + end + self:_tell("You are carrying: "..table.concat(contents2,", ")); + end, + jump = function (self, e) self:_action("jumps"); end +}; + + +function occupant:_processCommand(line) + person = self; + + if line:match("^%..*$") then BroadcastMessage(person.room.people, person.nick, line:match("^%.%s?(.*)$")); return nil; end + if line:match("^,.*$") then person:_action(line:match("^,%s?(.*)$")); return nil; end + action, object = commands:_parse(self, line); -- line:match("^(%a+)%s(%a+)$"); + if commands:_handle(self, action, object) == false then person:_tell(string.format("Sorry, I don't know how you can '%s'",line)); end +end + +occupant._findobject = classes.default._findobject; +occupant._get = classes.default._get; +occupant._unlink = classes.default._unlink; + +function occupant:_sendto(roomname) + MoveToRoom(self, roomname); +end