<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.skytemple.org/index.php?action=history&amp;feed=atom&amp;title=ROM_editing_with_Python_and_skytemple-files</id>
	<title>ROM editing with Python and skytemple-files - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.skytemple.org/index.php?action=history&amp;feed=atom&amp;title=ROM_editing_with_Python_and_skytemple-files"/>
	<link rel="alternate" type="text/html" href="https://wiki.skytemple.org/index.php?title=ROM_editing_with_Python_and_skytemple-files&amp;action=history"/>
	<updated>2026-05-17T03:54:46Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://wiki.skytemple.org/index.php?title=ROM_editing_with_Python_and_skytemple-files&amp;diff=1271&amp;oldid=prev</id>
		<title>Frostbyte: Add skytemple-files tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.skytemple.org/index.php?title=ROM_editing_with_Python_and_skytemple-files&amp;diff=1271&amp;oldid=prev"/>
		<updated>2025-09-30T16:51:45Z</updated>

		<summary type="html">&lt;p&gt;Add skytemple-files tutorial&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Stub}}&lt;br /&gt;
&lt;br /&gt;
[[SkyTemple]] is internally powered by skytemple-files, a Python library. This library can be installed independently and used to modify the assets of Explorers of Sky by writing Python code. This can be helpful to make changes that are not directly supported by SkyTemple, such as mass editing data.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
To install skytemple-files on any OS using Python 3.11 - 3.13 just run:&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
pip install skytemple-files&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Note: This only works if binary third party libraries used by skytemple-files are also published on pypi for the platform and python version you use. Otherwise pip will try to build them from source, which means you will have to build the dependencies, like Rust.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
The following script shows an example of how skytemple-files can be used to make a single change to dungeon floor data.&amp;lt;syntaxhighlight lang=&amp;quot;python3&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
from ndspy.rom import NintendoDSRom&lt;br /&gt;
from range_typed_integers import u8&lt;br /&gt;
&lt;br /&gt;
from skytemple_files.common.impl_cfg import (&lt;br /&gt;
    change_implementation_type,&lt;br /&gt;
    ImplementationType,&lt;br /&gt;
)&lt;br /&gt;
from skytemple_files.common.types.file_types import FileType&lt;br /&gt;
from skytemple_files.common.util import get_ppmdu_config_for_rom&lt;br /&gt;
&lt;br /&gt;
# 1. First you probably always want to enable native file handlers to fast Rust-based implementations&lt;br /&gt;
#    for all file types, wherever possible.&lt;br /&gt;
change_implementation_type(ImplementationType.NATIVE)&lt;br /&gt;
&lt;br /&gt;
# 2. Second you need to ROM&lt;br /&gt;
rom = NintendoDSRom.fromFile(&amp;quot;/tmp/rom.nds&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# 3. You then almost always need the ppmdu static data for the ROM &lt;br /&gt;
#    (the XML files in SkyTemple Files _resources/ppmdu_config)&lt;br /&gt;
static_data = get_ppmdu_config_for_rom(rom)&lt;br /&gt;
# 4. You then get the file you want as bytes from the ROM&lt;br /&gt;
file_raw = rom.getFileByName(&amp;quot;BALANCE/mappa_s.bin&amp;quot;)&lt;br /&gt;
# 5. Next you use FileType.&amp;lt;YOUR FILE TYPE&amp;gt; to get the file type handler and use deserialize to unpack&lt;br /&gt;
#    the bytes into a model representing the file. See `FileType` for a list of available file types.&lt;br /&gt;
#    Some file handlers need the PPMDU static data as parameter.&lt;br /&gt;
mappa = FileType.MAPPA_BIN.deserialize(file_raw)&lt;br /&gt;
# 6. You can then interact with the model. Here we change the tileset of the first floor in the dungeon floor list.&lt;br /&gt;
mappa.floor_lists[0][0].layout.tileset_id = u8(123)&lt;br /&gt;
# 7. You can then turn the model back into bytes with the handler:&lt;br /&gt;
mappa_bytes_after = FileType.MAPPA_BIN.serialize(mappa)&lt;br /&gt;
# 8. And then write that back to the ROM:&lt;br /&gt;
rom.setFileByName(&amp;quot;BALANCE/mappa_s.bin&amp;quot;, mappa_bytes_after)&lt;br /&gt;
# 9. Which you can then write to a file again:&lt;br /&gt;
rom.saveToFile(&amp;quot;/tmp/rom_out.nds&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Frostbyte</name></author>
	</entry>
</feed>