Skip to content

Commit

Permalink
Improve Tradeships.lua
Browse files Browse the repository at this point in the history
- Preparations:

Add method Ship:GetCargo
Add method Ship:GetDurationForDistance
Add method Ship:Create
Add method ui.treeNode & ui.treePop
Fix ui.Format.Number
Turn off the output when the ship changes frames
Reduce the detection range of hyperspace clouds

- Tradeships.lua

For current system, calculate all possible routes of tradeships,
durations, flows; arrange ships in space in such equilibrium state,
as if the have been flying about their business for a long time.

Calculate the average spawn interval for new ships, and parking
intervals, so that the stations are not overcrowded or empty.

Сreate a tab in the debug window with full information on
routes, ships, stations, remote systems.
  • Loading branch information
Gliese852 committed Mar 7, 2021
1 parent db00f85 commit dd73b6c
Show file tree
Hide file tree
Showing 8 changed files with 1,460 additions and 413 deletions.
30 changes: 30 additions & 0 deletions data/libs/Ship.lua
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,36 @@ Ship.RemoveEquip = function (self, item, count, slot)
return ret
end

--
-- Method: GetCargo
--
-- Build a table where the keys will be the names of the cargo, and the values
-- will be their number
--
-- > cargo = ship:GetCargo()
--
--
-- Return:
--
-- The table where the keys will be the names of the cargo, and the values
-- will be their number
--
-- Availability:
--
-- 2021
--
-- Status:
--
-- experimental
--
function Ship:GetCargo()
local count = {}
for _, et in pairs(self:GetEquip("cargo")) do
if not count[et] then count[et] = 0 end
count[et] = count[et]+1
end
return count
end

--
-- Method: IsHyperjumpAllowed
Expand Down
Loading

0 comments on commit dd73b6c

Please sign in to comment.