Advanced

Re: checker request

[Cancelled] checker request
March 23, 2022 03:49AM
I modified the checker for GC9NW86 - Challenge to cover 25% of the land area of the US a week ago but needed the checker released for testing



If the votes variable need to be an integer I'm fine with rounding to whole sq. miles. Also I did not know what to do with these but did the work for 51 of the areas:
Puerto Rico 3,423.78
Northern Mariana Islands 182.33
United States Virgin Islands 134.32
American Samoa 76.46
Guam 209.80
Minor Outlying Islands 16.00

Thanks

Start .lua file copied from PCG-LUA-script-1172.lua
-----------------
local args={...}
local conf = args[1].config
local profileName = args[1].profileName
local profileId = args[1].profileId
local filter = {}
PGC.print("Got profile name: ", profileName, "\n")
debug = false

if (conf.VotesNeeded ~= nil) then
VotesNeeded = conf.VotesNeeded
PGC.print("Votes Needed: " .. VotesNeeded .. "\n")
else
VotesNeeded = 883987.04
PGC.print("VotesNeeded parameter missing!!\nDefaulting to 88397.0325 for 25% of the US area\n\n")
end

filter.country="United States"

--- these are probably not used for area challenges, but leaving them for flexibility
if (conf.difficulties ~= nil) then filter.difficulties = conf.difficulties end
if (conf.terrains ~= nil) then filter.terrains = conf.terrains end
if (conf.foundOnOrAfter) ~= nil then filter.minVisitDate = conf.foundOnOrAfter end
if (conf.foundOnOrBefore ~= nil) then filter.maxVisitDate =conf.foundOnOrBefore end
if (conf.hiddenOnOrAfter) ~= nil then filter.minHiddenDate = conf.hiddenOnOrAfter end
if (conf.hiddenOnOrBefore ~= nil) then filter.maxHiddenDate = conf.hiddenOnOrBefore end
PGC.print("\nfilter: ")
PGC.print(filter)

function spairs(t, order)
-- collect the keys
local keys = {}
for k in pairs(t) do keys[#keys+1] = k end

-- if order function given, sort by it by passing the table and keys a, b,
-- otherwise just sort the keys
if order then
table.sort(keys, function(a,b) return order(t, a, b) end)
else
table.sort(keys)
end

-- return the iterator function
local i = 0
return function()
i = i + 1
if keys then
return keys, t[keys]
end
end
end

function remove_crazy_caches(finds)
PGC.print("Omitted caches:\n")
local crazy_caches = PGC.GetBookmarklist("BMAFMJR", {} ) or {}
local codes = {}
for _,code in ipairs(crazy_caches) do
codes
= true
end
local res={}
for _,f in ipairs(finds) do
if not codes[f.gccode] and f.type~="Locationless (Reverse) Cache" then
table.insert(res, f)
else
PGC.print(f.cache_name .. " " .. f.gccode .. " http://coord.info/";; .. f.gccode .. " " .. f.region .. "\n" )
end
end
return res
end


local WinCount=0
local LossCount=0

States = {}
States["Alabama"] ={}
States["Alabama"]["Name"] = "Alabama"
States["Alabama"]["Status"] = "Not Found"
States["Alabama"]["Votes"] = "50645.33"
States["Alaska"] ={}
States["Alaska"]["Name"] = "Alaska"
States["Alaska"]["Status"] = "Not Found"
States["Alaska"]["Votes"] = "570640.95"
States["Arizona"] ={}
States["Arizona"]["Name"] = "Arizona"
States["Arizona"]["Status"] = "Not Found"
States["Arizona"]["Votes"] = "113594.08"
States["Arkansas"] ={}
States["Arkansas"]["Name"] = "Arkansas"
States["Arkansas"]["Status"] = "Not Found"
States["Arkansas"]["Votes"] = "52035.48"
States["California"] ={}
States["California"]["Name"] = "California"
States["California"]["Status"] = "Not Found"
States["California"]["Votes"] = "155779.22"
States["Colorado"] ={}
States["Colorado"]["Name"] = "Colorado"
States["Colorado"]["Status"] = "Not Found"
States["Colorado"]["Votes"] = "103641.89"
States["Connecticut"] ={}
States["Connecticut"]["Name"] = "Connecticut"
States["Connecticut"]["Status"] = "Not Found"
States["Connecticut"]["Votes"] = "4842.36"
States["Delaware"] ={}
States["Delaware"]["Name"] = "Delaware"
States["Delaware"]["Status"] = "Not Found"
States["Delaware"]["Votes"] = "1948.54"
States["District of Columbia"] ={}
States["District of Columbia"]["Name"] = "District of Columbia"
States["District of Columbia"]["Status"] = "Not Found"
States["District of Columbia"]["Votes"] = "61.05
States["Florida"] ={}
States["Florida"]["Name"] = "Florida"
States["Florida"]["Status"] = "Not Found"
States["Florida"]["Votes"] = "53624.76"
States["Georgia"] ={}
States["Georgia"]["Name"] = "Georgia"
States["Georgia"]["Status"] = "Not Found"
States["Georgia"]["Votes"] = "57513.49"
States["Hawaii"] ={}
States["Hawaii"]["Name"] = "Hawaii"
States["Hawaii"]["Status"] = "Not Found"
States["Hawaii"]["Votes"] = "6422.63"
States["Idaho"] ={}
States["Idaho"]["Name"] = "Idaho"
States["Idaho"]["Status"] = "Not Found"
States["Idaho"]["Votes"] = "82643.12"
States["Illinois"] ={}
States["Illinois"]["Name"] = "Illinois"
States["Illinois"]["Status"] = "Not Found"
States["Illinois"]["Votes"] = "55518.93"
States["Indiana"] ={}
States["Indiana"]["Name"] = "Indiana"
States["Indiana"]["Status"] = "Not Found"
States["Indiana"]["Votes"] = "35826.11"
States["Iowa"] ={}
States["Iowa"]["Name"] = "Iowa"
States["Iowa"]["Status"] = "Not Found"
States["Iowa"]["Votes"] = "55857.13"
States["Kansas"] ={}
States["Kansas"]["Name"] = "Kansas"
States["Kansas"]["Status"] = "Not Found"
States["Kansas"]["Votes"] = "81758.72"
States["Kentucky"] ={}
States["Kentucky"]["Name"] = "Kentucky"
States["Kentucky"]["Status"] = "Not Found"
States["Kentucky"]["Votes"] = "39486.34"
States["Louisiana"] ={}
States["Louisiana"]["Name"] = "Louisiana"
States["Louisiana"]["Status"] = "Not Found"
States["Louisiana"]["Votes"] = "43203.90"
States["Maine"] ={}
States["Maine"]["Name"] = "Maine"
States["Maine"]["Status"] = "Not Found"
States["Maine"]["Votes"] = "30842.92"
States["Maryland"] ={}
States["Maryland"]["Name"] = "Maryland"
States["Maryland"]["Status"] = "Not Found"
States["Maryland"]["Votes"] = "9707.24"
States["Massachusetts"] ={}
States["Massachusetts"]["Name"] = "Massachusetts"
States["Massachusetts"]["Status"] = "Not Found"
States["Massachusetts"]["Votes"] = "7800.06"
States["Michigan"] ={}
States["Michigan"]["Name"] = "Michigan"
States["Michigan"]["Status"] = "Not Found"
States["Michigan"]["Votes"] = "56538.90"
States["Minnesota"] ={}
States["Minnesota"]["Name"] = "Minnesota"
States["Minnesota"]["Status"] = "Not Found"
States["Minnesota"]["Votes"] = "79626.74"
States["Mississippi"] ={}
States["Mississippi"]["Name"] = "Mississippi"
States["Mississippi"]["Status"] = "Not Found"
States["Mississippi"]["Votes"] = "46923.27"
States["Missouri"] ={}
States["Missouri"]["Name"] = "Missouri"
States["Missouri"]["Status"] = "Not Found"
States["Missouri"]["Votes"] = "68741.52"
States["Montana"] ={}
States["Montana"]["Name"] = "Montana"
States["Montana"]["Status"] = "Not Found"
States["Montana"]["Votes"] = "145545.80"
States["Nebraska"] ={}
States["Nebraska"]["Name"] = "Nebraska"
States["Nebraska"]["Status"] = "Not Found"
States["Nebraska"]["Votes"] = "76824.17"
States["Nevada"] ={}
States["Nevada"]["Name"] = "Nevada"
States["Nevada"]["Status"] = "Not Found"
States["Nevada"]["Votes"] = "109781.18"
States["New Hampshire"] ={}
States["New Hampshire"]["Name"] = "New Hampshire"
States["New Hampshire"]["Status"] = "Not Found"
States["New Hampshire"]["Votes"] = "8952.65"
States["New Jersey"] ={}
States["New Jersey"]["Name"] = "New Jersey"
States["New Jersey"]["Status"] = "Not Found"
States["New Jersey"]["Votes"] = "7354.22"
States["New Mexico"] ={}
States["New Mexico"]["Name"] = "New Mexico"
States["New Mexico"]["Status"] = "Not Found"
States["New Mexico"]["Votes"] = "121298.15"
States["New York"] ={}
States["New York"]["Name"] = "New York"
States["New York"]["Status"] = "Not Found"
States["New York"]["Votes"] = "47126.40"
States["North Carolina"] ={}
States["North Carolina"]["Name"] = "North Carolina"
States["North Carolina"]["Status"] = "Not Found"
States["North Carolina"]["Votes"] = "48617.91"
States["North Dakota"] ={}
States["North Dakota"]["Name"] = "North Dakota"
States["North Dakota"]["Status"] = "Not Found"
States["North Dakota"]["Votes"] = "69000.89"
States["Ohio"] ={}
States["Ohio"]["Name"] = "Ohio"
States["Ohio"]["Status"] = "Not Found"
States["Ohio"]["Votes"] = "40860.69"
States["Oklahoma"] ={}
States["Oklahoma"]["Name"] = "Oklahoma"
States["Oklahoma"]["Status"] = "Not Found"
States["Oklahoma"]["Votes"] = "68594.92"
States["Oregon"] ={}
States["Oregon"]["Name"] = "Oregon"
States["Oregon"]["Status"] = "Not Found"
States["Oregon"]["Votes"] = "95988.01"
States["Pennsylvania"] ={}
States["Pennsylvania"]["Name"] = "Pennsylvania"
States["Pennsylvania"]["Status"] = "Not Found"
States["Pennsylvania"]["Votes"] = "44742.70"
States["Rhode Island"] ={}
States["Rhode Island"]["Name"] = "Rhode Island"
States["Rhode Island"]["Status"] = "Not Found"
States["Rhode Island"]["Votes"] = "1033.81"
States["South Carolina"] ={}
States["South Carolina"]["Name"] = "South Carolina"
States["South Carolina"]["Status"] = "Not Found"
States["South Carolina"]["Votes"] = "30060.70"
States["South Dakota"] ={}
States["South Dakota"]["Name"] = "South Dakota"
States["South Dakota"]["Status"] = "Not Found"
States["South Dakota"]["Votes"] = "75811.00"
States["Tennessee"] ={}
States["Tennessee"]["Name"] = "Tennessee"
States["Tennessee"]["Status"] = "Not Found"
States["Tennessee"]["Votes"] = "41234.90"
States["Texas"] ={}
States["Texas"]["Name"] = "Texas"
States["Texas"]["Status"] = "Not Found"
States["Texas"]["Votes"] = "261231.71"
States["Utah"] ={}
States["Utah"]["Name"] = "Utah"
States["Utah"]["Status"] = "Not Found"
States["Utah"]["Votes"] = "82169.62"
States["Vermont"] ={}
States["Vermont"]["Name"] = "Vermont"
States["Vermont"]["Status"] = "Not Found"
States["Vermont"]["Votes"] = "9216.66"
States["Virginia"] ={}
States["Virginia"]["Name"] = "Virginia"
States["Virginia"]["Status"] = "Not Found"
States["Virginia"]["Votes"] = "39490.09"
States["Washington"] ={}
States["Washington"]["Name"] = "Washington"
States["Washington"]["Status"] = "Not Found"
States["Washington"]["Votes"] = "66455.52"
States["West Virginia"] ={}
States["West Virginia"]["Name"] = "West Virginia"
States["West Virginia"]["Status"] = "Not Found"
States["West Virginia"]["Votes"] = "24038.21"
States["Wisconsin"] ={}
States["Wisconsin"]["Name"] = "Wisconsin"
States["Wisconsin"]["Status"] = "Not Found"
States["Wisconsin"]["Votes"] = "54157.80"
States["Wyoming"] ={}
States["Wyoming"]["Name"] = "Wyoming"
States["Wyoming"]["Status"] = "Not Found"
States["Wyoming"]["Votes"] = "97093.14"
if (debug == true) then
PGC.print("\nStates:\n")
PGC.print(States)
end

local finds = remove_crazy_caches( PGC.GetFinds( profileId, { fields = {'gccode', 'cache_name', 'visitdate', 'region', 'type'}, order = 'NEWESTFIRST', filter = filter }))

PGC.print(finds)

for _,y in ipairs(finds) do -- Loop through the found caches and updat States
States[y["region"]]["Status"]="Found"
end

votecount = 0
local html = ""
local log=""
local logFirstLine = "Unfortunately you have not visited enough states greater than 25% of the Area of the United States. Here are the states you have: \br\br"
local htmlFirstLine = "Unfortunately you have not visited enough states greater than 25% of the Area of the United States. Here are the states you have: <br><br>"

for _,v in spairs(States, function(t,a,c) return c > a end) do

if (v["Status"] == 'Found') then
if v["type"] ~= 'Locationless (Reverse) Cache' then
WinCount=WinCount+1
votecount = votecount + v["Votes"]
html = html .."<b>" .. v["Name"] .. "</b> " .. v["Votes"] .. " votes. <br>"
log=log .."**" .. v["Name"] .. "** " .. v["Votes"] .. " votes. \n"
--if (votecount > VotesNeeded) then
-- ok = true
-- logFirstLine = "#WOOT WOOT, I WON!!#\nI needed " .. VotesNeeded .. " to win and have " .. votecount .. " sq miles of the possible 3,535,948.13 sq miles\n\n"
-- htmlFirstLine = "<b>WOOT WOOT, I WON!!</b><br>I needed " .. VotesNeeded .. " to win and have " .. votecount .. " sq miles of the possible 3,535,948.13 sq miles <br><br>"
--end
if (debug == true) then
PGC.print("\n" .. v["Status"] .. ": " .. v["Name"] .. " " .. v["Votes"] .. " votes. Running Total: " .. votecount)
end
end
else
LossCount=LossCount +1
end
end

if (votecount > VotesNeeded) then
ok = true
logFirstLine = "#WOOT WOOT, I WON!!#\nI needed " .. VotesNeeded .. " to win and have " .. votecount .. " sq miles of the possible 3,535,948.13 sq miles\n\n"
htmlFirstLine = "<b>WOOT WOOT, I WON!!</b><br>I needed " .. VotesNeeded .. " to win and have " .. votecount .. " sq miles of the possible 3,535,948.13 sq miles <br><br>"
else
ok= false
html = html .. "<br><br><Strong>Your found area is " .. votecount .. " from " .. WinCount .. " states.</strong><br><br>You need to travel to the following states:<br><br>"
for _,v in spairs(States, function(t,a,c) return c > a end) do

if (v["Status"] ~= 'Found') then
html = html ..'<b><font color="red">' .. v["Name"] .. '</font></b> ' .. v["Votes"] .. ' votes lost. <br>'
end
end
end

log = logFirstLine .. log
html = htmlFirstLine .. html

return { ok = ok, log = log, html = html }
Re: checker request
March 23, 2022 11:21AM
Please contact the author of PCG-LUA-script-1172 direct if he is willing to rewrite his script to suit your needs
Re: checker request
March 23, 2022 04:24PM
And who is that? I have rewritten the script to do the function. All I need is the little button to test and release.
Re: checker request
March 23, 2022 06:08PM
@MNTA To get "the little button to test and release" you contact Support via the orange button available on most Project-GC-pages and ask to become a scriptwriter.
Re: checker request
March 23, 2022 05:26PM
The author is TravelingGeek and you can contact him by pressing on the little envelope behind his name on the checker of PCG-LUA-script-1172

He has to alter his script to incorperate Puerto Rico etc because the script is written for the US only

I tried your script in the system but it failed, error log ([string ""]:65: ')' expected near ';')



Edited 1 time(s). Last edit at 03/23/2022 05:41PM by vogelbird. (view changes)
Re: checker request
April 03, 2022 07:06PM
Please close this request
Sorry, only registered users may post in this forum.

Click here to login