Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add export-map script #1329

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft

Conversation

timothymtorres
Copy link

@timothymtorres timothymtorres commented Oct 21, 2024

This adds a Lua tool that exports all the tile data in a fortress map to a JSON file. It's based on export-map.lua by @mikerenfro that I rewrote. I used his repo as my starting point while I was looking for DFHack scripts to export tile data.

With this script you can select tile flags and attributes to be copied and extracted:

  • tiletype
  • shape
  • special
  • variant
  • hidden
  • light
  • subterranean
  • outside
  • aquifer
  • material
  • evilness

Depending on the options selected, the material tables will be included as KEYS to reference the number IDs. Also big shoutout to @quietust for helping me find the aquifer data.

@timothymtorres timothymtorres marked this pull request as draft November 4, 2024 23:38
Copy link
Member

@myk002 myk002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also add a line to the New Tools section of changelog.txt: https://github.com/DFHack/scripts/blob/master/changelog.txt#L29


.. dfhack-tool::
:summary: Export fortress map tile data to a JSON file
:tags: dev map
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:tags: dev map
:tags: dev

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dev tools generally do not carry any other tags to avoid confusing end users (regular players)


::

export-map [include|exclude] [<options>]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export-map [include|exclude] [<options>]
export-map
export-map (include|exclude) <options>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to better reflect that include/exclude is required when specifying options

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you move

  • export-map.lua -> devel/export-map.lua
  • docs/export-map.rst -> docs/devel/export-map.rst

to match other dev tools?

==========

.. dfhack-tool::
:summary: Export fortress map tile data to a JSON file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

short summaries need to end in a period. also, this tool should work just as well on an adventure map, so there's no need to restrict it to fortress maps

Comment on lines +11 to +12
Exports the fortress map tile data to a JSON file. (does not include items,
characters, buildings, etc.) Depending on options enabled, there will be a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Exports the fortress map tile data to a JSON file. (does not include items,
characters, buildings, etc.) Depending on options enabled, there will be a
Exports the fortress map tile data to a JSON file. The export does not include items,
characters, buildings, etc. Depending on options enabled, there will be a

--------

``export-map``
Exports the fortress map to JSON with ALL data included
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below: Exports -> Export. These are descriptions of what the command represents, not a description of what happens. Also, please end these sentences in a period.

Comment on lines +37 to +46
Required
--------

When you are using options, you must include one of these settings.

``include``
Include only the data listed from options to the JSON (whitelist)

``exclude``
Exclude only the data listed from options to the JSON (blacklist)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the update to the Usage section, you can remove this section

Comment on lines +51 to +53
``help``, ``--help``
Shows the help menu

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we generally don't document "help" options since the canonical way to get help is help devel/export-map

checks the value of the center map tile at ground level and will ignore
biomes at the edges of the map.

JSON DATA
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the client requirements that led to this output format? The choices made here seem strange to me, and I could use some context.

Comment on lines +8 to +9
WARNING - This command will cause the game to freeze for minutes depending on
map size and options enabled.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the runtime for large maps is untenable, it probably would not be too hard to move the property scanning logic a Lua-accessible function of probe and just use Lua for the output formatting (which is a pain to do in C++).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants