thanks. I have since abandoned the learning mapper and am trying to adapt the Two Towers mapper..
I have trouble with duplicate rooms without vnums, so am trying to force override the mapper with some if statements and having a pre-fix in the room ID that is checked on checking 'expected_exit' prior to entering the room.
It is still work in progress but snip here..
snip:
-- -----------------------------------------------------------------
-- We have a room name and room exits
-- -----------------------------------------------------------------
function process_room_description (name, line, wildcards)
if not dups then
mapper_dups = "11"
end -- If
exits_str = trim (wildcards.exits)
-- mapper.mapprint ("(Exits: " .. exits_str .. " ).")
roomdesc = trim (wildcards.roomdesc)
-- mapper.mapprint ("(Room desc: " .. roomdesc .. " ).")
name = trim (wildcards.name)
-- mapper.mapprint ("(Name: " .. name .. " ).")
-- ColourNote ("white", "blue", "exits: " .. exits_str) -- debug
-- generate a "room ID" by hashing the room description and exits
uid = mapper_dups .. utils.tohex (utils.md5 (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
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 expected_exit then
-- dup handling
mapper_dups = string.sub(expected_exit, 1,2)
end -- If
if mapper_dups == "00" then
current_room = expected_exit
uid = expected_exit
mapper.mapprint ("force duplicate: " .. expected_exit)
else
if not rooms [uid] then
ColourNote ("cyan", "", "[" .. uid:sub (1, 8) .. "] Mapper adding room ".. uid .. ", name: " .. name)
rooms [uid] = { name = name, desc = roomdesc, exits = exits, area = MUD_NAME }
-- save so we know current room later on
current_room = uid
else
current_room = uid
room_edit_area1 ()
room_edit_name1 ()
end -- If
end -- If
-- set default dups
mapper_dups = "11"
-- call mapper to draw this room
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
-- -----------------------------------------------------------------
-- Duplicate room name and room exits
-- -----------------------------------------------------------------
function process_room_duplicate (name, line, wildcards)
mapper_dups = "00"
local name = ""
-- generate a "room ID" by hashing the room description and exits
uid = mapper_dups .. utils.tohex (utils.md5 (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
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", "", "[" .. uid:sub (1, 8) .. "] Mapper adding room ".. uid .. ", name: " .. name)
rooms [uid] = { name = name, desc = roomdesc, exits = exits, area = MUD_NAME }
else
room_edit_area1 ()
room_edit_name1 ()
end -- If
-- set default dups
mapper_dups = "11"
-- save so we know current room later on
current_room = uid
-- call mapper to draw this room
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
it runs off the following tagged trigger:
</trigger>
<trigger
custom_colour="2"
enabled="y"
lines_to_match="15"
match="^(?P<name>[^\d\n]+)\n(?P<roomdesc>(?:\S.*\n)*)?Exits:\s*(?P<exits>.*)\Z"
multi_line="y"
regexp="y"
script="process_room_description"
sequence="100"
>
</trigger>