Hi, so I started playing around with this plugin the other day, most of this is way over my head but I'm a good swimmer so I jumped right in.
I noticed that the mapper wasn't recording the 'area' of the room and so I started tinkering with it. I noticed that ATCP provides this info, e.g. "Room.Area the Western Ithmia". So I added in the handlers in ATCP_NCJ that were missing, the handlers list on my copy looks like this now.
edit: not 'ATCP_NCJ', 'ATCP_NJG' haha. I'm guessing those are nick's initials.
handlers = {
['Auth.Request'] = got_auth_request, -- handled here
['Room.Num'] = got_room_number,
['Room.Brief'] = got_room_brief,
['Room.Exits'] = got_room_exits,
['Room.FullExits'] = got_room_fullexits,
['Room.Area'] = got_room_area,
['Room.Environment'] = got_room_environment,
['Room.Coordinates'] = got_room_coords,
['Room.Info'] = got_room_info,
['Char.Vitals'] = got_vitals,
} -- end handlers
As a result, I had to create a few functions here too..
function got_room_fullexits (s) -- eg. "n(1234),s(4321)"
BroadcastPlugin (5, s)
end -- got_room_fullexits
function got_room_environment (s) -- eg. "Forest"
BroadcastPlugin (6, s)
end -- got_room_environment
function got_room_coords (s) -- eg. "77,-7,3,0"
BroadcastPlugin (7, s)
end -- got_room_coords
function got_room_area (s) -- eg. "the Western Ithmia"
BroadcastPlugin (8, s)
end -- got_room_coords
function got_room_info (s) -- eg. "shops,postoffice"
BroadcastPlugin (9, s)
end -- got_room_info
Now, after I did this much, the mapper started recording the room info (stores for instance) and the room environments all by itself. I thought I had solved the problem, but I noticed that there was still no area recording. So I went to ATCP_MAPPER and had a look around. I noticed that there were no functions specific to the Room.Area package so I tried making one based on what the others were doing. I came up with this (I have no clue what I'm doing.)
function got_area (s)
if not current_room then
return
end -- if
local room = rooms[current_room]
-- not cached - see if in database
if not room then
room = load_room_from_database (current_room)
end -- not in cache
if room and room.area == nil then
save_area_to_database(current_room, s)
mapper.draw (current_room) -- redraw room with area
end -- need to save area
end -- got_area
and
function save_area_to_database (uid, s)
local room = rooms[uid]
local area = s
if s then
dbcheck (db:execute (string.format ([[
UPDATE rooms SET area = %s WHERE uid = %s;
]], fixsql(area), fixsql(uid)
)))
if show_database_mods then
mapper.mapprint ("Fixed room", uid, "to have area:", area)
end -- if
else
mapper.maperror ("Cannot make sense of area:", s)
end -- if
end -- save_area_to_database
It doesn't seem to be working. I was hoping someone could give me a newbie spanking and show me what I'm doing wrong.
|