Basic Simple Mapping Script Thread

All and any discussion and development of the Mudlet Mapper.
User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Mapping

Post by Vadi »

You can move rooms by changing their coordinates via the setRoomCoordinates() function

Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

Re: Mapping

Post by Silvine »

how does this work for a group of rooms? Do i add or subtract 1 to the axis i want to make room on? I think Chris dealt with it on his 3k script but i didn't really grasp the concept of what he was doing.

Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

Re: Mapping

Post by Silvine »

the crashes seem fine now i was on test 4b, it looks pretty great on test 5, thanks

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Mapping

Post by Vadi »

Yeah, to shift rooms about, you add or subtract the coordinates - x to move left and right, y to move up and down, z to move the room on a different level.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Mapping

Post by Heiko »

Frankly, by far the easiest and best way to layout maps is to do the map layout manually with the visual map editor. A mapper script should do the basics, i. e. add a new room object in the right area at approximate coordinates and known room exits to other already known rooms. Then you do the map layout manually with the visual map editor tools like group selection, group spread, shrink etc. in order to get a both visually pleasing and geographically optimal result. All other attemps to do this fully automatically will inherently fail, because MUDs are notoriously illogical and unrealistic with respect to their maps, because there were no maps when the areas were originally created.

Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

Re: Mapping

Post by Silvine »

Thanks, I think I will use the visual map, as the coordinate system seems very complicated.

I tried to insert this line
if roomExists(roomID) then centerview(roomID); return; end

at the start of the script so I don't keep re-adding rooms I've already visited. However when I do this and then enter a new room the visual map explodes to the whole world map instead of just the area I'm mapping. If I walk back to the room I was just in it returns to normal. If I comment the line out again this doesn't happen. Any idea's?

Another problem is when I move rooms around using the right click menu and then walk into a new room, it plots the new room back at the old coordinates, how do I update the coordinates, also the room info at the top of the mapper stays fixed at the room I just moved.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Mapping

Post by Heiko »

Looks like you have some logic problem in your script. centerview(17) will show the room with room id 17, i. e. it will show the area that has room 17 at the x,y and z coordinate of room 17 and the surrounding rooms on that particular z level. Make sure to read this first: http://wiki.mudlet.org/w/Manual:Technical_Manual#Mapper

We need to add a mapping howto, so this thread is kind of interesting with respect to what problems people run into that are not familiar with the mapper internals. Keep asking questions, but read the docs first + provide source code of your scripts if you have coding questions or post a package of your entire mapper script and server details of the MUD that you are playing if you have more complex problems.

Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

Re: Mapping

Post by Silvine »

Yes, I have read the docs but still struggling. Think I might try and start again. When I move a room with the mapper, it messes up the mapping from that point on. The Room info on the map stops updating and the new rooms plot to old coordinates. Could it be that when I move a room, the exit rooms coordinates from that room don't update as well, so when i walk into one of those exits it maps back to the exits original position. I think it might be this, but I don't have any idea how to update these from the visual mapper? Is it intended to map every room first and then move the rooms?

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Mapping

Post by Heiko »

The visual map editor works correctly. You are messing things up somewhere in your script. If you don't show your script you won't get any help.

Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

Re: Mapping

Post by Silvine »

Here is the script, its mostly the aardwolf demo one posted on these forums.
Code: [show] | [select all] lua
function onRoomInfo(event, arg)

	-- get room ID over the GMCP channel

	roomID = tonumber(gmcp.room.info.num)


	-- create new room object
	local isNewRoom = addRoom( roomID )

    local roomName = gmcp.room.info.name
	setRoomName( roomID, roomName )

	local areaName = gmcp.room.info.zone
	echo("AREA:"..areaName.."\n")
	local areas = getAreaTable();
	if areas[areaName] == nil then 
		local newAreaID = 1
		while table.contains( areas, newAreaID ) do
			newAreaID = math.random(9999999)
		end
		echo("==>NEW AREA: name="..areaName.." ID:"..newAreaID.."\n")
		areas[areaName] = newAreaID;
		setAreaName( newAreaID, areaName )
		setRoomArea( roomID, newAreaID )

	else
		echo("--> adding room to area\n" )
		setRoomArea( roomID, areas[areaName] )

	end

	-- set random sector colors
	local sectorName = gmcp.room.info.terrain
	echo("SECTOR:"..sectorName.."\n")	
	if sectorColors[sectorName] == nil then 
		local newSectorColorID = math.random(99999)+16 -- user color IDs must be >= 16 as IDs <=15 are defined as standard ANSI colors
		while table.contains( sectorColors, newSectorColorID ) do
			newSectorColorID = math.random(99999)+16
		end
		-- define a few colors for standard sectors, the rest is random colors
		if sectorName == "ocean" then setCustomEnvColor(newSectorColorID, 30, 30, 128) 
--		elseif string.find(sectorName, "trail") then setCustomEnvColor(newSectorColorID, 80, 80, 10)
--		elseif string.find(sectorName, "smallroad") then setCustomEnvColor(newSectorColorID, 60, 60, 70) 
--		elseif string.find(sectorName, "swamp") then setCustomEnvColor(newSectorColorID, 90, 90, 70) 
--		elseif string.find(sectorName, "jungle") then setCustomEnvColor(newSectorColorID, 60, 120, 60) 
--		elseif string.find(sectorName, "forest") then setCustomEnvColor(newSectorColorID, 30, 155, 30) 
		elseif sectorName == "City" then setCustomEnvColor(newSectorColorID, 60, 60, 128) 
		elseif sectorName == "Inside" then setCustomEnvColor(newSectorColorID, 50, 50, 255) 
		elseif sectorName == "Forest" then setCustomEnvColor(newSectorColorID, 0, 0, 255) 
		elseif sectorName == "Field" then setCustomEnvColor(newSectorColorID, 50, 90, 0) 
--    	elseif sectorName == "volcano" then setCustomEnvColor(newSectorColorID, 200, 0, 0)
--    	elseif sectorName == "hills" then setCustomEnvColor(newSectorColorID, 100, 100, 0)
--    	elseif sectorName == "plain" then setCustomEnvColor(newSectorColorID, 150, 150, 00)
--    	elseif sectorName == "beach" then setCustomEnvColor(newSectorColorID, 255, 255, 100)
--    	elseif sectorName == "mountain" then setCustomEnvColor(newSectorColorID, 50, 50, 80)
--    	elseif sectorName == "waterswim" then setCustomEnvColor(newSectorColorID, 50, 50, 200)
--    	elseif sectorName == "road" then setCustomEnvColor(newSectorColorID, 50, 50, 50)
		else
			-- create a random room color for this sector
			-- note that a user color must be defined before it can be used
			sectorColors[sectorName] = newSectorColorID;
			setCustomEnvColor(newSectorColorID, math.random(255), math.random(255), math.random(255) )
		end
		setRoomEnv( roomID, newSectorColorID )
	else
		-- set the sector color
		setRoomEnv( roomID, sectorColors[sectorName] )
	end
	
	local exits = gmcp.room.info.exits;
	for k,v in pairs(exits) do
		-- add neighbouring rooms
		local x,y,z = getRoomCoordinates( roomID )
		-- DIR_NORTH 1
		-- DIR_NORTHEAST 2
		-- DIR_NORTHWEST 3
		-- DIR_EAST 4
		-- DIR_WEST 5
		-- DIR_SOUTH 6
		-- DIR_SOUTHEAST 7
		-- DIR_SOUTWEST 8
		-- DIR_UP 9
		-- DIR_DOWN 10
		-- DIR_IN 11
		-- DIR_OUT 12
		local dir = 0
		if k == "n" then dir = 1; y = y + 1; end
		if k == "ne" then dir = 2; y=y+1; x=x+1; end
		if k == "nw" then dir = 3; y=y+1; x=x-1; end
		if k == "e" then dir = 4; x=x+1; end
		if k == "w" then dir = 5; x=x-1; end
		if k == "s" then dir = 6; y=y-1; end
		if k == "se" then dir = 7; y=y-1; x=x+1; end
		if k == "sw" then dir = 8; y=y-1; x=x-1; end
		if k == "u" then dir = 9; z=z+1; end
		if k == "d" then dir = 10; z=z-1; end
		echo("adding exit: "..k.." direction: "..v.."\n")
		if addRoom( v ) then 
			setRoomArea(v,0) -- mark as unknown area for unknown rooms
			setRoomCoordinates( v, x, y, z ) 
		end

		setExit(roomID, v, dir)
	end
	 
    -- render the map
	centerview(roomID)

end
When I do getAreaRooms(id) I get 28 rooms, I counted the rooms on the map, there are 28 rooms. There are no exit rooms shown on the map but I think they are getting created because when I do roomExists(3068) it says true even though the room doesn't display and I think the script gives that room some coordinates some are returned with getRoomCoordinates(3068). I think one of the properties a room needs to display is missing centerview(3068) causes the map to go funny, so the exit room doesn't display, so I don't move the exit when I move the parent room.
It may be this line
setRoomArea(v,0) -- mark as unknown area for unknown rooms
Or I could be talking complete nonsense :D
Thanks for your assistance
Last edited by Silvine on Mon Dec 17, 2012 7:50 pm, edited 1 time in total.

Post Reply