1 QuestHelper_File
["director_find.lua"] = "Development Version"
2 QuestHelper_Loadtime
["director_find.lua"] = GetTime()
4 local function getitall(name
)
6 for i
= 1, #name
- 1 do
7 local sub
= name
:sub(i
, i
+ 1):lower()
8 if not sub
:find(" ") then
9 local dbi
= DB_GetItem("find", sub
:byte(1) * 256 + sub
:byte(2), true)
10 --print("inserting", sub)
11 if not dbi
then return {} end
17 for k
in pairs(segments
) do
18 table.insert(segwork
, {k
, 1, k
[1]})
24 local lowest
= segwork
[1][3]
25 local highest
= segwork
[1][3]
27 for i
= 2, #segwork
do
28 local v
= segwork
[i
][3]
29 --print("loop", i, lowest, highest, v, segwork[i][2])
40 if lowest
== highest
then
41 table.insert(found
, lowest
)
42 segwork
[1][2] = segwork
[1][2] + 1
43 if not segwork
[1][1][segwork
[1][2]]
then break end
44 segwork
[1][3] = segwork
[1][3] + segwork
[1][1][segwork
[1][2]]
46 while segwork
[lid
][3] < highest
do
47 segwork
[lid
][2] = segwork
[lid
][2] + 1
48 if not segwork
[lid
][1][segwork
[lid
][2]]
then break end
49 segwork
[lid
][3] = segwork
[lid
][3] + segwork
[lid
][1][segwork
[lid
][2]]
53 if not segwork
[lid
][1][segwork
[lid
][2]]
then break end
59 local function generate_objective(dbi
)
62 local why
= {desc
= dbi
.name
, tracker_desc
= dbi
.name
}
63 for _
, v
in ipairs(dbi
.loc
) do
64 QuestHelper
: Assert(QuestHelper_ParentLookup
)
65 QuestHelper
: Assert(QuestHelper_ParentLookup
[v
.p
], v
.p
)
66 table.insert(clooster
, {loc
= {x
= v
.x
, y
= v
.y
, c
= QuestHelper_ParentLookup
[v
.p
], p
= v
.p
}, cluster
= clooster
, tracker_hidden
= true, why
= why
, map_desc
= {QuestHelper
:HighlightText(dbi
.name
)}, tracker_desc
= dbi
.name
, map_suppress_ignore
= true, map_custom_menu
= function (menu
) QuestHelper
:CreateMenuItem(menu
, QHText("FIND_REMOVE")):SetFunction(function () QH_Route_ClusterRemove(clooster
) end) end})
69 QH_Route_ClusterAdd(clooster
)
72 local msfires
= {desc
= QHText("FIND_CUSTOM_LOCATION"), tracker_desc
= QHText("FIND_CUSTOM_LOCATION")}
74 function QH_FindName(name
)
75 local locd
= name
:match("^loc (.+)")
77 -- I just know some guy's gonna get pissed off because he was trying to find "loc crocolisk" or something, but screw him
78 local locx
, locy
, locz
80 locx
, locy
= locd
:match("^(%d+) (%d+)$")
82 locx
, locy
= tonumber(locx
), tonumber(locy
)
83 locz
= QuestHelper_NameLookup
[QuestHelper_IndexLookup
[QuestHelper
.routing_c
][QuestHelper
.routing_z]]
87 locz
, locx
, locy
= locd
:match("^(.+) (%d+) (%d+)$")
88 locx
, locy
= tonumber(locx
), tonumber(locy
)
92 for z
, nam
in pairs(QuestHelper_NameLookup
) do
93 if nam
:lower():find(locz
:lower()) then
99 if type(locz
) == "number" then
100 local ec
, ez
= unpack(QuestHelper_ZoneLookup
[locz
])
101 local c
, x
, y
= QuestHelper
.Astrolabe
:GetAbsoluteContinentPosition(ec
, ez
, locx
/ 100, locy
/ 100)
102 local node
= {loc
= {x
= x
, y
= y
, p
= locz
, c
= QuestHelper_ParentLookup
[locz
]}, why
= msfires
, map_desc
= {QHText("FIND_CUSTOM_LOCATION")}, tracker_desc
= QHText("FIND_CUSTOM_LOCATION"), tracker_hidden
= true}
103 local cluster
= {node
}
104 node
.cluster
= cluster
106 node
.map_suppress_ignore
= true
107 node
.map_custom_menu
= function (menu
) QuestHelper
:CreateMenuItem(menu
, QHText("FIND_REMOVE")):SetFunction(function () QH_Route_ClusterRemove(cluster
) end) end
109 QH_Route_ClusterAdd(cluster
)
113 if not DB_Ready() then
114 print(QHText("FIND_NOT_READY"))
118 local found
= getitall(name
)
120 local mennix
= QuestHelper
:CreateMenu()
121 QuestHelper
:CreateMenuTitle(mennix
, QHText("RESULTS_TITLE"))
123 local made_item
= false
127 local needs_postfix
= {}
129 for _
, v
in ipairs(found
) do
130 local dbi
= DB_GetItem("monster", v
)
134 table.insert(found_db
, dbi
)
136 if has_name
[dbi
.name
] then needs_postfix
[dbi
.name
] = true end
137 has_name
[dbi
.name
] = true
141 table.sort(found_db
, function (a
, b
) return a
.name
< b
.name
end)
143 for _
, v
in ipairs(found_db
) do
148 if needs_postfix
[name
] then name
= name
.. " (" .. QuestHelper_NameLookup
[v
.loc
[1].p
] .. ")" end
150 local opt
= QuestHelper
:CreateMenuItem(mennix
, name
)
151 opt
:SetFunction(generate_objective
, v
)
154 if not made_item
then
155 QuestHelper
:CreateMenuItem(mennix
, QHText("NO_RESULTS"))
158 mennix
:ShowAtCursor()