Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show import/export in commodity description in commodity market #5082

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data/libs/SpaceStation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ local function updateEquipmentStock (station)
local stock = (Engine.rand:Integer(0,rn) + Engine.rand:Integer(0,rn)) / 2 -- normal 0-100% stock
if pricemod > 10 then --major import, low stock
stock = stock - (rn*0.10) -- shifting .10 = 2% chance of 0 stock
elseif pricemod > 2 then --minor import
elseif pricemod > 4 then --minor import
stock = stock - (rn*0.07) -- shifting .07 = 1% chance of 0 stock
elseif pricemod < -10 then --major export
stock = stock + (rn*0.8)
elseif pricemod < -2 then --minor export
elseif pricemod < -4 then --minor export
stock = stock + (rn*0.3)
end
equipmentStock[station][e] = math.floor(stock >=0 and stock or 0)
Expand Down
8 changes: 4 additions & 4 deletions data/modules/TradeShips.lua
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,12 @@ local spawnInitialShips = function (game_start)
if key ~= "rubbish" and key ~= "radioactives" and Game.system:IsCommodityLegal(key) then
-- values from SystemInfoView::UpdateEconomyTab

if v > 2 then
if v > 4 then
import_score = import_score + (v > 10 and 2 or 1) -- lua is crazy
table.insert(imports, equip)
end

if v < -2 then
if v < -4 then
export_score = export_score + (v < -10 and 2 or 1)
table.insert(exports, equip)
end
Expand Down Expand Up @@ -913,9 +913,9 @@ local onGameStart = function ()
for key,equip in pairs(e.cargo) do
local v = Game.system:GetCommodityBasePriceAlterations(key)
if key ~= 'rubbish' and key ~= 'radioactives' and Game.system:IsCommodityLegal(key) then
if v > 2 then
if v > 4 then
table.insert(imports, equip)
elseif v < -2 then
elseif v < -4 then
table.insert(exports, equip)
end
end
Expand Down
10 changes: 10 additions & 0 deletions data/pigui/libs/commodity-market.lua
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@ function CommodityMarketWidget:TradeMenu()
ui.columns(1, "", false)
ui.text('')

local pricemod = Game.system:GetCommodityBasePriceAlterations(self.selectedItem.name)
if pricemod > 10 then
ui.text(l.MAJOR_IMPORT)
elseif pricemod > 4 then
ui.text(l.MINOR_IMPORT)
elseif pricemod < -10 then
ui.text(l.MAJOR_EXPORT)
elseif pricemod < -4 then
ui.text(l.MINOR_EXPORT)
end
ui.textWrapped(self.selectedItem:GetDescription())

ui.setCursorPos(bottomHalf)
Expand Down