Skip to content

Instantly share code, notes, and snippets.

@johnbartholomew
Created December 27, 2012 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnbartholomew/4392053 to your computer and use it in GitHub Desktop.
Save johnbartholomew/4392053 to your computer and use it in GitHub Desktop.
function MinMaxCommodity(sys)
sys = sys or Game.system
if sys:isa('SystemPath') then
sys = sys:GetStarSystem()
end
local alt = sys:GetCommodityBasePriceAlterations()
local minPrice = math.huge
local maxPrice = -math.huge
local minCargo, maxCargo
for k,v in pairs(alt) do
if v < minPrice then
minPrice = v
minCargo = k
end
if v > maxPrice then
maxPrice = v
maxCargo = k
end
end
print('Best import:', maxCargo)
print('Best export:', minCargo)
return minCargo, maxCargo
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment