Modding Help I want to change ocean liquid type. How to overwrite planet parameter?

Discussion in 'Starbound Modding' started by kliria, Oct 26, 2017.

  1. kliria

    kliria Void-Bound Voyager

    Hello. I'm very new to lua and modding. Sorry for bad english because I'm not native.
    Playing with lua, I finally knew to access information of ocean liquids forming surface of a planet.
    The information can be accessed through celestial object, which only can be called via cockpit navigation interface of player's ship.
    Code:
    celestial.visitableParameters(self.selection.planet).subsurfaceLayer.primarySubRegion.oceanLiquid
    celestial.visitableParameters(self.selection.planet).subsurfaceLayer.primaryRegion.oceanLiquid
    celestial.visitableParameters(self.selection.planet).surfaceLayer.primarySubRegion.oceanLiquid
    celestial.visitableParameters(self.selection.planet).surfaceLayer.primaryRegion.oceanLiquid
    ...
    celestial.visitableParameters(self.selection.planet).subsurfaceLayer.primarySubRegion.oceanLiquidLevel
    ...
    
    There are 4 separated specific biome layers defining infinite liquid region.
    self.selection.planet is planet coordinate in `CelestialCoordinate` format.
    oceanLiquid or oceanLiquidLevel arguments contain liquidtype in 'LiquidId' or height in 'integer' respectively.
    I guess ocean information doesn't stored in world file. It is stored in system file. Because it still remains even world file is removed. After removal of world file, revisiting the planet rebuilt everything new except weather or something.

    I tried direct input to overwrite stored parameter via
    Code:
    celestial.visitableParameters(self.selection.planet).subsurfaceLayer.primarySubRegion.oceanLiquid=7
    celestial.visitableParameters(self.selection.planet).subsurfaceLayer.primaryRegion.oceanLiquid=7
    celestial.visitableParameters(self.selection.planet).surfaceLayer.primarySubRegion.oceanLiquid=7
    celestial.visitableParameters(self.selection.planet).surfaceLayer.primaryRegion.oceanLiquid=7
    to make it coconut milk ocean(Id=7), but nothing happens and return values are still original.

    I checked lua file of terraformer object to reference. Because it is the only code to modify planet parameters. But I didn't find any useful. Fundamental functions look like hardcoded for me.

    Is there anybody can change existing planet's ocean type? How to overwrite returning values of them?...
     
  2. kliria

    kliria Void-Bound Voyager

    ohh.. I found there is something wrong I mentioned.
    It was wrong. Customized biome information per planet is not stored in system nor world. It's stored in universe.chunks file.
    I tried to figure out where the data stored in chunks file via hex editing.
    1. Removed universe.chunks file. Then it is newly created. Never to use navigation of ship to avoid creation of non-interested star map chunks.
    2. terraform an planet into some biome.
    3. get an backup of universe.chunks
    4. terraform the previous planet into some another biome.
    5. get an backup of universe.chunks
    6. I repeated step #2~#5 a few times.

    I figured out universe.chunks data keep increasing about 2kilobytes unit when I change planet biome. The file changes header a little bit and attaches some datablock to end of file in each operation.
    So I guess universe.chunks file is a kind of "log file" storing "change of universe" action log. When I decrease number of some hex value in header showing difference during operation while leaving attached datablocks end of chunks file latest, planet biome information of universe looks like got back to the past.
     
  3. kliria

    kliria Void-Bound Voyager

    However I still can not figure out where to touch in chunks file to change ocean type of a planet... It's too difficult for me.
     
  4. kliria

    kliria Void-Bound Voyager

    Finally I succeed to change liquid type of ocean. But it's not handy method. And it is unable to be published as mod.

    The method is changing part of generation code before generation of starmap chunks.
    At first, it requires universe.chunks file to be deleted... (It contains customized biome information whether terraformer item used)
    .system file of system where your ship and you exist and .world file of lava or ocean type planet belong to the system also have to be deleted.

    And, make a small mod contains terrestrial_worlds.config.patch file, which replace some texts in original terrestrial_worlds.config file.
    Code:
    [
      {
        "op": "replace",
        "path": "/regionTypes/magma",
        "value": {
          "oceanLiquid" : [ "milk" ],
          "blockSelector" : [ "remixedIslandsSurface" ],
          "fgCaveSelector" : [ "empty" ],
          "bgCaveSelector" : [ "empty" ],
          "biome" : [
            [0, [ "magma" ]]
          ]
        }
      },
      {
        "op": "replace",
        "path": "/regionTypes/magmaoceanfloor",
        "value": {
          "oceanLiquid" : [ "milk" ],
          "oceanLevelOffset" : 1000,
          "blockSelector" : [ "ledgesSurface" ],
          "fgCaveSelector" : [ "emptier" ],
          "bgCaveSelector" : [ "emptiest" ],
          "biome" : [
            [0, [ "magmaoceanfloor" ]]
          ]
        }
      }
    ]
    And enter the game to regenerate universe.chunks and system file. In this stage, All lava type planet in the system will have milk ocean. Do not touch navigator. Touching navigator may change all lava planets in near-by stars.
    Turn off the game, remove the small mod to turn it back to vanilla.
    Enter the game again, and you may see milk ocean still remains because universe.chunks file still contains information that the planet have milk ocean biome.

    Milk ocean and Erchius fuel ocean will make planet texture glitchy, because of there is no proper planet image for them in vanilla client.

    I failed. I guess there is no way to create a handy mod to change ocean liquid type in real-time.
    I wish developers to create some basic functions to handle ocean liquids...
     

Share This Page