Left Panel Sort (Activity)

A place for discussion of making game modifications.
Jem
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 = {
    'refitting',
    'building_design',
    'building_ground_unit', --moved here
    'building_improvement',
    'building_colony',
    'building_planet',
    'terraforming',

    --'activity', 
  }


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

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

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

  function sort_funs.Activity (p1,p2)
    return lexical_compare(
      project_rank(p2),project_rank(p1),
      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)
  endend

Return to “Modding”

Who is online

Users browsing this forum: No registered users and 3 guests

cron