-
Notifications
You must be signed in to change notification settings - Fork 4
LeafEdit Scripts
There is something, which isn't implemented inside LeafEdit yet but you know the offset already? Then scripts are the best option for the time!
Scripts can do the following stuff...
- Edit bytes of your Save. (supported: uint8_t, uint16_t, uint32_t, EncryptedInt32, for loop writes of the same uint8_t value)
- Dump & Inject specific parts from / into your savefile.
You will need the following part on every script:
{
"scriptInfo": {
"title": "<Your Title>",
"author": "<Your Name>",
"description": "<Your Description>",
"version": 1,
"revision": 1
},Here are explanations about each thing:
- "scriptInfo" specifies that it's the script's info section. It includes informations about the script itself.
- "title" is the title of the script. It will be displayed on the top bar of LeafEdit.
- "author" is the name of the creator(s) from the script.
- "description" is a little description about what the script does for other people.
- "version" is the version which LeafEdit uses to detect, if the script is compatible. It is 1 as of v0.2.1.
- "revision" is the revision of the script, when created, set it to 1. Increase it, whenever a change has been made.
The script would be invalid in that case though, because it does not include any entries yet and the syntax is invalid. Here's what you need now:
"scriptContent": [{
"info": {
"title": "<Entry Title>",
"description": "<Small entry description>",
"savetypes": ["WW", "NL", "WA", "HHD"],
"regions": ["EUR", "USA", "JPN", "KOR"]
},Here are explanations about each thing:
- "scriptContent" is what we need, to say.. AHA! here begin our entries.
- "info" is needed to say.. AHA! here begin's our info part for the first entry.
- "title" is the title about the entry. Name it like "My Test Entry" or something like that.
- "description" is the small description about the entry.
- "savetypes" NEEDS to be an ARRAY, it can look like the following above. More about it in the "savetypes" section later below.
- "regions" NEEDS to be an ARRAY as well, it can look like the following above. It is only needed, when the entry is for Wild World.
But that's not an invalid script either! That's what you need as well:
"script": [{
"type": "WriteU8",
"offset": "0x00C",
"data": "0x1"
}]
}]
}Here are explanations about each thing:
- "script" is what we need to say.. AHA! here starts our actual script.
- "type" tells LeafEdit, which function it should use.
The following part does depend on the script function. Those are the parameters, which are needed to properly tell LeafEdit, what to use for the script. More about each function more below later!
If you combine all of these parts, then you'd have your first valid script.. it could look like this:
{
"scriptInfo": {
"title": "Testing Stuff.",
"author": "LeafEdit-Tester",
"description": "Script example.",
"version": 1,
"revision": 1
},
"scriptContent": [{
"info": {
"title": "Test Entry.",
"description": "Writing 0x1 to offset 0x00C",
"savetypes": ["WW"],
"regions": ["EUR", "USA"]
},
"script": [{
"type": "WriteU8",
"offset": "0x00C",
"data": "0x1"
}]
}]
}If you have 2+ Entries, then it should look like this:
{
"scriptInfo": {
"title": "Testing Stuff.",
"author": "LeafEdit-Tester",
"description": "Script example.",
"version": 1,
"revision": 1
},
"scriptContent": [{
"info": {
"title": "Test Entry.",
"description": "Writing 0x1 to offset 0x00C",
"savetypes": ["WW"],
"regions": ["EUR", "USA"]
},
"script": [{
"type": "WriteU8",
"offset": "0x00C",
"data": "0x1"
}]
},
{
"info": {
"title": "Test Entry 2.",
"description": "Writing 0x2 to offset 0x00C",
"savetypes": ["WW"],
"regions": ["EUR", "USA"]
},
"script": [{
"type": "WriteU8",
"offset": "0x00C",
"data": "0x2"
}]
}]
}Basically.. instead of doing }] at the last one, you'll do }, then { and the "info" part begins again.
If you have multiple needed writes, then you need to remove the ] from the first one at the end, add a , at }, then add a { and then do the next "type" etc.
Like you already saw, "savetypes": ["WW", "NL", "WA", "HHD"] can also only contain one entry. Basically.. you include all your supported Savetypes there. Here are explanations about each SaveType:
"WW": Wild World
"NL": New Leaf (The regular one, with garden.dat)
"WA": New Leaf Welcome amiibo (The new one, with garden_plus.dat)
"HHD": Happy Home Designer
Like you already saw, "regions": ["EUR", "USA"] can also only contain 1 or more. Basically you include all your supported regions there. (This only affects Wild World, because the regions are different). Here are explanations about each region:
"EUR": Europe
"USA": USA
"JPN": Japan
"KOR": Korean
NOTE: EUR & USA are the same, so it's recommended, to include both there.
Here you can see all script features. NOTE: For Offset, data & length, they need to be as HEX values.. so from 0-9 and A-F. You can easilly convert a decimal value to hex with google by doing <Decimal Value> to hex.
Write an uint8_t (1 byte) to the savefile.
"type": "WriteU8",
"offset": "0x200", // The offset where to write to. In that case it just modifies 0x200.
"data": "0x1" // The value which should be written. Valid: 0x0 - 0xFF.
Write an uint8_t (1 byte) value multiple times.
"type": "ForWrite",
"offset": "0x220", // The startoffset from where to write to.
"length": "0x10", // The length / size to write for.
"data": "0x1" // The value which should be written. Valid: 0x0 - 0xFF.
Write an uint16_t (2 byte) to the savefile.
"type": "WriteU16",
"offset": "0x200", // The offset where to write to. In that case it modifies 0x200 - 0x201.
"data": "0x0001" // The value which should be written. Valid: 0x0 - 0xFFFF.
Write an uint32_t (4 byte) to the savefile.
"type": "WriteU32",
"offset": "0x200", // The offset where to write to. In that case it modifies 0x200 - 0x203.
"data": "0x00000001" // The value which should be written. Valid: 0x0 - 0xFFFFFFFF
Write an EncryptedInt32 to the savefile.
EncryptedInt32 is the value format for New Leaf and Welcome Amiibo. It is basically like WriteU32, but encrypted.
"type": "WriteEncryptedInt32",
"offset": "0x200", // The offset where to write to.
"data": "0xC350" // The value which should be written. 0xC350 is 50.000 in hex format.
Write a bit to your savefile.
"type": "WriteBit",
"offset": "0x200", // The offset where to write to.
"bitIndex": 1, // The bit index. Reminder: it goes from 0 to 7.
"data": 1 // 0 and 1 are valid. it does not use hex as the only special case.
NOTE: This feature is not included in the latest LeafEdit release v0.2.1.
Dump a specific location and size from the savefile to a file.
"type": "DumpFile",
"offset": "0x200", // The start offset where to dump from.
"length": "0x10", // The length of the data.
"file": "sdmc:/3ds/LeafEdit/Test.dat" // The filepath, where to place the dumped file.
NOTE: This feature is not included in the latest LeafEdit release v0.2.1.
Inject a file's raw data to the savefile.
"type": "InjectFile",
"offset": "0x200", // The start offset where to write the dumped file to.
"file": "sdmc:/3ds/LeafEdit/Test.dat" // The filepath from the wanted file.
You need help on something, which is not explained at the wiki there? Then join our discord server here and ask for help in #animal-crossing.