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

akkamaddi
Posts: 140
Joined: Tue Sep 26, 2017 5:11 am

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

Postby akkamaddi » Fri Aug 09, 2019 2:14 am

I'm sorry, but I'm having a bit of trouble with this. Where in the file should this be added?

gaerzi
Posts: 41
Joined: Wed Jul 10, 2019 1:30 pm

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

Postby gaerzi » Fri Aug 09, 2019 10:49 am

I've used this as a base to make tiny planets buildable but not gas giants. I can accept gathering asteroids and stuff to build planets (it's kind of unlikely there's enough materials to build something the mass of the Earth but let's ignore that) but condensing a gas giant into something solid where the gravity would not be devastating?

Plus the gas giants in this game are too pretty.

@akkamaddi: you need to edit the following functions:
  • function StarProperty.cant_build_more_planets(star)
  • function StarProperty.num_planet_build_sites(star)
  • function complete_build_planet_project(planet,report)

The first two have the logic for finding where you can build artificial planets, the last one has the logic for setting up the new planet's stats.


Return to “Modding”

Who is online

Users browsing this forum: No registered users and 1 guest

cron