Map Data Extractor

by DarkCampainger
Extract only the relevant bits of data from your project for your mappers [More]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://DarkCampainger.MapDataExtractor##version=0

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:


Version Initial Release
Date added: Jul 1 2012
Last updated: Jul 2 2012
8 fans
If you want to allow others to make maps for your game, but don't have a custom map editor, you might be tempted to give them the entire source code. However, a mapper only needs a small subset of your code to create maps for your game: the basic visual data of your mappable turfs, objs, and mobs.

This library allows you to extract all of the data for your mappable atoms and create a separate project just for your mappers in as little as a single line of code:

var/MapDataExtractor/mde = new/MapDataExtractor()

The default settings will analyze your project to automatically extract any atoms that have been used in included map files, and will exclude any types listed in the project's Object Tree Hidden Paths preference. You can also specify your own list of types to include and/or exclude.

The generated project contains only a single DM code file--which holds just the visual data of the included atoms--and a precompiled RSC file.

// //
// VERSION 1.0 //
// //
// BY //
// //
// //
// > Extract mapping data and generate mapping project
var/MapDataExtractor/mde = new/MapDataExtractor(whitelist, blacklist, projectName)
// > Arguments:
// - whitelist: List of atom paths to include in generated map data.
// (children of the supplied paths ARE also included)
// If null, parse included map files for paths.
// (children of the located paths are NOT included)
// If list passed but first entry is null, parse included
// map files for paths and append to end of list.
// - blacklist: List of atom paths to exclude from generated map data.
// (children of the supplied paths ARE also excluded)
// If null, parse project preferences for 'HIDDENPATHS' paths.
// (children of the located paths ARE also excluded)
// If list passed but first entry is null, parse project
// preferences for hidden paths and append to end of list.
// - projectName: Text to use as the name for the generated project / directory
// (Do *NOT* set to an existing folder, as it will be DELETED!)
// > Action:
// Remove any paths from whitelist that are in blacklist. Extract the visual data
// for the remaining paths and their parent paths. In the [projectName]
// directory: generate a DM code file containing the visual data, create a
// DME environment file, and copy over the existing RSC file.

Update History:

Version 1.0 (July 3rd, 2012)

Initial release


Kisioj: (Apr 18 2013, 1:44 pm)
Ah, I'm sorry. Look's like I've been mistaken. I had map with one turf on top of another and it didn't work, but when I deleted one of them, it started working. I assumed MDE doesn't work when there are two turfs in the same location.
Just investigated your library again and I know circumstances when it won't work. For example try to place this mob on your demo's map:


If you do this, your library won't ever finish and will just stop at line:
var/datum/D = new path(lab) //GenerateGraph(list/includeList) proc

As a result, MDE_Map_Project folder and the new .dm file won't be ever created.
DarkCampainger: (Apr 18 2013, 5:43 am)
Kisioj wrote:
doesn't work if you have 2 turfs in the same location

Hi Kisioj, can you elaborate? Do you mean that if you place one turf on top of another, the lower turf isn't extracted? I just tested it, and it seems to work properly, so if you could give me more details I would appreciate it.

One workaround would be to specifically tell MDE about that turf type so it can include it. You can both scan the map and manually specify types by passing a list with a null element first, followed by whatever types you want to manually include:
var/MapDataExtractor/mde = new/MapDataExtractor(whitelist = list(null, /turf/OtherType, /turf/AnotherType))

The included has some more information.
Kisioj: (Apr 17 2013, 11:58 pm)
doesn't work if you have 2 turfs in the same location
DarkCampainger: (Sep 1 2012, 12:38 pm)
Do you mean something like:
parent_type = /obj
icon = 'LawnChair.dmi'

Thanks for pointing it out, it slipped my mind. I can add support for it, but it might be awhile before I get around to it.

If you want to do it yourself, you just have to add it to the list (like you did) and define it's default value in IsDefault():
        IsDefault(list/child, list/parent, attribute)

// Special case for parent_type
if(attribute == "parent_type")
// Built-in parent_types
if( (child["type"] == /obj && child["parent_type"] == /atom/movable) \
|| (child["type"] == /mob && child["parent_type"] == /atom/movable) \
|| (child["type"] == /area && child["parent_type"] == /atom) \
|| (child["type"] == /turf && child["parent_type"] == /atom))
return 1

// Custom parent_types
if(GetPathParent("[child["type"]]") == "[child["parent_type"]]")
return 1
return 0

// ... rest of the process as-is

RageFury33: (Sep 1 2012, 11:01 am)
This seems like a very useful tool. I'll probably end up needing it in the near-future..

Though, I notice it doesn't work with special datums. I decided to go into the code and add parent_type to the list of saved vars, but that saves it for EVERYTHING.. XD
Just figured you should know..