From 14b8e8a6f97e38b053492cc560a4c5ed92c2eca1 Mon Sep 17 00:00:00 2001 From: Emlembow <36314674+Emlembow@users.noreply.github.com> Date: Sun, 15 Sep 2024 15:58:03 -0700 Subject: [PATCH] Committing changes from folder MiningRadar --- Radar.lua | 354 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 354 insertions(+) create mode 100644 Radar.lua diff --git a/Radar.lua b/Radar.lua new file mode 100644 index 0000000..8474444 --- /dev/null +++ b/Radar.lua @@ -0,0 +1,354 @@ +local Tinkr = ... + +local Draw = Tinkr.Util.Draw:New() + +local Builder = Tinkr.Util.GUIBuilder:New { + config = "node_finder_config" +} + +local nodes = { + -- Mining nodes + [413046] = {name = "Bismuth", type = "mining"}, + [413902] = {name = "Weeping Ironclaw", type = "mining"}, + [1733] = {name = "Silver Vein", type = "mining"}, + [413881] = {name = "Aqirite Seam", type = "mining"}, + [181557] = {name = "Khorium Vein", type = "mining"}, + [2040] = {name = "Mithril Deposit", type = "mining"}, + [1732] = {name = "Tin Vein", type = "mining"}, + [1731] = {name = "Copper Vein", type = "mining"}, + [1735] = {name = "Iron Deposit", type = "mining"}, + [202736] = {name = "Obsidium Deposit", type = "mining"}, + [175404] = {name = "Rich Thorium Vein", type = "mining"}, + [413047] = {name = "Aqirite", type = "mining"}, + [181555] = {name = "Fel Iron Deposit", type = "mining"}, + [413049] = {name = "Ironclaw", type = "mining"}, + [181556] = {name = "Adamantite Deposit", type = "mining"}, + [413880] = {name = "Bismuth Seam", type = "mining"}, + [413882] = {name = "Ironclaw Seam", type = "mining"}, + [202738] = {name = "Elementium Vein", type = "mining"}, + [1734] = {name = "Gold Vein", type = "mining"}, + [413905] = {name = "EZ-Mine Ironclaw", type = "mining"}, + [2047] = {name = "Truesilver Deposit", type = "mining"}, + [413886] = {name = "EZ-Mine Bismuth", type = "mining"}, + [324] = {name = "Small Thorium Vein", type = "mining"}, + [413907] = {name = "Camouflaged Ironclaw", type = "mining"}, + [191133] = {name = "Titanium Vein", type = "mining"}, + [446351] = {name = "Loose Crystal Shard", type = "mining"}, + [430351] = {name = "Webbed Ore Deposit", type = "mining"}, + [202737] = {name = "Pyrite Deposit", type = "mining"}, + [430335] = {name = "Webbed Ore Deposit", type = "mining"}, + [189978] = {name = "Cobalt Deposit", type = "mining"}, + [413897] = {name = "Camouflaged Aqirite", type = "mining"}, + [446352] = {name = "Loose Crystal Shard", type = "mining"}, + [181569] = {name = "Rich Adamantite Deposit", type = "mining"}, + [165658] = {name = "Dark Iron Deposit", type = "mining"}, + [413874] = {name = "Rich Bismuth", type = "mining"}, + [209313] = {name = "Trillium Vein", type = "mining"}, + [413884] = {name = "Weeping Bismuth", type = "mining"}, + [413892] = {name = "Weeping Aqirite", type = "mining"}, + [209330] = {name = "Rich Trillium Vein", type = "mining"}, + [452079] = {name = "Bismuth", type = "mining"}, + [413889] = {name = "Camouflaged Bismuth", type = "mining"}, + [413895] = {name = "EZ-Mine Aqirite", type = "mining"}, + [202741] = {name = "Rich Elementium Vein", type = "mining"}, + [255344] = {name = "Felslate Seam", type = "mining"}, + [434558] = {name = "Bismuth Chunk", type = "mining"}, + [413883] = {name = "Crystallized Bismuth", type = "mining"}, + [209311] = {name = "Ghost Iron Deposit", type = "mining"}, + [413900] = {name = "Crystallized Ironclaw", type = "mining"}, + [446349] = {name = "Loose Crystal Shard", type = "mining"}, + [189980] = {name = "Saronite Deposit", type = "mining"}, + [440211] = {name = "Bismuth", type = "mining"}, + [452075] = {name = "Ironclaw", type = "mining"}, + [413877] = {name = "Rich Ironclaw", type = "mining"}, + [440214] = {name = "Ironclaw", type = "mining"}, + [414113] = {name = "Sivstone Deposit", type = "mining"}, + [181248] = {name = "Copper Vein", type = "mining"}, + [452076] = {name = "Bismuth", type = "mining"}, + [241726] = {name = "Leystone Deposit", type = "mining"}, + [446347] = {name = "Loose Crystal Shard", type = "mining"}, + [452060] = {name = "Ironclaw", type = "mining"}, + [430352] = {name = "Webbed Ore Deposit", type = "mining"}, + [253280] = {name = "Leystone Seam", type = "mining"}, + [202739] = {name = "Rich Obsidium Deposit", type = "mining"}, + [452083] = {name = "Ironclaw", type = "mining"}, + [189979] = {name = "Rich Cobalt Deposit", type = "mining"}, + [434556] = {name = "Aqirite Chunk", type = "mining"}, + [446343] = {name = "Loose Crystal Shard", type = "mining"}, + [349982] = {name = "Phaedrum Deposit", type = "mining"}, + [195036] = {name = "Pure Saronite Deposit", type = "mining"}, + [236169] = {name = "Harvestable Precious Crystal", type = "mining"}, + [202740] = {name = "Rich Pyrite Deposit", type = "mining"}, + [325874] = {name = "Osmenite Seam", type = "mining"}, + [272768] = {name = "Empyrium Deposit", type = "mining"}, + [272780] = {name = "Empyrium Seam", type = "mining"}, + [247075] = {name = "Secreted Wax Glob", type = "mining"}, + [452080] = {name = "Bismuth", type = "mining"}, + [247967] = {name = "Brimstone Destroyer Core", type = "mining"}, + [185877] = {name = "Nethercite Deposit", type = "mining"}, + [123848] = {name = "Ooze Covered Thorium Vein", type = "mining"}, + [189981] = {name = "Rich Saronite Deposit", type = "mining"}, + [349900] = {name = "Elethium Deposit", type = "mining"}, + [452081] = {name = "Bismuth", type = "mining"}, + [452066] = {name = "Ironclaw", type = "mining"}, + [276619] = {name = "Monelite Seam", type = "mining"}, + [177388] = {name = "Ooze Covered Rich Thorium Vein", type = "mining"}, + [413890] = {name = "Crystallized Aqirite", type = "mining"}, + [181570] = {name = "Rich Adamantite Deposit", type = "mining"}, + [185557] = {name = "Ancient Gem Vein", type = "mining"}, + [241743] = {name = "Felslate Deposit", type = "mining"}, + [349898] = {name = "Laestrite Deposit", type = "mining"}, + [349981] = {name = "Oxxein Deposit", type = "mining"}, + [413875] = {name = "Rich Aqirite", type = "mining"}, + [276621] = {name = "Rich Monelite Deposit", type = "mining"}, + [247370] = {name = "Brimstone Destroyer Core", type = "mining"}, + [276618] = {name = "Platinum Deposit", type = "mining"}, + [232543] = {name = "Rich Blackrock Deposit", type = "mining"}, + [272778] = {name = "Rich Empyrium Deposit", type = "mining"}, + [232545] = {name = "Rich True Iron Deposit", type = "mining"}, + [276620] = {name = "Storm Silver Seam", type = "mining"}, + [221541] = {name = "Trillium Vein", type = "mining"}, + + -- Herb nodes + [454010] = {name = "Luredrop", type = "herb"}, + [414319] = {name = "Arathor's Spear", type = "herb"}, + [414317] = {name = "Orbinid", type = "herb"}, + [142140] = {name = "Purple Lotus", type = "herb"}, + [454055] = {name = "Luredrop", type = "herb"}, + [414316] = {name = "Luredrop", type = "herb"}, + [1621] = {name = "Briarthorn", type = "herb"}, + [2046] = {name = "Goldthorn", type = "herb"}, + [202747] = {name = "Cinderbloom", type = "herb"}, + [452956] = {name = "Orbinid", type = "herb"}, + [210537] = {name = "Eternal Blossom", type = "herb"}, + [210539] = {name = "Eternal Blossom", type = "herb"}, + [202751] = {name = "Twilight Jasmine", type = "herb"}, + [210538] = {name = "Eternal Blossom", type = "herb"}, + [186662] = {name = "Reagent Pouch", type = "herb"}, + [202749] = {name = "Azshara's Veil", type = "herb"}, + [414344] = {name = "Camouflaged Arathor's Spear", type = "herb"}, + [202748] = {name = "Stormvine", type = "herb"}, + [181279] = {name = "Netherbloom", type = "herb"}, + [142145] = {name = "Gromsblood", type = "herb"}, + [454071] = {name = "Mycobloom", type = "herb"}, + [454008] = {name = "Irradiated Luredrop", type = "herb"}, + [142144] = {name = "Ghost Mushroom", type = "herb"}, + [202750] = {name = "Heartblossom", type = "herb"}, + [2866] = {name = "Firebloom", type = "herb"}, + [452979] = {name = "Luredrop", type = "herb"}, + [202752] = {name = "Whiptail", type = "herb"}, + [142143] = {name = "Blindweed", type = "herb"}, + [2042] = {name = "Fadeleaf", type = "herb"}, + [414331] = {name = "Altered Luredrop", type = "herb"}, + [142142] = {name = "Sungrass", type = "herb"}, + [181278] = {name = "Ancient Lichen", type = "herb"}, + [1620] = {name = "Mageroyal", type = "herb"}, + [414318] = {name = "Blessing Blossom", type = "herb"}, + [181276] = {name = "Flame Cap", type = "herb"}, + [414332] = {name = "Altered Orbinid", type = "herb"}, + [414337] = {name = "Irradiated Orbinid", type = "herb"}, + [2041] = {name = "Liferoot", type = "herb"}, + [452973] = {name = "Luredrop", type = "herb"}, + [414324] = {name = "Lush Arathor's Spear", type = "herb"}, + [176589] = {name = "Black Lotus", type = "herb"}, + [1623] = {name = "Wild Steelbloom", type = "herb"}, + [209354] = {name = "Golden Lotus", type = "herb"}, + [423363] = {name = "Sporefused Arathor's Spear", type = "herb"}, + [181275] = {name = "Ragveil", type = "herb"}, + [452977] = {name = "Luredrop", type = "herb"}, + [176586] = {name = "Mountain Silversage", type = "herb"}, + [176584] = {name = "Dreamfoil", type = "herb"}, + [1624] = {name = "Kingsblood", type = "herb"} +} + +local function GetNodeInfo(objectId) + return nodes[objectId] +end + +local function DrawCrystalNode(draw, nx, ny, nz, color) + draw:SetColor(unpack(color)) + draw:SetWidth(2) + draw:SetAlpha(200) + + local baseSize = 1.5 + local height = 3 + local bobHeight = math.sin(GetTime() * 4) * 0.5 + local baseZ = nz + 5 + bobHeight + + -- Bottom pyramid + local v1 = {nx, ny, baseZ} + local v2 = {nx - baseSize, ny - baseSize, baseZ + height/2} + local v3 = {nx + baseSize, ny - baseSize, baseZ + height/2} + local v4 = {nx + baseSize, ny + baseSize, baseZ + height/2} + local v5 = {nx - baseSize, ny + baseSize, baseZ + height/2} + + -- Top pyramid + local v6 = {nx, ny, baseZ + height} + + -- Draw bottom pyramid + draw:Line(v1[1], v1[2], v1[3], v2[1], v2[2], v2[3]) + draw:Line(v1[1], v1[2], v1[3], v3[1], v3[2], v3[3]) + draw:Line(v1[1], v1[2], v1[3], v4[1], v4[2], v4[3]) + draw:Line(v1[1], v1[2], v1[3], v5[1], v5[2], v5[3]) + + draw:Line(v2[1], v2[2], v2[3], v3[1], v3[2], v3[3]) + draw:Line(v3[1], v3[2], v3[3], v4[1], v4[2], v4[3]) + draw:Line(v4[1], v4[2], v4[3], v5[1], v5[2], v5[3]) + draw:Line(v5[1], v5[2], v5[3], v2[1], v2[2], v2[3]) + + -- Draw top pyramid + draw:Line(v2[1], v2[2], v2[3], v6[1], v6[2], v6[3]) + draw:Line(v3[1], v3[2], v3[3], v6[1], v6[2], v6[3]) + draw:Line(v4[1], v4[2], v4[3], v6[1], v6[2], v6[3]) + draw:Line(v5[1], v5[2], v5[3], v6[1], v6[2], v6[3]) + + -- Draw a small sphere at the top for emphasis + draw:Circle(nx, ny, baseZ + height + 0.5, 0.3) +end + +local function DrawNode(draw, nodeInfo, nx, ny, nz, objectId) + local px, py, pz = ObjectRawPosition('player') + local dist = FastDistance(px, py, pz, nx, ny, nz) + + local nodeType = nodeInfo.type + local shouldDraw = false + local color + + if nodeType == "mining" and Builder:GetConfig("show_mining") == "yes" and Builder:GetConfig("show_mining_" .. objectId) == "yes" then + color = {0, 0, 255} + shouldDraw = true + elseif nodeType == "herb" and Builder:GetConfig("show_herbs") == "yes" and Builder:GetConfig("show_herb_" .. objectId) == "yes" then + color = {0, 255, 0} + shouldDraw = true + end + + if shouldDraw then + DrawCrystalNode(draw, nx, ny, nz, color) + + if Builder:GetConfig("draw_lines") == "yes" then + draw:SetColor(unpack(color)) + draw:Line(px, py, pz, nx, ny, nz) + end + + draw:SetColor(255, 255, 255) + local displayText = string.format("%s [%dy]", nodeInfo.name, math.floor(dist)) + draw:Text(displayText, "SourceCodePro", nx, ny, nz + 9) + end +end + +Draw:Sync(function(draw) + for _, object in ipairs(Objects()) do + if ObjectType(object) == 8 then + local objectId = ObjectId(object) + local nodeInfo = GetNodeInfo(objectId) + + if nodeInfo and ObjectLootable(object) then + local nx, ny, nz = ObjectRawPosition(object) + DrawNode(draw, nodeInfo, nx, ny, nz, objectId) + end + end + end +end) + +-- Modify the SavePreferences function +local function SavePreferences() + for id, node in pairs(nodes) do + local key = "show_" .. node.type .. "_" .. id + local value = Builder:GetConfig(key) + Builder:SetConfig(key, value) + end + print("Node preferences saved!") +end + +local MainSettingsTab = Builder:Tab { + title = "Main Settings", + content = { + Builder:Checkbox { + key = "show_mining", + label = "Show Mining Nodes", + -- description = "Toggle visibility of mining nodes.", + default = "yes" + }, + Builder:Checkbox { + key = "show_herbs", + label = "Show Herb Nodes", + -- description = "Toggle visibility of herb nodes.", + default = "yes" + }, + Builder:Checkbox { + key = "draw_lines", + label = "Draw Lines to Nodes", + description = "Draw lines between the player and visible nodes.", + default = "yes" + }, + } +} + +local DetailedFilterTab = Builder:Tab { + title = "Detailed Filters", + content = { + Builder:Group { + key = "mining_nodes_group", + title = "Mining Nodes", + content = (function() + local elements = {} + for id, node in pairs(nodes) do + if node.type == "mining" then + table.insert(elements, Builder:Checkbox { + key = "show_mining_" .. id, + label = node.name, + -- description = "Toggle visibility of " .. node.name, + default = "yes" + }) + end + end + return elements + end)() + }, + Builder:Group { + key = "herb_nodes_group", + title = "Herb Nodes", + content = (function() + local elements = {} + for id, node in pairs(nodes) do + if node.type == "herb" then + table.insert(elements, Builder:Checkbox { + key = "show_herb_" .. id, + label = node.name, + -- description = "Toggle visibility of " .. node.name, + default = "yes" + }) + end + end + return elements + end)() + }, + Builder:Button { + key = "save_preferences_button", + text = "Save Preferences", + onClick = function() + SavePreferences() + end + } + } +} + +local MainWindow = Builder:Window { + key = "node_finder_window", + title = "Node Finder Settings", + width = 400, -- Increased width to accommodate more content + height = 600, -- Increased height to accommodate more content + content = { + Builder:TabGroup { + key = "main_tabs", + tabs = { + MainSettingsTab, + DetailedFilterTab, + } + } + } +} + +Builder:Build(MainWindow) + +Draw:Enable() \ No newline at end of file