Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Script name: showMap
- EventHandlers: gmcp.Room.Info
- -------------------------------------------------
- -- Put your Lua functions here. --
- -- --
- -- Note that you can also use external Scripts --
- -------------------------------------------------
- function showMap()
- local function set_exit(x, y, exit, dir)
- if exit~=nil then
- map[x][y][dir] = true
- end
- end
- local function set_all_exits(roomnum, x, y)
- local exits = getRoomExits(roomnum)
- -- East, southeast, south. (current element)
- set_exit(x,y, exits["east"], "east")
- set_exit(x,y, exits["southeast"], "southeast")
- set_exit(x,y, exits["south"], "south")
- -- Northwest. (northwest element)
- if (x~=0 and y~=0) then
- set_exit(x-1,y-1, exits["northwest"], "southeast")
- end
- -- North, northeast. (north element)
- if (y~=0) then
- set_exit(x, y-1, exits["north"], "south")
- set_exit(x, y-1, exits["northeast"], "southeast_rev")
- end
- -- West, southwest. (west element)
- if (x~=0) then
- set_exit(x-1, y, exits["west"], "east")
- set_exit(x-1, y, exits["southwest"], "southeast_rev")
- end
- -- In, out.
- map[x][y].in_out = exits["in"] and true or (exits["out"] and true or false)
- map[x][y].up = exits["up"] and true or false
- map[x][y].down = exits["down"] and true or false
- end
- local function fill_map(roomnum,x,y, level)
- local xi = { 0, 1, 1, 1, 0, -1, -1, -1, 2, 2, 2, 2, 2 }
- local yi = { -1, -1, 0, 1, 1, 1, 0, -1, 2, 2, 2, 2, 2 }
- local directions = {"north", "northeast", "east", "southeast", "south", "southwest", "west", "northwest", "up", "down", "in", "out"}
- if mapped_rooms[roomnum] then
- return
- end
- if x < 0 or x >= 18 or y < 0 or y >= 14 then
- return
- end
- if current_area ~= getRoomArea(roomnum) then
- return
- end
- -- if level == 13 then
- -- return
- -- end
- mapped_rooms[roomnum] = true
- map[x][y].room = roomnum
- set_all_exits(roomnum, x, y)
- local exits = getRoomExits(roomnum)
- for num, name in ipairs(directions) do
- if exits[name] and roomExists(exits[name]) then
- local xn,yn,zn = getRoomCoordinates(exits[name])
- local xo,yo,zo = getRoomCoordinates(roomnum)
- local lengthx, lengthy = xo-xn, yn-yo
- if xi[num]~=2 and yi[num]~=2 then
- fill_map(exits[name], x - lengthx, y - lengthy, level+1)
- end
- end
- end
- end
- map = {}
- mapped_rooms = {}
- current_area = getRoomArea(gmcp.Room.Info.num)
- for i=0, 18 do
- map[i] = {}
- for j = 0, 14 do
- map[i][j] = {}
- end
- end
- fill_map(gmcp.Room.Info.num, 9, 7, 0)
- for y = 0, 14 do
- local line = ""
- for x = 0, 18 do
- if map[x][y].room then
- line = line .. "["
- if x == 9 and y == 7 then
- line = line .. "+"
- elseif map[x][y].in_out then
- line = line .. "o"
- elseif map[x][y].up and map[x][y].down then
- line = line .. "X"
- elseif map[x][y].up then
- line = line .. "^"
- elseif map[x][y].down then
- line = line .. "v"
- else
- line = line .. " "
- end
- line = line .. "]"
- else
- line = line .. " "
- end
- if map[x][y].east then
- line = line .. "-"
- else
- line = line .. " "
- end
- end
- line = line .. "\n"
- echo(line)
- line = ""
- for x = 0, 18 do
- if map[x][y].south then
- line = line .. " | "
- else
- line = line .. " "
- end
- if map[x][y].southeast and not map[x][y].southeast_rev then
- line = line .. "\\"
- elseif map[x][y].southeast and map[x][y].southeast_rev then
- line = line .. "X"
- elseif not map[x][y].southeast and map[x][y].southeast_rev then
- line = line .. "/"
- else
- line = line .. " "
- end
- end
- line = line .. "\n"
- echo(line)
- end
- --display(map)
- --centerview(7695)
- end
Add Comment
Please, Sign In to add comment