TMX Loader

TMX Loader

7.5k Downloads

All content packs go directly into the mod folder

Loads Tiled XML Map Files (*.tmx) into SDV.

On first launch it converts your whole Content/Maps Folder and exports it into TMXLoader/Converter/FullMapExport/ incl. Tilesheets.
Tbin & Xnb Files copied to TMXLoader/Converter/IN get converted and placed in TMXConverter/OUT after launch.

Additional Layers and new TileActions will also work in maps not imported with TMX Loader.

Json Structure of ContenPacks:

{
  "name": "Jungle Temple", // Name of your ContentPack
  "version": "1.0.0", // Version
  "author": "Ulithium Dragon", //Author
  "addMaps": // New Maps
  [  
    {
      "name": "JungleTempleExterior", // Name of the new Location 
      "file": "JungleTempleExterior.tmx", // Filename inside the ContentPacks folder
    },
    ...
  ],
  "mergeMaps": // Replace parts of Maps
  [  
    {
      "name": "Woods", // Map to merge into
  "file": "Woods.tmx", 
  "sourceArea": [0,0,12,12], // Area on your Map that you want to place (x, y, width, height)
  "position": [0,0], // Position were the new Content should be placed on the map (x, y)
      "addWarps":  // add Warps ("entryX entryY TargetLocation exitX exitY")
      [
        "7 -1 JungleTempleExterior 14 34",
      ....
      ],
     "removeWarps":  // removes existing Warps ("entryX entryY TargetLocation exitX exitY")
      [ 
        "7 -1 JungleTempleExterior 14 34",
      ....
      ]
    },
   ...
  ],
"replaceMaps": // Fully replace Maps
  [  
   {
      "name": "Woods", // Map to replace
  "file": "Woods.tmx", 
    },
   ...
  ],
  "onlyWarps": // Only change Warps
   [
    {
      "name": "BusStop", 
      "addWarps": [
        "12 8 CityBus 2 6"
      ]
    }
  ],
"scripts":["script.lua"]
}

Additional Features:

Drawing more than just the standart layers:
Add the property Draw to the layer you want to see drawn in the game, the value needs to be the layer that is it drawn after, for exp. Back if you want another Back-Layer.

Added TileActions (1.0.1), used either in the Action or TouchAction Property.
And since 1.1.0 you can also use the map property "EntryAction" which will be triggered whenever the player enters the map.

Say
 YourText
Same as Message used to work but without the " "

Say Dwarvish YourText
Same as Say but shows the text in dwarvish if the player doesn't have the translation guide.



SwitchLayers Layer1:Layer2
Switches two layers, even layers that aren't actually drawn.

SwitchLayers 
Layer1:Layer2:14:17
Switches only the specified Tile between layers x:y

SwichLayers Layer1:Layer2:1-5:5-7
Switches the specified Area between layers x1-x2:y1-y2

SwitchLayers Actions can be combined by just writting them one after the other exp: 
SwitchLayers Buildings:BuildingsOpen:4:6-9 Buildings:BuildingsOpen:9:5 Front:FrontOpen:4:6-9 AlwaysFront:AlwaysFrontOpen:4:6-9

Lock 1 380
Invokes a TileAction if the Active object is of the specified index Lock amount index
Requires further properties on the same tile:

Success Action triggered when using the right object in at least the right amount
Failure Action triggerd when using the wrong object or not enough
Default Action triggered when holding no object

Lua YourFolderName YourFunction
Invokes a function from any of your lua scripts

Lua functions must take three paramters: location, tileposition & layerid

Lua Examples
on = false
function startPC(location, tilepos, layer)
if on then
Game1.playSound("coin")
TMX.getTile(location,"Front",36, 12).TileIndex = 991
on = false
else
Game1.playSound("stardrop")
TMX.getTile(location,"Front",36, 12).TileIndex = 1153
on = true
end
end

Additionally every Action (and TouchAction) can be set conditional by adding the following properties to the same Tile:
Condition A condition either in the format of an event condition (Event preconditions) or if prefixed by PC a playerconditon (but not mixed yet)
FallbackAction triggered if the condition isn't met (optional)

Player conditions currently supported: catPerson , isMale , exhausted , hasGreenhouse , hasRustyKey , hasSkullKey , hasUnlockedSkullDoor , hasDarkTalisman , hasMagicInk , running , usingTool , usingSlingshot , bathingClothes , stardewHero , hasClubCard , canUnderstandDwarves

Conditions and PlayerConditions can be prefixed with NOT the invert them.


Actions are still very limited but will be expanded on. If you're in need of a specific TileAction you can suggest it to me on the SMAPI Discort (@Routine)

SMAPI Mods can add their own Tileactions using PyTK:
using PyTK.Types;
TileAction Say = new TileAction("Say", sayAction).register();