Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Скрипт для OpenComputers, для создания точек JourneyMap
- --Автор: aka_zaratustra осень 2020
- local ver = "1.5" -- версия программы
- local computer = require("computer")
- local component = require("component")
- local controller = component.inventory_controller
- --local json = require("json")
- local dim = "-9999" --дименшн в котором юзали проспектор
- --таблица с найденными рудами
- local oreX = {}
- local oreZ = {}
- local oreDim = {}
- local oreName = {}
- local veinName = {}
- local oreIndex = 0 --количество найденных записей о рудах
- --таблица с найденными жидкостями
- local oilX = {}
- local oilZ = {}
- local oilDim = {}
- local oilName = {}
- local oilSegmentNum = {} -- номер сегмента жижи в споте от 1 до 9
- local oilIndex = 0 --количество найденных записей о жижах
- fileLog=io.open("log.txt","w")
- --словарь руд
- local dict = {
- --overworld
- {OreName = "Graphite", veinName = "Graphite", dim = "0"},
- {OreName = "Diamond", veinName = "Graphite", dim = "0"},
- {OreName = "Redstone", veinName = "Redstone", dim = "0"},
- {OreName = "Ruby", veinName = "Redstone", dim = "0"},
- {OreName = "Cinnabar", veinName = "Redstone", dim = "0"},
- {OreName = "Pyrite", veinName = "Chalcopyrite (Low)", dim = "0"},
- {OreName = "Copper", veinName = "Chalcopyrite (Low)", dim = "0"},
- {OreName = "Brown Limonite", veinName = "Limonite", dim = "0"},
- {OreName = "Yellow Limonite", veinName = "Limonite", dim = "0"},
- {OreName = "Banded Iron", veinName = "Limonite", dim = "0"},
- {OreName = "Malachite", veinName = "Limonite", dim = "0"},
- {OreName = "Grossular", veinName = "Grossular", dim = "0"},
- {OreName = "Spessartine", veinName = "Grossular", dim = "0"},
- {OreName = "Pyrolusite", veinName = "Grossular", dim = "0"},
- {OreName = "Tantalite", veinName = "Grossular", dim = "0"},
- {OreName = "Kyanite", veinName = "Kyanite", dim = "0"},
- {OreName = "Mica", veinName = "Kyanite", dim = "0"},
- {OreName = "Pollucite", veinName = "Kyanite", dim = "0"},
- {OreName = "Lazurite", veinName = "Lazurite", dim = "0"},
- {OreName = "Sodalite", veinName = "Lazurite", dim = "0"},
- {OreName = "Lapis", veinName = "Lazurite", dim = "0"},
- {OreName = "Calcite", veinName = "Lazurite", dim = "0"},
- {OreName = "Soapstone", veinName = "Soapstone", dim = "0"},
- {OreName = "Talc", veinName = "Soapstone", dim = "0"},
- {OreName = "Glauconite", veinName = "Soapstone", dim = "0"},
- {OreName = "Pentlandite", veinName = "Soapstone", dim = "0"},
- {OreName = "Magnetite", veinName = "Magnetite", dim = "0"},
- {OreName = "Vanadium Magnetite", veinName = "Magnetite", dim = "0"},
- {OreName = "Gold", veinName = "Magnetite", dim = "0"},
- {OreName = "Lignite Coal", veinName = "Coal", dim = "0"},
- {OreName = "Apatite", veinName = "Apatite", dim = "0"},
- {OreName = "Tricalcium Phosphate", veinName = "Apatite", dim = "0"},
- {OreName = "Pyrochlore", veinName = "Apatite", dim = "0"},
- {OreName = "Cassiterite Sand", veinName = "Cassiterite", dim = "0"},
- {OreName = "Garnet Sand", veinName = "Cassiterite", dim = "0"},
- {OreName = "Asbestos", veinName = "Cassiterite", dim = "0"},
- {OreName = "Diatomite", veinName = "Cassiterite", dim = "0"},
- {OreName = "Basaltic Mineral Sand", veinName = "Basaltic Mineral", dim = "0"},
- {OreName = "Granitic Mineral Sand", veinName = "Basaltic Mineral", dim = "0"},
- {OreName = "Gypsum", veinName = "Basaltic Mineral", dim = "0"},
- {OreName = "Kaolinite", veinName = "Kaolinite", dim = "0"},
- {OreName = "Zeolite", veinName = "Kaolinite", dim = "0"},
- {OreName = "Glauconite Sand", veinName = "Kaolinite", dim = "0"},
- {OreName = "Rock Salt", veinName = "Rock Salt", dim = "0"},
- {OreName = "Salt", veinName = "Rock Salt", dim = "0"},
- {OreName = "Lepidolite", veinName = "Rock Salt", dim = "0"},
- {OreName = "Spodumene", veinName = "Rock Salt", dim = "0"},
- {OreName = "Oilsands", veinName = "Oilsands", dim = "0"},
- {OreName = "Tin", veinName = "Tin", dim = "0"},
- {OreName = "Vermiculite", veinName = "Chalcopyrite (High)", dim = "0"},
- {OreName = "Alunite", veinName = "Chalcopyrite (High)", dim = "0"},
- {OreName = "Dolomite", veinName = "Dolomite", dim = "0"},
- {OreName = "Wollastonite", veinName = "Dolomite", dim = "0"},
- {OreName = "Trona", veinName = "Dolomite", dim = "0"},
- {OreName = "Andradite", veinName = "Dolomite", dim = "0"},
- --nether
- {OreName = "Redstone", veinName = "Redstone", dim = "-1"},
- {OreName = "Ruby", veinName = "Redstone", dim = "-1"},
- {OreName = "Cinnabar", veinName = "Redstone", dim = "-1"},
- {OreName = "Chalcopyrite", veinName = "Chalcopyrite (Low)", dim = "-1"},
- {OreName = "Iron", veinName = "Chalcopyrite (Low)", dim = "-1"},
- {OreName = "Brown Limonite", veinName = "Limonite", dim = "-1"},
- {OreName = "Yellow Limonite", veinName = "Limonite", dim = "-1"},
- {OreName = "Banded Iron", veinName = "Limonite", dim = "-1"},
- {OreName = "Malachite", veinName = "Limonite", dim = "-1"},
- {OreName = "Grossular", veinName = "Grossular", dim = "-1"},
- {OreName = "Spessartine", veinName = "Grossular", dim = "-1"},
- {OreName = "Pyrolusite", veinName = "Grossular", dim = "-1"},
- {OreName = "Tantalite", veinName = "Grossular", dim = "-1"},
- {OreName = "Sulfur", veinName = "Sulfur", dim = "-1"},
- {OreName = "Sphalerite", veinName = "Sulfur", dim = "-1"},
- {OreName = "Beryllium", veinName = "Beryllium", dim = "-1"},
- {OreName = "Emerald", veinName = "Beryllium", dim = "-1"},
- {OreName = "Thorium", veinName = "Beryllium", dim = "-1"},
- {OreName = "Saltpeter", veinName = "Saltpeter", dim = "-1"},
- {OreName = "Diatomite", veinName = "Saltpeter", dim = "-1"},
- {OreName = "Electrotine", veinName = "Saltpeter", dim = "-1"},
- {OreName = "Alunite", veinName = "Saltpeter", dim = "-1"},
- {OreName = "Wulfenite", veinName = "Wulfenite", dim = "-1"},
- {OreName = "Molybdenite", veinName = "Wulfenite", dim = "-1"},
- {OreName = "Molybdenum", veinName = "Wulfenite", dim = "-1"},
- {OreName = "Powellite", veinName = "Wulfenite", dim = "-1"},
- {OreName = "Quartzite", veinName = "Certus Quartz", dim = "-1"},
- {OreName = "Barite", veinName = "Certus Quartz", dim = "-1"},
- {OreName = "Certus Quartz", veinName = "Certus Quartz", dim = "-1"},
- {OreName = "Tetrahedrite", veinName = "Tetrahedrite", dim = "-1"},
- {OreName = "Stibnite", veinName = "Tetrahedrite", dim = "-1"},
- --twilight
- {OreName = "Graphite", veinName = "Graphite", dim = "7"},
- {OreName = "Diamond", veinName = "Graphite", dim = "7"},
- {OreName = "Brown Limonite", veinName = "Limonite", dim = "7"},
- {OreName = "Yellow Limonite", veinName = "Limonite", dim = "7"},
- {OreName = "Banded Iron", veinName = "Limonite", dim = "7"},
- {OreName = "Malachite", veinName = "Limonite", dim = "7"},
- {OreName = "Lazurite", veinName = "Lazurite", dim = "7"},
- {OreName = "Sodalite", veinName = "Lazurite", dim = "7"},
- {OreName = "Lapis", veinName = "Lazurite", dim = "7"},
- {OreName = "Calcite", veinName = "Lazurite", dim = "7"},
- {OreName = "Soapstone", veinName = "Soapstone", dim = "7"},
- {OreName = "Talc", veinName = "Soapstone", dim = "7"},
- {OreName = "Magnetite", veinName = "Magnetite", dim = "7"},
- {OreName = "Vanadium Magnetite", veinName = "Magnetite", dim = "7"},
- {OreName = "Gold", veinName = "Magnetite", dim = "7"},
- {OreName = "Lignite Coal", veinName = "Coal", dim = "7"},
- {OreName = "Coal", veinName = "Coal", dim = "7"},
- {OreName = "Apatite", veinName = "Apatite", dim = "7"},
- {OreName = "Tricalcium Phosphate", veinName = "Apatite", dim = "7"},
- {OreName = "Pyrochlore", veinName = "Apatite", dim = "7"},
- {OreName = "Rock Salt", veinName = "Rock Salt", dim = "7"},
- {OreName = "Salt", veinName = "Rock Salt", dim = "7"},
- {OreName = "Lepidolite", veinName = "Rock Salt", dim = "7"},
- {OreName = "Spodumene", veinName = "Rock Salt", dim = "7"},
- {OreName = "Tin", veinName = "Tin", dim = "7"},
- {OreName = "Cassiterite", veinName = "Tin", dim = "7"},
- {OreName = "Wulfenite", veinName = "Wulfenite", dim = "7"},
- {OreName = "Molybdenite", veinName = "Wulfenite", dim = "7"},
- {OreName = "Molybdenum", veinName = "Wulfenite", dim = "7"},
- {OreName = "Powellite", veinName = "Wulfenite", dim = "7"},
- {OreName = "Perditio Infused Stone", veinName = "Perditio Infused Stone", dim = "7"},
- {OreName = "Ordo Infused Stone", veinName = "Perditio Infused Stone", dim = "7"},
- {OreName = "Terra Infused Stone", veinName = "Terra Infused Stone", dim = "7"},
- {OreName = "Aer Infused Stone", veinName = "Terra Infused Stone", dim = "7"},
- {OreName = "Aqua Infused Stone", veinName = "Aqua Infused Stone", dim = "7"},
- {OreName = "Ignis Infused Stone", veinName = "Aqua Infused Stone", dim = "7"},
- {OreName = "Galena", veinName = "Galena", dim = "7"},
- {OreName = "Silver", veinName = "Galena", dim = "7"},
- {OreName = "Lead", veinName = "Galena", dim = "7"},
- {OreName = "Almandine", veinName = "Almandine", dim = "7"},
- {OreName = "Pyrope", veinName = "Almandine", dim = "7"},
- {OreName = "Sapphire", veinName = "Almandine", dim = "7"},
- {OreName = "Green Sapphire", veinName = "Almandine", dim = "7"},
- {OreName = "Bentonite", veinName = "Bentonite", dim = "7"},
- {OreName = "Magnesite", veinName = "Bentonite", dim = "7"},
- {OreName = "Olivine", veinName = "Bentonite", dim = "7"},
- {OreName = "Garnierite", veinName = "Garnierite", dim = "7"},
- {OreName = "Nickel", veinName = "Garnierite", dim = "7"},
- {OreName = "Cobaltite", veinName = "Garnierite", dim = "7"},
- --moon
- {OreName = "Chalcopyrite", veinName = "Chalcopyrite", dim = "28"},
- {OreName = "Iron", veinName = "Chalcopyrite", dim = "28"},
- {OreName = "Pyrite", veinName = "Chalcopyrite", dim = "28"},
- {OreName = "Copper", veinName = "Chalcopyrite", dim = "28"},
- {OreName = "Tin", veinName = "Tin", dim = "28"},
- {OreName = "Cassiterite", veinName = "Tin", dim = "28"},
- {OreName = "Wulfenite", veinName = "Wulfenite", dim = "28"},
- {OreName = "Molybdenite", veinName = "Wulfenite", dim = "28"},
- {OreName = "Molybdenum", veinName = "Wulfenite", dim = "28"},
- {OreName = "Powellite", veinName = "Wulfenite", dim = "28"},
- {OreName = "Galena", veinName = "Galena", dim = "28"},
- {OreName = "Silver", veinName = "Galena", dim = "28"},
- {OreName = "Lead", veinName = "Galena", dim = "28"},
- {OreName = "Chromite", veinName = "Ilmenite", dim = "28"},
- {OreName = "Uvarovite", veinName = "Ilmenite", dim = "28"},
- {OreName = "Perlite", veinName = "Ilmenite", dim = "28"},
- {OreName = "Bauxite", veinName = "Bauxite", dim = "28"},
- {OreName = "Aluminium", veinName = "Bauxite", dim = "28"},
- {OreName = "Bastnasite", veinName = "Bastnasite", dim = "28"},
- {OreName = "Monazite", veinName = "Bastnasite", dim = "28"},
- {OreName = "Neodymium", veinName = "Bastnasite", dim = "28"},
- {OreName = "Quartzite", veinName = "Certus Quartz", dim = "28"},
- {OreName = "Barite", veinName = "Certus Quartz", dim = "28"},
- {OreName = "Certus Quartz", veinName = "Certus Quartz", dim = "28"},
- --deimos
- {OreName = "Magnetite", veinName = "Magnetite", dim = "40"},
- {OreName = "Iron", veinName = "Magnetite", dim = "40"},
- {OreName = "Vanadium Magnetite", veinName = "Magnetite", dim = "40"},
- {OreName = "Sulfur", veinName = "Sulfur", dim = "40"},
- {OreName = "Pyrite", veinName = "Sulfur", dim = "40"},
- {OreName = "Sphalerite", veinName = "Sulfur", dim = "40"},
- {OreName = "Tetrahedrite", veinName = "Tetrahedrite", dim = "40"},
- {OreName = "Copper", veinName = "Tetrahedrite", dim = "40"},
- {OreName = "Stibnite", veinName = "Tetrahedrite", dim = "40"},
- {OreName = "Garnierite", veinName = "Garnierite", dim = "40"},
- {OreName = "Nickel", veinName = "Garnierite", dim = "40"},
- {OreName = "Cobaltite", veinName = "Garnierite", dim = "40"},
- {OreName = "Pentlandite", veinName = "Garnierite", dim = "40"},
- {OreName = "Scheelite", veinName = "Scheelite", dim = "40"},
- {OreName = "Tungstate", veinName = "Scheelite", dim = "40"},
- {OreName = "Lithium", veinName = "Scheelite", dim = "40"},
- {OreName = "Bastnasite", veinName = "Bastnasite", dim = "40"},
- {OreName = "Monazite", veinName = "Bastnasite", dim = "40"},
- {OreName = "Neodymium", veinName = "Bastnasite", dim = "40"},
- {OreName = "Uraninite", veinName = "Uraninite", dim = "40"},
- {OreName = "Uranium 238", veinName = "Uraninite", dim = "40"},
- {OreName = "Draconium", veinName = "Draconium", dim = "40"},
- {OreName = "Electrotine", veinName = "Draconium", dim = "40"},
- {OreName = "Jade", veinName = "Draconium", dim = "40"},
- {OreName = "Vinteum", veinName = "Draconium", dim = "40"},
- {OreName = "Tanzanite", veinName = "Oriharukon", dim = "40"},
- {OreName = "Vyroxeres", veinName = "Oriharukon", dim = "40"},
- {OreName = "Mirabilite", veinName = "Oriharukon", dim = "40"},
- --mars
- {OreName = "Rock Salt", veinName = "Rock Salt", dim = "29"},
- {OreName = "Salt", veinName = "Rock Salt", dim = "29"},
- {OreName = "Lepidolite", veinName = "Rock Salt", dim = "29"},
- {OreName = "Spodumene", veinName = "Rock Salt", dim = "29"},
- {OreName = "Sulfur", veinName = "Sulfur", dim = "29"},
- {OreName = "Pyrite", veinName = "Sulfur", dim = "29"},
- {OreName = "Sphalerite", veinName = "Sulfur", dim = "29"},
- {OreName = "Beryllium", veinName = "Beryllium", dim = "29"},
- {OreName = "Emerald", veinName = "Beryllium", dim = "29"},
- {OreName = "Thorium", veinName = "Beryllium", dim = "29"},
- {OreName = "Tetrahedrite", veinName = "Tetrahedrite", dim = "29"},
- {OreName = "Copper", veinName = "Tetrahedrite", dim = "29"},
- {OreName = "Stibnite", veinName = "Tetrahedrite", dim = "29"},
- {OreName = "Galena", veinName = "Galena", dim = "29"},
- {OreName = "Silver", veinName = "Galena", dim = "29"},
- {OreName = "Lead", veinName = "Galena", dim = "29"},
- {OreName = "Garnierite", veinName = "Garnierite", dim = "29"},
- {OreName = "Nickel", veinName = "Garnierite", dim = "29"},
- {OreName = "Cobaltite", veinName = "Garnierite", dim = "29"},
- {OreName = "Pentlandite", veinName = "Garnierite", dim = "29"},
- {OreName = "Lithium", veinName = "Scheelite", dim = "29"},
- {OreName = "Quartzite", veinName = "Quartzite", dim = "29"},
- {OreName = "Barite", veinName = "Quartzite", dim = "29"},
- {OreName = "Certus Quartz", veinName = "Quartzite", dim = "29"},
- {OreName = "Desh", veinName = "Desh", dim = "29"},
- {OreName = "Pitchblende", veinName = "Pitchblende", dim = "29"},
- {OreName = "Uraninite", veinName = "Pitchblende", dim = "29"},
- {OreName = "Arsenic", veinName = "Arsenic", dim = "29"},
- {OreName = "Bismuth", veinName = "Arsenic", dim = "29"},
- {OreName = "Antimony", veinName = "Arsenic", dim = "29"},
- --phobos
- {OreName = "Sulfur", veinName = "Sulfur", dim = "38"},
- {OreName = "Pyrite", veinName = "Sulfur", dim = "38"},
- {OreName = "Sphalerite", veinName = "Sulfur", dim = "38"},
- {OreName = "Wulfenite", veinName = "Wulfenite", dim = "38"},
- {OreName = "Molybdenite", veinName = "Wulfenite", dim = "38"},
- {OreName = "Molybdenum", veinName = "Wulfenite", dim = "38"},
- {OreName = "Powellite", veinName = "Wulfenite", dim = "38"},
- {OreName = "Garnierite", veinName = "Garnierite", dim = "38"},
- {OreName = "Nickel", veinName = "Garnierite", dim = "38"},
- {OreName = "Cobaltite", veinName = "Garnierite", dim = "38"},
- {OreName = "Pentlandite", veinName = "Garnierite", dim = "38"},
- {OreName = "Bauxite", veinName = "Bauxite", dim = "38"},
- {OreName = "Ilmenite", veinName = "Bauxite", dim = "38"},
- {OreName = "Aluminium", veinName = "Bauxite", dim = "38"},
- {OreName = "Quartzite", veinName = "Quartzite", dim = "38"},
- {OreName = "Barite", veinName = "Quartzite", dim = "38"},
- {OreName = "Certus Quartz", veinName = "Quartzite", dim = "38"},
- {OreName = "Uranium 238", veinName = "Uraninite", dim = "38"},
- {OreName = "Draconium", veinName = "Draconium", dim = "38"},
- {OreName = "Electrotine", veinName = "Draconium", dim = "38"},
- {OreName = "Jade", veinName = "Draconium", dim = "38"},
- {OreName = "Vinteum", veinName = "Draconium", dim = "38"},
- {OreName = "Pitchblende", veinName = "Pitchblende", dim = "38"},
- {OreName = "Oriharukon", veinName = "Oriharukon", dim = "38"},
- {OreName = "Tanzanite", veinName = "Oriharukon", dim = "38"},
- {OreName = "Vyroxeres", veinName = "Oriharukon", dim = "38"},
- {OreName = "Mirabilite", veinName = "Oriharukon", dim = "38"},
- {OreName = "Arsenic", veinName = "Arsenic", dim = "38"},
- {OreName = "Bismuth", veinName = "Arsenic", dim = "38"},
- {OreName = "Antimony", veinName = "Arsenic", dim = "38"},
- }
- --словарь жидкостей
- dictOils = {}
- dictOils["fluid.liquid_light_oil"] = "Light Oil"
- dictOils["fluid.liquid_medium_oil"] = "Raw Oil"
- dictOils["fluid.liquid_heavy_oil"] = "Heavy Oil"
- dictOils["fluid.gas_natural_gas"] = "Natural Gas"
- function translateOilName(oilName) --переводит имя жидкости согласно словарю dictOils
- for key, val in pairs(dictOils) do
- pos = string.find(oilName , "fluid")
- --print(pos)
- if pos~=nil then
- st = string.sub(oilName, pos)
- if st == key then
- return string.sub(oilName, 1, pos-1).. val
- end
- end
- end
- print(oilName, "соответствий в словаре не нашли")
- return oilName
- end
- function getVeinName(sOre) --возвращает имя жилы по имени руды и дименшну
- --print(sOre)
- for key, val in pairs(dict) do
- if val.OreName == sOre then
- --print(dim, vein.dim)
- if val.dim == dim then
- return val.veinName
- end
- end
- end
- --print("Обнаружена неизвестная руда: "..sOre)
- --fileLog:write("Обнаружена неизвестная руда: "..sOre) fileLog:write("\n")
- return nil
- end
- function parseX(s) --парсит координату X
- -- -8,-104 has Banded Iron
- pos2 = string.find(s, ",") - 1
- return string.sub(s, 1 , pos2)
- end
- function parseZ(s) --парсит координату Z
- -- -8,-104 has Banded Iron
- pos1 = string.find(s, ",") + 1
- pos2 = string.find(s, "has")
- if pos2 == nil then
- pos2 = pos1
- else
- pos2 = pos2 - 2
- end
- return string.sub(s, pos1 , pos2)
- end
- function parseName(s) --парсит имя руды
- pos1 = string.find(s, "has") + 4
- return string.sub(s, pos1)
- end
- function processProspectionTable(tab) --Обработать данные таблицы
- Ores = false --признак, является ли эта таблица рудной
- Oils = false --признак, является ли эта таблица жидкостной
- OilsSum = false --признак, является ли эта таблица с итогами жиж
- for name, val in pairs(tab) do --просмотрим таблицу данных
- if type(name) == "number" then --интересуют только строчки с номером
- -------------------------------
- if name == 1 then
- --руды
- if string.find(val, "Ores Found") ~= nil then -- если встретили текст "Ores Found", значит перед нами таблица руд
- Ores = true
- --print ("Ores Found")
- end
- --жижи
- if string.find(val, "Oils") ~= nil then -- если встретили текст "Oils", значит перед нами таблица жидкостей
- Oils = true
- --print ("Oils")
- end
- --жижи итоги
- if string.find(val, "Corners") ~= nil then -- если встретили текст "Corners", значит перед нами таблица итогов жидкостей
- OilsSum = true
- --print ("Oils Sums")
- end
- end
- pos = string.find(val, "Dim:") -- если это строчка с дименшном типа "2 Dim: 0"
- if pos~= nil then
- dim = string.sub(val, pos + 5) --запомним дименшн
- end
- ---------------------------------
- --руды
- if Ores == true then -- если это таблица руд
- pos = string.find(val, "has") -- 6 72,24 has Banded Iron
- --print(val, pos)
- if pos ~= nil then --если есть имя руды
- oreIndex = oreIndex + 1
- oreX[oreIndex] = parseX(val)
- oreZ[oreIndex] = parseZ(val)
- oreDim[oreIndex] = dim
- oreName[oreIndex] = parseName(val)
- end
- end
- ---------------------------------
- --жидкости
- if Oils == true then -- если это таблица жидкостей
- if name ~= 1 and name ~= 2 then -- любая строчка кроме второй содержит запись о жиже
- oilIndex = oilIndex + 1
- oilX[oilIndex] = -9999 --актуальное значение мы получим в следующей таблице позже
- oilZ[oilIndex] = -9999
- oilDim[oilIndex] = dim
- oilName[oilIndex] = string.sub(val, 4) --1: 9-15L Heavy Oil
- oilSegmentNum[oilIndex] = name - 2
- --print(val)
- end
- end
- ---------------------------------
- --итоги жидкостей
- if OilsSum == true then -- если это таблица итогов жидкостей
- if name == 2 then --X: 0 Z: -128
- --print(val)
- --парсим координты сектора [5]
- Zpos = string.find(val, "Z")
- xc = string.sub(val, 4, Zpos - 2)
- zc = string.sub(val, Zpos + 3)
- --print(xc, zc)
- --на этом шаге у нас таблице жидкостей есть записи о жижах текущей флешки, но без координату
- --и есть координаты сектора [5]
- --проставим координаты каждого сектора
- -- [1][2][3]
- -- [4][5][6]
- -- [7][8][9]
- for i=1, oilIndex do
- if oilX[i] == -9999 then -- находим запись, которой еще не присвоены координаты
- if oilSegmentNum[i] == 1 then
- oilX[i] = tostring(math.floor(xc -8*16))
- oilZ[i] = tostring(math.floor(zc -8*16))
- elseif oilSegmentNum[i] == 2 then
- oilX[i] = tostring(math.floor(xc))
- oilZ[i] = tostring(math.floor(zc -8*16))
- elseif oilSegmentNum[i] == 3 then
- oilX[i] = tostring(math.floor(xc +8*16))
- oilZ[i] = tostring(math.floor(zc -8*16))
- elseif oilSegmentNum[i] == 4 then
- oilX[i] = tostring(math.floor(xc -8*16))
- oilZ[i] = tostring(math.floor(zc))
- elseif oilSegmentNum[i] == 5 then
- oilX[i] = tostring(math.floor(xc))
- oilZ[i] = tostring(math.floor(zc))
- elseif oilSegmentNum[i] == 6 then
- oilX[i] = tostring(math.floor(xc +8*16))
- oilZ[i] = tostring(math.floor(zc))
- elseif oilSegmentNum[i] == 7 then
- oilX[i] = tostring(math.floor(xc -8*16))
- oilZ[i] = tostring(math.floor(zc +8*16))
- elseif oilSegmentNum[i] == 8 then
- oilX[i] = tostring(math.floor(xc))
- oilZ[i] = tostring(math.floor(zc +8*16))
- elseif oilSegmentNum[i] == 9 then
- oilX[i] = tostring(math.floor(xc +8*16))
- oilZ[i] = tostring(math.floor(zc +8*16))
- end
- end
- end
- end
- end
- end
- --file:write(name .." ".. val)
- --file:write("\n")
- end
- end
- function processProspectionData(tab) --Обработать данные флешки
- for name, val in pairs(tab) do --просмотрим таблицу данных проспектора
- --print(name, val)
- --os.sleep(1)
- if name ~= "n" then
- processProspectionTable(val)
- end
- end
- end
- --Пример JSON
- -- {
- -- "id": "iron_168,83,984",
- -- "name": "iron",
- -- "icon": "waypoint-normal.png",
- -- "x": 168,
- -- "y": 83,
- -- "z": 984,
- -- "r": 255,
- -- "g": 255,
- -- "b": 255,
- -- "enable": false,
- -- "type": "Normal",
- -- "origin": "JourneyMap",
- -- "dimensions": [
- -- 0
- -- ]
- -- }
- function wlJSON(key, val)--запишем строчку в JSON файл
- file:write(" \"".. key.. "\": ".. val ..",")
- file:write("\n")
- end
- function generateOreJSON(i) -- генерирует точку JourneyMap (файл JSON) для жилы
- -- id = veinName[i].."_"..oreX[i]..",1,"..oreZ[i] -- пример Glauconite Sand_x,1,z
- id = veinName[i].."_"..oreX[i]..",1,"..oreZ[i].."_"..oreDim[i] -- пример Glauconite Sand_x,1,z_0
- fileName = id..".json" -- пример имени файла: "Glauconite Sand_x,1,z_0.json"
- file=io.open("waypoints".."/" .. fileName,"w")
- if file == nil then --если файл не удалось создать, значит нет папки. создадим
- os.execute("mkdir " .. "waypoints")
- file=io.open("waypoints".."/" .. fileName,"w")
- end
- if oreDim[i] == "-1" then -- Рукожопая вставка Шелла для корректного отображения жил в Незере
- oreX[i] = oreX[i] * 8
- oreZ[i] = oreZ[i] * 8
- end
- --заполним тело JSON
- file:write("{") file:write("\n")
- wlJSON("id", "\""..id.."\"")
- wlJSON("name", "\""..veinName[i].."\"")
- wlJSON("icon", "\"".."waypoint-normal.png".."\"")
- wlJSON("x", oreX[i])
- wlJSON("y", "1")
- wlJSON("z", oreZ[i])
- wlJSON("r", "255")
- wlJSON("g", "255")
- wlJSON("b", "255")
- wlJSON("enable", "true")
- wlJSON("type", "\"".."Normal".."\"")
- wlJSON("origin", "\"".."JourneyMap".."\"")
- file:write(" \"dimensions\": [") file:write("\n")
- file:write(" ".. oreDim[i]) file:write("\n")
- file:write(" ]") file:write("\n")
- file:write("}")
- file:close()
- end
- function generateOilJSON(i) -- генерирует точку JourneyMap (файл JSON) ждя жидкости
- id = oilName[i].."_"..oilX[i]..",1,"..oilZ[i] -- пример 9-15L Heavy Oil_x,1,z
- fileName = id..".json" -- пример имени файла: "9-15L Heavy Oil_x,1,z.json"
- file=io.open("waypoints".."/" .. fileName,"w")
- if file == nil then --если файл не удалось создать, значит нет папки. создадим
- os.execute("mkdir " .. "waypoints")
- file=io.open("waypoints".."/" .. fileName,"w")
- end
- --заполним тело JSON
- file:write("{") file:write("\n")
- wlJSON("id", "\""..id.."\"")
- wlJSON("name", "\""..oilName[i].."\"")
- wlJSON("icon", "\"".."waypoint-normal.png".."\"")
- wlJSON("x", oilX[i])
- wlJSON("y", "1")
- wlJSON("z", oilZ[i])
- wlJSON("r", "127")
- wlJSON("g", "127")
- wlJSON("b", "127")
- wlJSON("enable", "true")
- wlJSON("type", "\"".."Normal".."\"")
- wlJSON("origin", "\"".."JourneyMap".."\"")
- file:write(" \"dimensions\": [") file:write("\n")
- file:write(" ".. oilDim[i]) file:write("\n")
- file:write(" ]") file:write("\n")
- file:write("}")
- file:close()
- end
- ----------------------------------------------------------------
- print ("Программа генерации точек JourneyMap запущена.")
- print ("Версия "..ver)
- print ("Ищем флешки с данными проспектора и просматриваем их...")
- --ищем флешки и сканируем их
- for i=1,5 do --цикл просмотра сторон адаптера
- slotNumbers = controller.getInventorySize(i) --получаем количество слотов инвентори в сундуке, в котором лежат флешки
- if slotNumbers ~= nil then --если вообще сундук там есть
- for slot=1, slotNumbers do --цикл по слотам сундука
- itemStack = controller.getStackInSlot(i, slot)
- if itemStack ~= nil then --если в слоте что-то есть
- --print(itemStack.label)
- --if itemStack.label == "Data Stick" then
- --print("Найдена флешка в слоте "..slot.."...")
- --print("Item hasTag: ", itemStack.hasTag)
- --nbt = item.readTag(itemStack)
- for name, val in pairs(itemStack) do --просмотрим таблицу реультата анализа предмета
- if name == "Analyzed Prospection Data" then
- --print(name, val)
- processProspectionData(val)
- end
- end
- --end
- end
- end
- end
- end
- --проставим имя жилы
- for i=1, oreIndex do
- sOre = oreName[i]
- veinName[i] = getVeinName(sOre)
- end
- --print("Debug stop")
- --os.exit()
- --Пометим дубликаты, чтобы не создавать лишние точки. У дубликатов имя жилы приравнивается к nil
- for i=1, oreIndex do
- for j = i+1, oreIndex do
- if oreX[i] == oreX[j] and oreZ[i] == oreZ[j] and oreDim[i] == oreDim[j] and veinName[i] == veinName[j] then --если записи полностью одинаковые, то одну из них помечаем как дубликат
- veinName[j] = nil -- стираем имя жилы у второй записи
- end
- end
- end
- --траслитерируем называние жидкостей
- for i=1, oilIndex do
- oilName[i] = translateOilName(oilName[i])
- end
- print("Ores")
- for i=1, oreIndex do
- if veinName[i] ~= nil then
- --print("x: "..oreX[i], "z: "..oreZ[i], "d: "..oreDim[i], "vein: "..veinName[i])
- end
- end
- print("Oils")
- for i=1, oilIndex do
- --print("x: "..oilX[i], "z: "..oilZ[i], "d: "..oilDim[i], "oil: "..oilName[i])
- end
- print("--------------")
- --Генерируем JSON файлы
- j1 = 0
- --для руд
- for i=1, oreIndex do
- if veinName[i] ~= nil then --если у записи не пустое имя жилы, то создаем точку
- generateOreJSON(i)
- j1=j1+1
- end
- end
- print("Созадно меток руды: "..j1..".")
- j2 = 0
- --для жидкостей
- for i=1, oilIndex do
- generateOilJSON(i)
- fileLog:write(oilName[i]) fileLog:write("\n")
- j2=j2+1
- end
- print("Создано меток жидкостей под бэдроком: "..j2..".")
- print("Итого в папке waypoints созадно файлов: "..j1+j2..".")
- os.exit()
- --История версий:
- --Версия 1.5
- --Устранена проблема неправильного отображения меток в Незере.
- --В название файла метки добавлен идентификатор дименшена.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement