Skip to content

Instantly share code, notes, and snippets.

@numberlesstim
Last active August 12, 2024 19:28
Show Gist options
  • Save numberlesstim/7e40dbd1c3512804e30844397ff80add to your computer and use it in GitHub Desktop.
Save numberlesstim/7e40dbd1c3512804e30844397ff80add to your computer and use it in GitHub Desktop.
//gist 7e40dbd1c3512804e30844397ff80add
parameter param is -1.
local craftnames is list().
if param <> -1 {
if param:isType("String") craftnames:add(param).
else if param:isType("List") set craftnames to param.
else if param:hassuffix("ship") {
for el in param:ship:elements {
craftnames:add(el:name).
}
}
else if param:hassuffix("name") craftnames:add(param:name).
}
else for el in ship:elements craftnames:add(el:name).
set cc to kuniverse:craftlist.
set craftlist to list().
for i in range(cc:length) if unchar(cc[i]:tostring()[15]) <> 34 craftlist:add(cc[i]).
unset cc.
set bestmatch to lex().
for craft in craftlist {
for name in craftnames {
if name:contains(craft:name) {
if bestmatch:haskey(name) {
if craft:name:contains(bestmatch[name]:name) set bestmatch[name] to craft.
}
else set bestmatch[name] to craft.
}
}
}
for key in bestmatch:keys {
local craft is bestmatch[key].
print ("Info for " + key:toupper + " "):padleft(terminal:width):replace(" ", "-").
print " Craftname: " + craft:name.
print " Cost: " + round(craft:cost, 2) + " $".
print " Mass: " + round(craft:mass, 2) + " t".
print " Parts: " + craft:partcount.
print " Description: " + craft:description.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment