I was not able to install Visual Studio Express 2010 because my computer is a piece of crap (and is going to be replaced sooner rather than later), but I realized that using "prospect all" to hunt for minerals on the embark screen is just not going to have reasonable response times.
So, that project needs to wait for me to get a compiler up and running, excise the relevant bits of prospector.cpp, and figure out a good way to implement break-loop-when-found to speed things up.
In the meantime, I did add a prospect-lite script to my mod in case anyone might find this useful.
-- tesb-prospect.lua
-- Wrapper for the DFHack command "prospect all" that reveals only Living Stone and Missing Gems
function tchelper(first, rest) -- Title case function from Lua users wiki String Recipes
return first:upper()..rest:lower()
-- Usage: str = str:gsub("(%a)([%w_']*)", tchelper)
end
local prospect_results
local found_any
local mineral_name
local output
prospect_results = dfhack.run_command_silent("prospect all")
output = ""
if string.match(prospect_results,"Map is not available") then
output = prospect_results
dfhack.color(COLOR_LIGHTRED)
else
for result in string.gmatch(prospect_results,"LIVING .- :") do
if not found_any then
found_any = true
output = "===== Living Stones =====\n"
end
mineral_name = string.sub(result,1,-3).."\n"
output = output .. mineral_name:gsub("(%a)([%w_']*)", tchelper)
end
if found_any then output = output .. "\n" end
found_any = false
for result in string.gmatch(prospect_results,"HIDDEN .- :") do
if not found_any then
found_any = true
output = output .. "====== Hidden Gems ======\n"
end
mineral_name = string.sub(result,1,-3).."\n"
output = output .. mineral_name:gsub("(%a)([%w_']*)", tchelper)
end
if output == "" then output = "No Living Stones nor Hidden Gems are present.\n" end
end
dfhack.print(output)
dfhack.color(COLOR_RESET)
And a more general one:
-- lookfor.lua
-- Wrapper for the DFHack command "prospect all" that reveals only materials that match strings provided on the command line
-- If the first argument is the flag "-terse" then lookfor outputs only the material name; otherwise the entire "prospect all" line is printed
local prospect_results
local output
local terse
local args = {...}
prospect_results = dfhack.run_command_silent("prospect all")
output = ""
if args[1] == "-terse" then
trim_pattern = "^%s*(.-) : %C*"
args[1] = ":::" -- Change the flag into a pattern that cannot exist in the "propect all" output
else
trim_pattern = "^(%C*)"
end
if string.match(prospect_results,"Map is not available") then
output = prospect_results
dfhack.color(COLOR_LIGHTRED)
else
for line in string.gmatch(prospect_results,".-\n") do -- To order output by search pattern, swap this line with the next
for i,pattern in ipairs(args) do
if string.find(line,string.upper(pattern),1,true) then
line = line:gsub(trim_pattern, "%1")
output = output .. line
end
end
end
if output == "" then output = "No matches found.\n" end
end
dfhack.print(output)
dfhack.color(COLOR_RESET)
The mod-specific one takes no arguments, the general one takes a list of strings to use for matching and accepts a
-terse flag to report nothing but the mineral name.
lookfor -terse coal diamond ruby
DIAMOND_FY
DIAMOND_LYWondering if maybe
-terse should be the default? The whole point of this script is for people who consider
prospect all to be cheating, but are looking for something in particular.