Skip to content

Instantly share code, notes, and snippets.

@numberlesstim
Last active August 19, 2024 19:55
Show Gist options
  • Save numberlesstim/a78133867a86ab42b8c302c628084473 to your computer and use it in GitHub Desktop.
Save numberlesstim/a78133867a86ab42b8c302c628084473 to your computer and use it in GitHub Desktop.
//gist a78133867a86ab42b8c302c628084473
set cc to kuniverse:craftlist.
set cleanlist to list().
for i in range(cc:length) if unchar(cc[i]:tostring()[15]) <> 34 cleanlist:add(cc[i]).
unset cc.
function printPrintalist {
parameter printalist.
local pads is list(0,0,0).
for p in printalist {
for i in range(3) if p[i]:length > pads[i] set pads[i] to p[i]:length + 1.
}
for i in range(3) if mod(pads[i], 2) > 0 set pads[i] to pads[i] + 1.
print "Name":padright(pads[0]) + "|" + "Cost":padleft(pads[1]) + "|" + "Parts":padright(pads[2]).
for p in printalist {
print p[0]:padright(pads[0]) + "|" + p[1]:padleft(pads[1]) + "|" + p[2]:padright(pads[2]).
}
}
function showMeTheMoney {
parameter dub is "", mincost is 0, maxcost is -1.
local printalist is list().
for c in cleanlist {
if (dub:length = 0 OR c:name:contains(dub)) AND c:cost >= mincost AND (maxcost < 0 OR c:cost <= maxcost) {
printalist:add(list(c:name, c:cost:tostring, c:partcount:tostring)).
}
}
printPrintalist(printalist).
}
function showMeTheParts {
parameter dub is "", minparts is 0, maxparts is -1.
local printalist is list().
for c in cleanlist {
if (dub:length = 0 OR c:name:contains(dub)) AND c:partcount >= minparts AND (maxparts < 0 OR c:partcount <= maxparts) {
printalist:add(list(c:name, c:cost:tostring, c:partcount:tostring)).
}
}
printPrintalist(printalist).
}
function gimmeTheTemplates {
parameter dub.
local clist is list().
for c in cleanlist {
if c:name:contains(dub) {
clist:add(c).
}
}
return clist.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment