I've changed this to allow existing planets to keep their 'specials'. Previously I only keep the 'Rich' trait.
Thanks 
gaerzi for your addition!
Find the file > \Lua state\Orders\production.lua
Look for the function then the section with --jem
Code: Select all
  function StarProperty.cant_build_more_planets(star)
    local a,b=StarOrbitRange![star.type]()
    for i=a,b
      if not star.planets[i]
        return false
      end
      if (star.planets[i].type=='Gas Giant' or star.planets[i].type=='Inferno' or star.planets[i].size=='Tiny' or star.planets[i].size=='Small' or star.planets[i].temperature=='Cold' or star.planets[i].minerals=='Poor') and (star.planets[i].no_colony or not star.planets[i].empire) --jem
        return false
      end
    end
    return true
  end
    function StarProperty.num_planet_build_sites(star)
    local a,b=StarOrbitRange![star.type]()
    local rval=0
    for i=a,b
      if not star.planets[i]
        rval+=1
      elseif (star.planets[i].type=='Gas Giant' or star.planets[i].type=='Inferno' or star.planets[i].size=='Tiny' or star.planets[i].size=='Small' or star.planets[i].temperature=='Cold' or star.planets[i].minerals=='Poor') and (star.planets[i].no_colony or not star.planets[i].empire) --jem
	rval+=1
      end
    end
    return rval
  end
  function complete_build_planet_project(planet,report)
    clear_current_project(planet)
    local push, candidate_slots = pusher {}
    local star in planet
    
    local a,b=StarOrbitRange![star.type]()
    for i=a,b
      if (not star.planets[i]) or ( 
          (star.planets[i].type=='Gas Giant' or star.planets[i].type=='Inferno' or star.planets[i].size=='Tiny' or star.planets[i].size=='Small' or star.planets[i].temperature=='Cold' or star.planets[i].minerals=='Poor') and (star.planets[i].no_colony or not star.planets[i].empire) ) --jem
	push | i
      end
    end
    --print(v2s | star.planets)
    if not next | candidate_slots
      report.unable_to_complete='No Build Sites'
      return
    end
    local orbit = candidate_slots[ dice_roll(#candidate_slots) ]
    local old_planet = star.planets[orbit]
    local size='Medium'
    if old_planet and (star.planets[orbit].type=='Gas Giant' or star.planets[orbit].size=='Large') --jem
      size='Large'
    end
    local kW_m2=1.2
    local new_planet = new_planet_ref {
      type='Barren',
      minerals='Normal',
      ..size,
      ..planet.star,
      ..kW_m2,
      ..orbit,
      day_length=32,
      rarity='common',
      temperature = get_temperature(kW_m2),
      --name = 'Artificial Planet' ,  
			 name = (star.name .. " " .. to_roman(orbit) .. '-A'),
      specials = {}, 
    }
    if old_planet
      if star.planets[orbit].minerals=='Rich' --jem
        new_planet.minerals='Rich'
      end
      if star.planets[orbit].special_resources --jem
	if not new_planet.special_resources
	  new_planet.special_resources={}
	end
        for i,r in ipairs | star.planets[orbit].special_resources?
	  new_planet.special_resources[1+#new_planet.special_resources]=r
        end
      end
    end
    local i=orbit
I'm thinking to do the Mass Scrap of (Same) Building and Ship which will help quite a bit when playing. But after looking around the codes (I don't know LUA) I feel faint and that I suspect (but I could have misunderstood) that LUA is a 'patchwork' programming language. The 'randomness' got to me... I mean there must be an easier way to find out How Many ships of current type is refittable (after following the mass-refit codes)... I was thinking of reusing those codes to count how many ships/station of Same type I can scrap in current star, then across galaxy/empire... I can't help ranting. Cheers!
Jem