MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / GetMap

Function GetMap

internal/scripting/room_func.go:591–696  ·  view source on GitHub ↗

mapRoomId - Room the map is centered on mapSize - wide or normal mapHeight - Height of the map mapWidth - Width of the map mapName - The title of the map showSecrets - Include secret exits/rooms? mapMarkers - A list of strings representing custom map markers: [roomId],[symbol],[le

(mapRoomId int, zoomLevel int, mapHeight int, mapWidth int, mapName string, showSecrets bool, mapMarkers ...string)

Source from the content-addressed store, hash-verified

589// [roomId],[symbol],[legend text]
590// 1,×,Here
591func GetMap(mapRoomId int, zoomLevel int, mapHeight int, mapWidth int, mapName string, showSecrets bool, mapMarkers ...string) string {
592 // mapRoomId - Room the map is centered on
593 // mapSize - wide or normal
594 // mapHeight - Height of the map
595 // mapWidth - Width of the map
596 // mapName - The title of the map
597 // showSecrets - Include secret exits/rooms?
598 // mapMarkers - A list of strings representing custom map markers:
599 // [roomId],[symbol],[legend text]
600 // 1,×,Here
601
602 room := rooms.LoadRoom(mapRoomId)
603 if room == nil {
604 return ""
605 }
606
607 rMapper := mapper.GetMapper(room.RoomId)
608 if rMapper == nil {
609 mudlog.Error("Map", "error", "Could not find mapper for roomId:"+strconv.Itoa(room.RoomId))
610 return "Could not find mapper for roomId:" + strconv.Itoa(room.RoomId)
611 }
612
613 c := mapper.Config{
614 ZoomLevel: zoomLevel,
615 Width: mapWidth,
616 Height: mapHeight,
617 }
618
619 if showSecrets {
620 c.UserId = -1
621 }
622
623 if len(mapMarkers) > 0 {
624 for _, overrideString := range mapMarkers {
625 parts := strings.Split(overrideString, `,`)
626 if len(parts) == 3 {
627 roomId, _ := strconv.Atoi(parts[0])
628 symbol := parts[1]
629 legend := parts[2]
630
631 if roomId > 0 && len(symbol) > 0 && len(legend) > 0 {
632 c.OverrideSymbol(roomId, []rune(symbol)[0], legend)
633 }
634 }
635 }
636 }
637
638 mapOutput := rMapper.GetLimitedMap(mapRoomId, c)
639
640 legend := mapOutput.GetLegend(keywords.GetAllLegendAliases(room.Zone))
641
642 displayLines := []string{}
643 for _, row := range mapOutput.Render {
644 var sb strings.Builder
645 for _, cell := range row {
646 if cell.Symbol == ' ' {
647 sb.WriteRune(' ')
648 continue

Callers 4

onCommandFunction · 0.85
onLoadFunction · 0.85
onCommandFunction · 0.85
onLoadFunction · 0.85

Calls 9

OverrideSymbolMethod · 0.95
LoadRoomFunction · 0.92
GetMapperFunction · 0.92
ErrorFunction · 0.92
GetAllLegendAliasesFunction · 0.92
ProcessFunction · 0.92
GetLimitedMapMethod · 0.80
GetLegendMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected