#RequireContext CMapEditorPlugin #Include "TextLib" as TL // Script Version 2022-12-27 Text ChangePlatformType(Text model, Text type) { declare Text newModel = model; declare Text newType = "Platform"^type; if (type == "Wall") newType = "DecoWall"; if (TL::StartsWith("Open", newModel)) newType = "Open"^type; newModel = TL::RegexReplace("^((Platform|Open)(Tech|Dirt|Grass|Ice|Plastic))|DecoWall", newModel, "G", newType); return newModel; } Text ChangeDecoType(Text model, Text type) { declare Text newModel = model; declare Text newType = type; if (type == "Grass") newType = ""; if (TL::StartsWith("DecoPlatform", newModel)) newType = "DecoPlatform"^newType; if (TL::StartsWith("DecoHill", newModel)) newType = "DecoHill"^newType; log(newType); newModel = TL::RegexReplace("^Deco(Platform|Hill)(Dirt|Ice){0,1}", newModel, "G", newType); return newModel; } Text ChangeRoadType(Text model, Text type) { declare Text newModel = model; declare Text newType = "Road"^type; if (type == "Wall") newType = "TrackWall"; newModel = TL::RegexReplace("^Road(Tech|Ice|Dirt|Bump|Water)|TrackWall", newModel, "G", newType); log(newModel); return newModel; } Text ForceLR(Text model, Text type) { return TL::RegexReplace("(Left|Right)", model, "", type); } Text ForceUD(Text model, Text type) { return TL::RegexReplace("(Up|Down)", model, "", type); } CBlockModel MirrorV(Text inModel) { declare Text model = inModel; declare Text[] UpMatch = TL::RegexMatch("Up", model, ""); declare Text[] DownMatch = TL::RegexMatch("Down", model, ""); if (UpMatch.count > 0) { model = TL::Replace(model,"Up", "Down"); return GetBlockModelFromName(model); } if (DownMatch.count > 0) { model = TL::Replace(model, "Down", "Up"); return GetBlockModelFromName(model); } return CBlockModel; } CBlockModel MirrorH(Text inModel) { declare Text model = inModel; declare Text[] LeftMatch = TL::RegexMatch("Left", model, ""); declare Text[] RightMatch = TL::RegexMatch("Right", model, ""); if (LeftMatch.count > 0) { model = TL::Replace(model,"Left", "Right"); return GetBlockModelFromName(model); } if (RightMatch.count > 0) { model = TL::Replace(model, "Right", "Left"); return GetBlockModelFromName(model); } return CBlockModel; } CBlockModel CastType(Text type, Text inModel) { declare Text model = inModel; declare Text[] matchDeco = TL::RegexMatch("^Deco(Platform|Hill)", Cursor.BlockModel.Name, ""); if (matchDeco.count > 0) { declare Text newType = TL::RegexReplace("^d", type, "", ""); model = ChangeDecoType(model, newType); return GetBlockModelFromName(model); } if (TL::StartsWith("s", type)) { declare Text newType = TL::RegexReplace("^s", type, "", ""); model = ChangePlatformType(model, newType); return GetBlockModelFromName(model); } if (TL::StartsWith("r", type)) { declare Text newType = TL::RegexReplace("^r", type, "", ""); model = ChangeRoadType(model, newType); return GetBlockModelFromName(model); } if (type == "MirrorH") { return MirrorH(model); } if (type == "MirrorV") { return MirrorV(model); } /* declare Text[] UD = ["Up", "Down"]; declare Text[] LR = ["Left", "Right"]; if (UD.exists(type)) { model = ForceUD(model, type); return GetBlockModelFromName(model); } if (LR.exists(type)) { model = ForceLR(model, type); return GetBlockModelFromName(model); } */ return CBlockModel; } Void Show(Text frame) { ManialinkPage.GetFirstChild("surface").Hide(); ManialinkPage.GetFirstChild("deco").Hide(); ManialinkPage.GetFirstChild("road").Hide(); ManialinkPage.GetFirstChild("all").Hide(); // Show the frame ManialinkPage.GetFirstChild(frame).Show(); } main() { declare CMapEditorPlugin::PlaceMode oldPlaceMode; declare Boolean process = True; LayersDefaultManialinkVersion = 3; ManialinkText = """