Create [Artificial Planet] on Tiny & Small planets

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

Create [Artificial Planet] on Tiny & Small planets

Postby Jem » Tue Mar 05, 2019 3:05 am

I tried editing the script logic to allow (unoccupied) Tiny & Small planets to be 'upgraded' to Medium Barren planets after using create [Artificial Planet]. My thinking was since we can create Medium size planets from nothing, the same should be able to apply to Tiny&Small planets by 'filling' them up to Medium size with more 'soil'. :) Anyone who might find this useful please refer to below that ends with '--jem'. Cheers!

in production.lua

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].size=='Tiny' or star.planets[i].size=='Small') and (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

  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].size=='Tiny' or star.planets[i].size=='Small') and (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' --jem

Jem
Posts: 8
Joined: Tue Aug 15, 2017 9:21 am

Re: Create [Artificial Planet] on Tiny & Small planets

Postby Jem » Wed Mar 13, 2019 5:02 am

After some testing, I went ahead and add 'Cold' & 'Inferno' planets (regardless of size) to the list of planets that can be 'transformed' by [Make Artificial Planet]. Also the [Rich] mineral property is kept; if any; all other special resources are not. Refer to below lines end with --jem.
\Lua state\Orders\production.lua

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 (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 (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 (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 and star.planets[orbit].minerals=='Rich' --jem
      new_planet.minerals='Rich'
    end


Return to “Modding”

Who is online

Users browsing this forum: No registered users and 3 guests