Oh ok. I can see that in two particular functions of the plugin:
1. fix_up_exit
2. room_change_exit
'Fix_up_exit' is called from the following 'got_room_number' function when we get a room number via the GMCP handler. Here, (s) is (LID.hash):
-- here when location changes, eg. : Room.Num 7476
function got_room_number (s)
-- Note ("Mapper doing: got_room_number.")
local room_number = tostring (s)
if not room_number then
return
end -- no room number
current_room = room_number
-- Note ("Mapper doing: current room is " .. current_room)
mapper.draw (tostring (room_number))
if expected_exit == "0" and from_room then
fix_up_exit ()
end -- exit was wrong
end -- got_room_number
And this is the full fix_up_exit function:
function fix_up_exit ()
local room = rooms [from_room]
dbcheck (db:execute (string.format ([[
UPDATE exits SET touid = %s WHERE fromuid = %s AND dir = %s;
]],
fixsql (current_room), -- destination room
fixsql (from_room), -- from previous room
fixsql (last_direction_moved) -- direction (eg. "n")
)))
if show_database_mods then
mapper.mapprint ("Fixed exit", last_direction_moved, "from room", from_room, "to be to", current_room)
end -- if
room.exits [last_direction_moved] = current_room
last_direction_moved = nil
from_room = nil
end -- fix_up_exit
The only other function that includes that text is room_change_exit:
function room_change_exit (room, uid)
local available = {
n = "North",
s = "South",
e = "East",
w = "West",
u = "Up",
d = "Down",
ne = "Northeast",
sw = "Southwest",
nw = "Northwest",
se = "Southeast",
nu = "nu",
su = "su",
eu = "eu",
wu = "wu",
neu = "neu",
swu = "swu",
nwu = "nwu",
seu = "seu",
nd = "nd",
sd = "sd",
ed = "ed",
wd = "wd",
ned = "ned",
swd = "swd",
nwd = "nwd",
sed = "sed",
['in'] = "In",
out = "Out",
} -- end of available
-- remove non-existent exits
for k in pairs (available) do
if room.exits [k] then
available [k] = available [k] .. " --> " .. room.exits [k]
else
available [k] = nil
end -- if not a room exit
end -- for
if next (available) == nil then
utils.msgbox ("There are no exits from this room.", "No exits!", "ok", "!", 1)
return
end -- not known
local chosen_exit = utils.listbox ("Choose exit to change destination of:", "Exits ...", available )
if not chosen_exit then
return
end
exit_destination = utils.inputbox ("Enter destination room identifier (number) for " .. available [chosen_exit], room.name, "")
if not exit_destination then
return
end -- cancelled
-- look it up
local dest_room = rooms [exit_destination]
-- not cached - see if in database
if not dest_room then
dest_room = load_room_from_database (exit_destination)
rooms [exit_destination] = dest_room -- cache for later
end -- not in cache
if not dest_room then
utils.msgbox ("Room " .. exit_destination .. " does not exist.", "Room does not exist!", "ok", "!", 1)
return
end -- if still not there
dbcheck (db:execute (string.format ([[
UPDATE exits SET touid = %s WHERE dir = %s AND fromuid = %s;
]], fixsql (exit_destination),
fixsql (chosen_exit), -- direction (eg. "n")
fixsql (uid) -- from current room
)))
if show_database_mods then
mapper.mapprint ("Modified exit", available [chosen_exit], "from room", uid, "to be to room", exit_destination, "in database.")
end -- if
-- update in-memory table
rooms [uid].exits [chosen_exit] = exit_destination
mapper.draw (tostring (current_room))
end -- room_change_exit
There's a fair bit going on between these functions that I'm not entirely sure I need.
For instance, I don't quite understand the purpose behind fix_up_exit but I would guess it's used for mapping your movement back to the room you just came from. If that's true it's not really needed as "LID.links" provides all the exit data I need. |