classes.obj_room =
{
_properties = {};
_create = function (self, e)
self.people = {}; self._objects = createcontainertable(); self._properties.name = e.room; self._properties.server = e.server; self.jid = e.room.."@"..e.server;
if type(tpl_rooms[e.room]) == "table" then
for k, v in pairs(tpl_rooms[e.room]) do
self[k] = v;
end
return self._init and self._init(self, e);
end
end,
_addobject = function (self, e)
if e.class then self._objects:add(e.class:_create{room = self, name = e.name, ext = e }); end
end,
_addalias = function (self, e)
for k, v in ipairs(e) do
self._objects:addalias(e[1], v);
end
end,
_enter = function (self, e)
PSay(e.room, e.nick, " ", "You have entered "..(e.room._properties.longname or e.room._properties.name or "the room"));
end,
_findobject=function (self, tag)
if not tag then return nil; end
tag = tag:match("^the (.*)$") or tag;
return self._objects:findobject(tag);
end,
look = function (self, e)
local contents = {};
local contents2 = {};
contents = self._objects:getallobjects();
for o, exists in pairs(contents) do
table.insert(contents2, o._properties.longname or o._properties.name or "Something");
end
e.person:_tell("You see in this room: "..table.concat(contents2,", "));
end,
obj = function (self, e)
local contents = {};
local contents2 = {};
contents = self._objects:getallobjects();
for o, exists in pairs(contents) do
table.insert(contents2, (o._properties.longname or o._properties.name or "Something")..(" ("..o._properties.name or "No name")..")");
end
e.person:_tell("You see in this room: \n"..table.concat(contents2,"\n"));
end,
teleport = function (self, e)
if not e.param or #(e.param) == 0 then PSay(e.room, e.nick, " ", "Teleport to where exactly?"); end
MoveToRoom(e.person, e.param);
end,
where = function (self, e)
PSay(e.room, e.nick, " ", "You are in "..e.room._properties.name);
end
}
function classes.obj_room:_unlink(o)
if not self._objects then print("Attempt to _unlink from an empty room."); return nil; end
if type(o) == "string" then o = self._objects:findobject(o); end
if (not o) or (o._properties and o._properties.static == true) then return false; end
if self._objects:remove(o) then
return true;
end
end
function classes.obj_room:_get(i)
if not self._objects then self._objects = createcontainertable(); end
if not i.container:_unlink(i.object) then return false; end
print("room _get", self._properties.name or "o");
self._objects:add(i.object);
return true;
end