valid_direction = {
n = "n",
s = "s",
e = "e",
w = "w",
u = "u",
d = "d",
ne = "ne",
sw = "sw",
nw = "nw",
se = "se",
north = "n",
south = "s",
east = "e",
west = "w",
up = "u",
down = "d",
northeast = "ne",
northwest = "nw",
southeast = "se",
southwest = "sw",
['in'] = "in",
out = "out",
['sneak n'] = "sneak n",
['sneak s'] = "sneak s",
['sneak e'] = "sneak e",
['sneak w'] = "sneak w",
['sneak up'] = "sneak up",
['sneak down'] = "sneak down",
['sneak ne'] = "sneak ne",
['sneak sw'] = "sneak sw",
['sneak nw'] = "sneak nw",
['sneak se'] = "sneak se",
} -- end of valid_direction
-- -----------------------------------------------------------------
-- We have a room name and room exits
-- -----------------------------------------------------------------
function process_exits (exits_str)-- changed from process_room_desc
-- local roomname = trim (wildcards.roomname)
-- local exits_str = trim (wildcards.exits)
-- local roomdesc = trim (wildcards.roomdesc)
-- ColourNote ("white", "blue", "exits: " .. exits_str) -- debug
-- generate a "room ID" by hashing the room description and exits
uid = utils.tohex (utils.md5 (roomname .. roomdesc .. exits_str))
uid = uid:sub (1, 25)
-- break up exits into individual directions
exits = {}
for exit in string.gmatch (exits_str, "%w+") do
local ex = valid_direction [exit]
if ex then
exits [ex] = "0" -- don't know where it goes yet
end -- if
end -- for
local name = roomname
if #name > MAX_NAME_LENGTH then
name = name:sub (1, MAX_NAME_LENGTH - 3) .. "..."
end -- if too long
-- add to table if not known
if not rooms [uid] then
ColourNote ("cyan", "", "Mapper adding room " .. uid:sub (1, 8) .. ", name: " .. name)
rooms [uid] = { name = name, desc = roomdesc, exits = exits, area = MUD_NAME }
end -- if
-- save so we know current room later on
current_room = uid
-- call mapper to draw this rom
mapper.draw (uid)
-- try to work out where previous room's exit led
if expected_exit == "0" and from_room then
fix_up_exit ()
end -- exit was wrong
end -- Name_Or_Exits
function Name_Or_Exits (name, line, wildcards)
exits = string.match (line, "^Obvious Exits: (.*)")
if exits then
process_exits (exits)
end -- if
--roomname = line
--roomdesc = nil
end -- Name_Or_Exits
function Name_Desc (name, line, wildcards) -- Teef roomname and roomdesc grab
roomname = wildcards[1]
roomitems = wildcards[2]
roomdesc = string.gsub (roomitems , " You notice .+$", "n")
--roomdesc = (roomdesc or "" ) .. line .. "n"--Teef
end -- Name_Desc
-- -----------------------------------------------------------------
-- mapper 'get_room' callback - it wants to know about room uid
-- -----------------------------------------------------------------
function get_room (uid)
if not rooms [uid] then
return nil
end -- if
local room = copytable.deep (rooms [uid])
local texits = {}
for dir in pairs (room.exits) do
table.insert (texits, dir)
end -- for
table.sort (texits)
room.hovermessage = string.format (
"%stExits: %snRoom: %s",
room.name or "unknown",
table.concat (texits, ", "),
uid
)
if uid == current_room then
room.bordercolour = config.OUR_ROOM_COLOUR.colour
room.borderpenwidth = 2
end -- not in this area
return room
end -- get_room
|