Fixing a bridge with PyTK


The numbers after Your secondary layer's name is not quite the normal coordinates, instead it is TopRightX-BottomLeftX:ToprightY-BottomleftY

Should look something like this
In order to allow this to work on a custom map, it must me loaded with TMXL. You will want to create an extra layer per layer of your bridge or thing you're fixing/breaking. For example, if my bridge is on back, front and buildings, I want to create a layer similar to secondback, otherbuildings, fixfront etc. Now, onto the mapping, choose the thing you want the player to have to interact with and place a Buildings layer tiledata. Add a property called Action, set it and a string and enter the following into it
Lock <amount of item> <itemID> persist recall
Then, add another property and name it Default, and in the properties you enter
Say <whatever you want it to say if the user interacts with it>
And for if the player brings the wrong item, make a property called Failure and enter
Say <whatever you want it to say when the player gives it the wrong item or has too little of the correct item.>
Then, create a property called Lua_Bridge1 (Lua_ is required but bridge1 can be substituted) and enter the following
TMX.switchLayersAction('SwitchLayers Back:swapback:30-36:27-31', Game1.currentLocation) TMX.switchLayersAction('SwitchLayers Buildings:swapbuildings:30-36:27-31', Game1.currentLocation) TMX.switchLayersAction('SwitchLayers Front:swapfront:30-36:27-31', Game1.currentLocation)  Game1.flashAlpha = 1.0 Game1.MasterPlayer.mailReceived.Add('<nexusid>0001')
You can duplicate
TMX.switchLayersAction('SwitchLayers Back:swapback:30-36:27-31', Game1.currentLocation)
as many times as you need for the layers you will be switching.


The number after
Game1.flashAlpha = 1.0
Is the duration of the flash, in seconds. The numbers after each Switchlayersaction are the coordinates, with not normal, they're xtopleft x bottomright, y topleft y bottom right. And finally, you can add another Property called Success and enter the following into it
Lua this Bridge1
Bridge1 can be switched for whatever you called the 4th tile property.

To make the change permanent, add a cp patch that has the number at the end of the fourth tiledata as a mail condition, and make it update on location change.

An example of this would be the following
{
            "Action": "EditMap",
            "Target": "Maps/Backwoods",
            "FromFile": "assets/Maps/Backwoods.tmx",
            "ToArea": {
                "X": 8,
                "Y": 24,
                "Width": 7,
                "Height": 9
            },
            "When": {
                "HasFlag: hostPlayer": "89680001"
                    },
             "Update": "OnLocationChange",
        },