local CHANNEL = 1337 local TARGET = "devplayer0" local ICON_BASE = "https://p.nul.ie/cc/icon/" local ORE_ICONS = { ["minecraft:coal_ore"] = "coal", ["minecraft:deepslate_coal_ore"] = "ds-coal", ["minecraft:iron_ore"] = "iron", ["minecraft:deepslate_iron_ore"] = "ds-iron", ["minecraft:copper_ore"] = "copper", ["minecraft:deepslate_copper_ore"] = "ds-copper", ["minecraft:gold_ore"] = "gold", ["minecraft:deepslate_gold_ore"] = "ds-gold", ["minecraft:redstone_ore"] = "redstone", ["minecraft:deepslate_redstone_ore"] = "ds-redstone", ["minecraft:emerald_ore"] = "emerald", ["minecraft:deepslate_emerald_ore"] = "ds-emerald", ["minecraft:lapis_ore"] = "lapis", ["minecraft:deepslate_lapis_ore"] = "ds-lapis", ["minecraft:diamond_ore"] = "diamond", ["minecraft:deepslate_diamond_ore"] = "ds-diamond", -- ["create:ochrum"] =, -- ["create:zinc_ore"] =, -- ["create:deepslate_zinc_ore"] =, -- ["create_new_age:thorium_ore"] =, -- ["powah:deepslate_uraninite_ore_poor"] =, -- ["powah:deepslate_uraninite_ore"] =, -- ["powah:deepslate_uraninite_ore_dense"] =, -- ["powah:uraninite_ore_poor"] =, -- ["powah:uraninite_ore"] =, -- ["powah:uraninite_ore_dense"] =, } function oreIcon(t) local i = "generic" if ORE_ICONS[t] then i = ORE_ICONS[t] end return ICON_BASE .. "ore-" .. i .. ".png" end local modem = peripheral.find("modem") -- local monitor = peripheral.find("monitor") local chat = peripheral.find("chatBox") local cartographer = peripheral.find("cartographer") function vecToStr(v) return v.x .. "," .. v.y .. "," .. v.z end function markerSet(msg) return "autominer_" .. msg.name end function setPosMarker(msg) local id = markerSet(msg) local mId = id .. "_pos" cartographer.removeMarker(id, mId) cartographer.addPOIMarker( id, mId, msg.name, msg.name .. "'s position", msg.pos.x, msg.pos.y, msg.pos.z, ICON_BASE .. "turtle.png") end function handleStart(msg) local cMsg = { {text = msg.name, color = "green"}, {text = " @ ", color = "white"}, {text = vecToStr(msg.pos), color = "aqua"}, {text = " found ", color = "white"}, {text = tostring(msg.oreCount), color = "red"}, {text = " ores (", color = "white"}, {text = tostring(#msg.veins), color = "red"}, {text = " veins) on iteration ", color = "white"}, {text = tostring(msg.i), color = "green"}, {text = "!", color = "white"}, } local msgJSON = textutils.serializeJSON(cMsg) chat.sendFormattedMessage(msgJSON, "AutoMine") local id = markerSet(msg) cartographer.addMarkerSet(id, "AutoMiner " .. msg.name) cartographer.clearMarkerSet(id) setPosMarker(msg) local orePoints = {} for i, v in ipairs(msg.veins) do table.insert(orePoints, v.pos) cartographer.addPOIMarker( id, id .. "_vein_" .. i, v.count .. " " .. v.type, "Vein of " .. v.count .. " " .. v.type, v.pos.x, v.pos.y, v.pos.z, oreIcon(v.type)) end cartographer.addLineMarker( id, id .. "_vein_path", "Mining path #" .. msg.i, "Current mining path", "#FF00FF", 0.7, 3, orePoints) end function handleVein(msg) local cMsg = { {text = msg.name, color = "green"}, {text = " @ ", color = "white"}, {text = vecToStr(msg.pos), color = "aqua"}, {text = " is mining ", color = "white"}, {text = tostring(msg.oreCount), color = "red"}, {text = " ", color = "white"}, {text = msg.oreType, color = "dark_purple"}, {text = " (vein ", color = "white"}, {text = tostring(msg.i), color = "red"}, {text = " / ", color = "white"}, {text = tostring(msg.total), color = "red"}, {text = ")!", color = "white"}, } local msgJSON = textutils.serializeJSON(cMsg) chat.sendFormattedMessageToPlayer(msgJSON, TARGET, "AutoMine") local id = markerSet(msg) setPosMarker(msg) if msg.i ~= 1 then cartographer.removeMarker(id, id .. "_vein_" .. (msg.i - 1)) end end cartographer.refreshIntegrations() modem.open(CHANNEL) -- handleStart({ -- i = 69, -- oreCount = 1337, -- veins = { -- { -- pos = {x = 297, y = 124, z = 1935}, -- type = "minecraft:coal_ore", -- count = 12, -- }, -- { -- pos = {x = 297, y = 134, z = 1935}, -- type = "minecraft:iron_ore", -- count = 7, -- }, -- { -- pos = {x = 400, y = 134, z = 1935}, -- type = "minecraft:diamond_ore", -- count = 2, -- }, -- { -- pos = {x = 400, y = 134, z = 1975}, -- type = "minecraft:sussy_ore", -- count = 7, -- } -- }, -- name = "test", -- pos = {x = 297, y = 154, z = 1935}, -- }) -- handleVein({ -- i = 2, -- total = 69, -- oreCount = 1337, -- oreType = "minecraft:yeet", -- name = "test", -- pos = {x = 1, y = 2, z = 3}, -- }) -- assert(false) while true do local event, side, channel, replyChannel, msg, distance = os.pullEvent("modem_message") if channel == CHANNEL then if msg.type == "iterationStart" then handleStart(msg) -- sendChat(msg.name.." found "..msg.oreCount.." ores ("..msg.veinCount.." veins)") -- for _, v in ipairs(msg.path) do -- print("vein path "..v.x..", "..v.y..", "..v.z) -- end elseif msg.type == "veinStart" then handleVein(msg) -- sendChat(msg.name.." is mining "..msg.count.." "..msg.oreType.." (vein "..msg.i..") @ "..msg.pos.x..", "..msg.pos.y..", "..msg.pos.z) end end end