Skip to content
ChiefOfGxBxL edited this page Jun 2, 2018 · 9 revisions

The WC3MapTranslator wiki is a reference for how to utilize the numerous translators in the library. Refer to the sidebar to read documentation on the translators

Translation

WC3MapTranslator supports translation between the WC3 file format ("war3map") and JSON files. You can convert between the two. The translators have two methods, .jsonToWar() and .warToJson() for this purpose.

For example, we can use the Regions translator to translate either way:

var result = Translator.Regions.jsonToWar(data); // for taking a JSON file and getting the WC3 data
var result2 = Translator.Regions.warToJson(data2); // for taking WC3 data and getting the JSON representation

Note that the files are not created for you automatically; this is up to you. The translators simply take one data format and generate the other.

Output of jsonToWar

{
    errors: [],
    buffer: <Buffer 00 00 00...>
}

Output of warToJson

{
    errors: [],
    json: ...
}

If you are creating a WC3 map file (jsonToWar) you'll take the buffer field from the translation result, and probably use the fs module or similar to write a file. You can then take that file and place it in a .w3x archive using a tool like MPQ Editor.

Similarly, if you're wanting the JSON format, grab the json field from the translation result. You could save it in a file, or store it in a variable in your JavaScript application and manipulate it in the same manner you would any other object in JavaScript.

The errors array is unused right now, but may in the future contain string error messages if the translator encounters any problems.

Types

When a translator requires you to provide a type, there are four choices:

  • String - a series of characters
  • Int - a whole number
  • Real - signed real number (allows positive/negative)
  • Unreal - unsigned real number, aka float (positive values only)

This is typically seen in the Object translator when you're modifying an object's field. For instance, if you want to modify Holy Light's "amount healed", you'll need to specify not only the field name and new value, but also that the type is an unreal.

Examples

Take a look at the /examples/jsonToWar and /examples/warToJson directories in the project to get working examples on how the translators are used.

Translators

World entities

Place entities like units, doodads, etc. on the map

Units (unit or item)
Doodads
Terrain
Regions
Cameras
Sounds

Object definitions

Edit objects in the object editor

Units
Items
Destructables
Doodads
Abilities
Buffs
Upgrades

Other

Miscellaneous files like imports and strings

Imports
Strings
Info

Clone this wiki locally