Page 29 of 45
Re: Generic Mapping Script
Posted: Wed May 23, 2018 8:19 pm
by ulysses
Jor'Mox wrote: ↑Tue May 22, 2018 10:47 pm
So, the question is, why are the debug messages not firing. So, here is a further modified version of the capture_room_info function, along with a modified event handler function.
local function capture_room_info(name, exits)
-- captures room info, and tries to move map to match
print("Capturing Room Info") -- debug
if (not vision_fail) and name and exits then
prevName = currentName
prevExits = currentExits
name = string.trim(name)
currentName = name
exits = string.gsub(string.lower(exits)," and "," ")
currentExits = (exits ~= "" and string.split(exits,"[, ]+")) or {}
print("Room Info: " .. currentName) -- debug
display(currentExits) -- debug
move_map()
elseif vision_fail then
print("Vision Failure") -- debug
move_map()
end
end
function map.eventHandler(event,...)
if event == "onPrompt" and room_detected then
print("Prompt", map.prompt.room, map.prompt.exits)
room_detected = false
capture_room_info(map.prompt.room, map.prompt.exits)
elseif event == "onMoveFail" then
table.remove(move_queue,1)
elseif event == "onVisionFail" then
vision_fail = true
room_detected = true
elseif event == "onRandomMove" then
random_move = true
move_queue = {}
elseif event == "onForcedMove" then
capture_move_cmd(arg[1],arg[2]=="true")
elseif event == "onNewRoom" then
room_detected = true
elseif event == "sysDataSendRequest" then
capture_move_cmd(arg[1])
elseif event == "sysDownloadDone" and downloading then
loadMap(getMudletHomeDir() .. "/map.dat")
downloading = false
print("Map File Loaded.")
elseif event == "sysConnectionEvent" or event == "sysInstall" then
config()
end
end
Hopefully we will get more than enough debug info from these versions of things.
Thanks, so everything looks ok actually from the captured info, i tried a very short path, just two E movements. The output says I moved two rooms east and the last room info matches with the target room. The only thing that is wrong is that the glowing here pointer on the map is pointing at the room in between the starting room and the target room.
Code: Select all
Arkham - Intersection of S. West St. & W. Church St. (city-cloudy-clear)
The sidewalks around the intersection are noticeably wide and spacious, even
forcing the street itself to narrow slightly. The extra room for pedestrians
is necessary to the presence of Miskatonic University, which stands a few
blocks to the west and encompasses several city blocks. A steady stream of
students and faculty often walk to and from the campus during the day,
enjoying the spacious walkways. West Street extends to the north and south,
while Church Street stretches off to the east and west.
[Exits: north east south west]
A small shop has been built here.
Seraph flies in.
(06:34) (2967/2967hp 2295/2295mn 2471/2474mv) Level:(158 + 2%) Prompt Arkham - Intersection of S.
West St. & W. Church St. north east south west
Capturing Room Info
Room Info: Arkham - Intersection of S. West St. & W. Church St.
{
"north",
"east",
"south",
"west"
}
Path to Arkham - West Church Street - 400 Block: e, e
e
Move: east
Invalid Direction
You proceed along Church Street.
Arkham - West Church Street - 500 Block (city-cloudy-clear)
The road is only wide enough for a single lane of traffic along this stretch,
constricted by the wide sidewalks along its sides. The vast majority of
traffic in this neighborhood consists of students and faculty traveling to and
from Miskatonic University, so the spacious sidewalks are necessary. The
campus of the university lies behind a wrought-iron fence to the south, where
a small brick building is nestled in the corner of the campus lawn. A row of
shops and offices stands on the opposite side of the street. Church Street
continues to the east and west.
A small sign hangs on the shop to the north.
[Exits: #north east west]
(Too weak) A stray dog wanders through the area.
(Too weak) A local laborer trudges slowly through the area.
Seraph flies in.
(06:42) (2967/2967hp 2295/2295mn 2471/2474mv) Level:(158 + 2%) Prompt Arkham - West Church Street
- 500 Block north east west
Capturing Room Info
Room Info: Arkham - West Church Street - 500 Block
{
"north",
"east",
"west"
}
e
Move: east
Invalid Direction
You proceed along Church Street.
Arkham - West Church Street - 400 Block (city-cloudy-clear)
The street runs through the southern half of Arkham, only a few blocks away
from the Miskatonic River to the north. The buildings on the northern side of
the street are tall, narrow structures of a colonial design, fronted by a wide
sidewalk and several tall elm trees. The southern side of the road is
occupied by the famous Miskatonic University, whose sprawling campus stretches
across several city blocks. A tall fence of wrought-iron posts surrounds the
campus, but an arched iron gate to the south always stands open, silently
inviting the curious into the brick halls of the university. Church Street
leads off to the east and west.
A small sign hangs on the shop to the north.
A large plaque is attached to the open gate to the south.
[Exits: #north east south west]
(Too weak) A local man strolls through the area casually.
Seraph flies in.
(06:43) (2967/2967hp 2295/2295mn 2468/2474mv) Level:(158 + 2%) Prompt Arkham - West Church Street
- 400 Block north east south west
Capturing Room Info
Room Info: Arkham - West Church Street - 400 Block
{
"north",
"east",
"south",
"west"
}
The eastern clouds start to get lighter.
(07:00) (2967/2967hp 2295/2295mn 2474/2474mv) Level:(158 + 2%)
So it appears your script is doing the right thing but the glowing tracker pointer thing is too slow to keep up with events?
Wod
Re: Generic Mapping Script
Posted: Wed May 23, 2018 11:14 pm
by Jor'Mox
Except it clearly is fast enough, since the other functions that send directions just as fast don't cause it any problems.
Okay, try this. Change the doSpeedWalk function so that the for loop looks like this:
for k, v in ipairs(speedWalkDir) do
send(k)
end
Maybe we were messing with the table in some way that made it angry... though I have no idea why that would matter... at ALL, since you still clearly send the right commands, and capture the right data. Failing this, it is time to dive into the next level function, move_map. Here is a debug version of the move_map function (you can safely remove all the debug stuff from the other functions at this point, so we can focus on what the move_map function is outputting).
local function move_map()
-- tries to move the map to the next room
local move = table.remove(move_queue,1)
display(move) -- debug
if move or random_move then
local exits = (currentRoom and getRoomExits(currentRoom)) or {}
display(exits) -- debug
-- check handling of custom exits here
if currentRoom then
for i = 13, #stubmap do
exits[stubmap[i]] = tonumber(getRoomUserData(currentRoom,"exit " .. stubmap[i]))
end
end
local special = (currentRoom and getSpecialExitsSwap(currentRoom)) or {}
display(special) -- debug
if move and not exits[move] and not special[move] then
print("Searching for special exits") -- debug
for k,v in pairs(special) do
if string.starts(k,move) then
move = k
break
end
end
end
if find_portal then
print("Searching for portal destination") -- debug
map.find_me(currentName,currentExits,move)
find_portal = false
elseif force_portal then
find_portal = false
print("CREATING PORTAL DESTINATION")
create_room(currentName, currentExits, nil, {getRoomCoordinates(currentRoom)})
force_portal = false
elseif move == "recall" then
print("Recalling") -- debug
set_room(get_recall())
else
print("Normal movement, showing check_room results") -- debug
display(check_room(exits[move], currentName, currentExits)) -- debug
if exits[move] and (vision_fail or check_room(exits[move], currentName, currentExits)) then
print("Moving map, normal") -- debug
set_room(exits[move])
elseif special[move] and (vision_fail or check_room(special[move], currentName, currentExits)) then
print("Moving map, special") -- debug
set_room(special[move])
elseif not vision_fail then
print("Map move failed") -- debug
if mapping and move then
print("Creating new room") -- debug
find_link(currentName, currentExits, move)
else
print("Searching for room) -- debug
map.find_me(currentName,currentExits, move)
end
end
end
vision_fail = false
end
end
Re: Generic Mapping Script
Posted: Thu May 24, 2018 6:44 am
by ulysses
Jor'Mox wrote: ↑Wed May 23, 2018 11:14 pm
Except it clearly is fast enough, since the other functions that send directions just as fast don't cause it any problems.
Ah yes, true.
Okay, try this. Change the doSpeedWalk function so that the for loop looks like this:
for k, v in ipairs(speedWalkDir) do
send(k)
end
I think you meant send(v) not send(k), anyway it made no difference to the behaviour. Actually it made it worse, as there were no delays, as we discussed.
Failing this, it is time to dive into the next level function, move_map. Here is a debug version of the move_map function (you can safely remove all the debug stuff from the other functions at this point, so we can focus on what the move_map function is outputting).
Fixing the missing quote after the print searching for room line, this code runs and fixes the problem! Well done! The tracker keeps up with the movement all the way to the end room. So what is different? If it's just debugging statements you have added then perhaps one of these has introduced a necessary delay?
Thanks!
Wod
Re: Generic Mapping Script
Posted: Thu May 24, 2018 10:17 am
by Jor'Mox
Perhaps you had a slightly out of date version of that function, and the update fixed some problem it was experiencing. Try just commenting out all of the debug lines and seeing if it still works.
Re: Generic Mapping Script
Posted: Fri May 25, 2018 3:04 pm
by Eraene
Interesting to see all of this experimenting and investigating going on!
RE: my hidden room issue, I fixed it rather simply: I just removed the actual link from the offending room, and added it as a special exit instead. The destination room still has a one way exit to it, which will reflect how the room actually is in game, and it all works fine.
From what I'm reading here, it seems like if I add a door and lock it, that would mean the mapper doesn't care whether the exit is actually there or not?
Re: Generic Mapping Script
Posted: Fri May 25, 2018 3:18 pm
by Jor'Mox
The status of the door doesn’t matter, just it’s existence. The script compares observed exits to expected exits, and any that aren’t seen that are expected are counted if a door is in place on that exit. By default, doors added are just given the closed status, rather than the locked status. But even one with an open status is fine.
Re: Generic Mapping Script
Posted: Fri May 25, 2018 6:12 pm
by ulysses
Jor'Mox wrote: ↑Thu May 24, 2018 10:17 am
Perhaps you had a slightly out of date version of that function, and the update fixed some problem it was experiencing. Try just commenting out all of the debug lines and seeing if it still works.
Very odd. I commented out all the debugging and there was no change - the tracking still works. I compared the original function with the one with the debugging and apart from the debug lines there was only whitespace difference. Hmm. Hate fixing a problem without knowing why. I will save off a copy of the script and next time there's an update to the script, I will compare with the update. it's just possible that something elsewhere got fixed, I suppose.
Thanks again for your help with this.
Now to map those pesky mazes (again).
Re: Generic Mapping Script
Posted: Fri May 25, 2018 7:15 pm
by Jor'Mox
The main area that is likely to have changed would be hard to spot if you don't know where to look. The very first for loop in the function now runs from 13 to #stubmap, and it used to run from either 11 or 9, due to prior issues with exits in the up/down and in/out directions (when I first made the script, there were no doors for any of those directions, so I handled it all via userdata). When I took that bit out, I missed a few places, which caused some problems, because some places were still looking for userdata while others were looking at the actual doors. But, frankly, yeah... sometimes problems are basically just solved via magic. Either way, I'm glad it ended up working.
Re: Generic Mapping Script
Posted: Wed May 30, 2018 12:08 am
by Vain
I am new to mudlet and the mapping script so I suspect that I am just missing something basic or thinking about it wrong. If its too basic, feel free to PM me an I can remove this post but here goes.
I was trying to modify the Generic Mapping Script to work with CircleMud and TBA Mud.
I imported the package so I have the map script (all functions in a single script) the windows manager, and I have the triggers.
I modified the triggers so I am hoping that the room name and room exits are captured. (if i only trigger by color I get both room names and exits, but I can add a check to see if the first character is [ which means its the exit line)
I am assuming that the room prompt trigger is supposed to call the add room. I added debug logic (adding say) to verify that it is triggering.
I tried to start mapping by "start mapping" and I get the famous "Start Mapping Error: No room detected! "
So I am just curious what other major piece am I forgetting to modify? Any suggestions or advice would be greatly appreciated.
Thanks in advance,
Re: Generic Mapping Script
Posted: Wed May 30, 2018 12:27 am
by Jor'Mox
To go over what is hopefully review info, to get the mapper working at at least a minimal level, your triggers need to capture two values, the room name and exits, and store them in the appropriate variables in the appropriate format, map.prompt.room and map.prompt.exits, in which the exits contain nothing but the actual exit words, spaces, commas, and the word 'and' (the commas and the 'and' are optional), and you need to raise two events, the 'onNewRoom' and 'onPrompt' events, at the appropriate times.
I typically raise the 'onNewRoom' event when my exits trigger fires, as those are pretty unique, and less likely than a room name trigger to catch something by accident. And the 'onPrompt' event should fire every time there is a prompt, but only either move the map or create a new room if an 'onNewRoom' event was raised since the last time the 'onPrompt' event was raised. Prior to the raising of the 'onPrompt' event, both of the variables NEED to have their values stored inside them, but otherwise the timing of when that happens isn't important. I recommend using the display function to check those variables before the event is raised (like this: display(map.prompt.exits) ). Once you have all of that happening properly, I recommend moving at least once (to make sure all the info is loaded into the script), and then use the 'start mapping' function along with a name to be used for that area (like this: start mapping Main City ), as you will definitely need to divide the map up into areas for your own sanity.
If you have both variables properly filled, and both events properly being raised, and you still get that error message, let me know, and we can try to debug (note that this is rather unlikely). If, on the other hand, you find you have difficulty getting one of the necessary components working, also come back here with some examples of what text you have to work with, and what trigger patterns and code you are using, and I can help you get things sorted out.