Left Panel Sort (Activity)

A place for discussion of making game modifications.
Posts: 31
Joined: Tue Aug 15, 2017 9:21 am

Left Panel Sort (Activity)

Postby Jem » Sun Nov 24, 2019 2:15 pm

In summary, this changes the Left Panel under Activity to sort
1) Ground units below Ships, above Improvements,
2) In same Project Type, sorted by [Buy] value, Cheapest at top, Expensive below.

For detailed ranting, read on. Cheers! :)


I've been trying to change the Left Panel to show the planets in their appropriate sort order, like 'building' of ground units IMO should appear at the top (currently ground units are below improvements) next to the ship building.

\Lua state\GUI\~GalaxyMap\@PlanetListPanel.lua

Code: Select all

  local project_order = {
    'building_ground_unit', --moved here


I forgot what is the original, I only remembered I edited/changed the line to use project_type(), and add a new function to return buycost so each 'type' say 'mining' list the 'cheapest to [buy]' projects at the top with 'most expensive' at bottom. Another simple function to return just 1st 10 chars of project_name, so for "Colonize: ~~~~~" will return without the colony name.

Hope this can help you as it did for me. Cheers!

\Lua state\GUI\~GalaxyMap\@PlanetListPanel.lua

Code: Select all

  local function project_buycost(planet)
    local project_type,project_info = planet: project_info()
    if not project_type
      return 0
    local hammer_cost = planet.current_production_cost
    if not hammer_cost
      return 0

    local remaining = hammer_cost-planet.hammers-planet.overflow_hammers
    return remaining * planet.empire.coins_to_labor_rate
  local function project_group(planet)
    return string.sub(planet.project_name,1,10) --returns 1st 10 chars of project_name

  function sort_funs.Activity (p1,p2)
    return lexical_compare(
      p2.project_type, p1.project_type, --changed
       project_group(p1), project_group(p2), --replaced planet.project_name
      project_buycost(p1),project_buycost(p2), --replaced eq_project_rank()
      p1.name , p2.name,
      p2.outpost and 0 or total_pop(p2), p1.outpost and 0 or total_pop(p1),
      p1._ikey, p2._ikey)

Return to “Modding”

Who is online

Users browsing this forum: No registered users and 1 guest