Tarax the Terrible wrote:Loving your work.
Curious about something for a Cmud implementation.
Saw in the script you are using
Code: Select all
return end local x, y = tonumber(gmcp.room.info.x), tonumber(gmcp.room.info.y)
Does this have a map width and length?
Cus thats what you use to split it up.
Code: Select all
split(map, "\n") local myline = replace_char(x+1,maplines[y+1], "X") maplines[y+1] etc
Not on cMud or id just check instead of asking.
ty
Hi Tarax,
Hmm. the x and y values are the position that the charater is in on the map. Since the map sent through GMCP is a multiline string, I split the string into an array of strings everytime there is a newline ("\n"). Using maplines[y] returns the string of the row of the map that my character is located. After that, I use the replace the x-th character (which is usually an "o" on genesis maps) with a red "X" to make it easy to see where you are on the map... Look at the example I took from Greenhollow, below.
Code: Select all
info = {
zoomx = 19,
x = 60,
id = "PTwHB0",
short = "in southern Greenhollow near the Adventurer's Guild",
zoomy = 22,
exits = {
"west",
"north",
"east",
"south"
},
doors = {
},
y = 14
},
map = {
map = [[
__________
.' ________/ ` . _____
/ /. `. ` . / / `.
.-./ `. `. / .-----. `.___
/ `. `. `. // / `. / \ /\
/ \\\ `. /========`.// /----------`./ / / \
/=========`./\_________\/ \ \\\ \ / / /
\ . \ / /\__________\/ / /
Library \___\|\___\/ The Inn /______________/ /
__ | \ == == \ /
// `. | \____\\\\\_____\/
// /\ | Adventurer's |
__// /_/ | Guild |
/ // / /\ | |
/_// /__/\/-- -- -- -- o -- -- -- -- -- -- -- -- -- -- o -- -- -- -- --
\/ `. /\__\/ | |
/ `./ / | ============= |
\______\/ | Village of |
_______|__ Greenhollow |
/_________/|\ (south side) o
\_________\| | ============= |
Tavern |__|\_\____\| |
\__|
]],
In this case, x = 60 and y = 19. Now, if we split the map string by easy new line, then we get an array that looks like:
Code: Select all
{
" __________",
" .' ________/ ` . _____",
" / /. `. ` . / / `.",
" .-./ `. `. / .-----. `.___",
" / `. `. `. // / `. / \\ /\\",
" / \\\\\\ `. /========`.// /----------`./ / / \\",
" /=========`./\\_________\\/ \\ \\\\\\ \\ / / /",
" \\ . \\ / /\\__________\\/ / /",
" Library \\___\\|\\___\\/ The Inn /______________/ /",
" __ | \\ == == \\ /",
" // `. | \\____\\\\\\\\\\_____\\/",
" // /\\ | Adventurer's |",
" __// /_/ | Guild |",
" / // / /\\ | |",
" /_// /__/\\/-- -- -- -- o -- -- -- -- -- -- -- -- -- -- o -- -- -- -- -- ",
" \\/ `. /\\__\\/ | |",
" / `./ / | ============= |",
" \\______\\/ | Village of |",
" _______|__ Greenhollow |",
" /_________/|\\ (south side) o",
" \\_________\\| | ============= |",
" Tavern |__|\\_\\____\\| |",
" \\__| "
}
Since we know that our y position is 19 (where the smallest y is 0) I take the line at y+1=20 because LUA arrays are NOT 0 based (so if cMud arrays are 0 based. you do not need to add 1 to y), which returns the following line:
Code: Select all
" /_// /__/\\/-- -- -- -- o -- -- -- -- -- -- -- -- -- -- o -- -- -- -- --
Again, since mudlet has 1 based arrays, I add one to the value of x again so that character 61 (which is a "o") in this case, is replace with an "X". Then, I simply append all the lines back together, and print it to a miniconsole. I do not own a copy of cMud, and there is not a version of it that runs on linux natively (which is my main operating system), so I can't assist you with cMud specific code, but I can help you with any algorithm specific questions you have.