You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I made useful tool using OTBM2JSON.
Replaces item IDs on map. For people who want to convert map from one .otb to another.
constotbm2json=require("./otbm2json");// FROM_ID: TO_IDvarreplaceArray={5091: 5090,12659: 11703,}constmapData=otbm2json.read("before.otbm");letnotReplaced={};functionreplaceItem(itemid){if(!replaceArray[itemid]){notReplaced[itemid]=itemid;}returnreplaceArray[itemid] ? replaceArray[itemid] : itemid;}functionreplaceItemRecursive(item){if(item.type===otbm2json.HEADERS.OTBM_ITEM){item.id=replaceItem(item.id);if(item.content&&item.content.length){item.content.forEach(function(containerItem){replaceItemRecursive(containerItem)});}}}// Go over all nodesmapData.data.nodes.forEach(function(n){n.features.forEach(function(e){if(e.type!==otbm2json.HEADERS.OTBM_TILE_AREA){return;}e.tiles.forEach(function(tile){if(tile.type!==otbm2json.HEADERS.OTBM_TILE&&tile.type!==otbm2json.HEADERS.OTBM_HOUSETILE){return;}tile.tileid=replaceItem(tile.tileid);if(tile.items&&tile.items.length){tile.items.forEach(function(item){replaceItemRecursive(item)});}});});});// Write the output to OTBM using the libraryotbm2json.write("after.otbm",mapData);console.log(notReplaced);
The text was updated successfully, but these errors were encountered:
I made useful tool using OTBM2JSON.
Replaces item IDs on map. For people who want to convert map from one .otb to another.
The text was updated successfully, but these errors were encountered: