Skip to content

Commit

Permalink
Lua API: rename SystemBody.volatileGas -> atmosDensity
Browse files Browse the repository at this point in the history
- Rename misleading volatileGas field to atmospheric density (its real value)
- Add surfacePressure field
  • Loading branch information
sturnclaw committed Jan 31, 2024
1 parent 34ea556 commit 6837fc6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
9 changes: 6 additions & 3 deletions data/meta/SystemBody.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@
--- The measure of metallicity of the body's crust:
--- 0.0 = light (Al, SiO2, etc), 1.0 = heavy (Fe, heavy metals)
---@field metallicity number
--- The measure of volatile gas present in the atmosphere of the body:
--- 0.0 = no atmosphere, 1.0 = earth atmosphere density, 4.0+ ~= venus
---@field volatileGas number
--- The atmospheric density at "surface level" of the body:
--- 0.0 = no atmosphere, 1.225 = earth atmosphere density, 64 ~= venus
---@field atmosDensity number
--- The compositional value of any atmospheric gasses in the bodys atmosphere (if any):
--- 0.0 = reducing (H2, NH3, etc), 1.0 = oxidising (CO2, O2, etc)
---@field atmosOxidizing number
--- The pressure of the atmosphere at the body's mean "surface level":
--- 1.0atm = earth
---@field surfacePressure number
--- The measure of volatile liquids present on the body:
--- 0.0 = none, 1.0 = waterworld (earth = 70%)
---@field volatileLiquid number
Expand Down
2 changes: 1 addition & 1 deletion data/modules/Scout/Scout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ local function calcSurfaceScanMission(sBody, difficulty, reward)

-- Calculate parameters which make approaching the body to scan it more difficult
local bodyDifficulty = (1 + sBody.gravity / EARTH_G)
* (1 + math.max(math.log(sBody.volatileGas), 0.0) * 0.5)
* (1 + math.max(math.log(sBody.atmosDensity), 0.0) * 0.5)
* (1 + sBody.eccentricity * 0.5)

local bodyReward = 1
Expand Down
33 changes: 27 additions & 6 deletions src/lua/LuaSystemBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,10 @@ static int l_sbody_attr_metallicity(lua_State *l)
}

/*
* Attribute: volatileGas
* Attribute: atmosDensity
*
* Returns the measure of volatile gas present in the atmosphere of the body
* 0.0 = no atmosphere, 1.0 = earth atmosphere density, 4.0+ ~= venus
* Returns the atmospheric density at "surface level" of the body
* 0.0 = no atmosphere, 1.225 = earth atmosphere density, 64+ ~= venus
*
* Availability:
*
Expand All @@ -496,10 +496,10 @@ static int l_sbody_attr_metallicity(lua_State *l)
*
* experimental
*/
static int l_sbody_attr_volatileGas(lua_State *l)
static int l_sbody_attr_atmosDensity(lua_State *l)
{
SystemBody *sbody = LuaObject<SystemBody>::CheckFromLua(1);
lua_pushnumber(l, sbody->GetVolatileGas());
lua_pushnumber(l, sbody->GetAtmSurfaceDensity());
return 1;
}

Expand All @@ -524,6 +524,26 @@ static int l_sbody_attr_atmosOxidizing(lua_State *l)
return 1;
}

/*
* Attribute: surfacePressure
*
* The pressure of the atmosphere at the surface of the body (atm).
*
* Availability:
*
* 2024
*
* Status:
*
* experimental
*/
static int l_sbody_attr_surfacePressure(lua_State *l)
{
SystemBody *sbody = LuaObject<SystemBody>::CheckFromLua(1);
lua_pushnumber(l, sbody->GetAtmSurfacePressure());
return 1;
}

/*
* Attribute: volatileLiquid
*
Expand Down Expand Up @@ -810,8 +830,9 @@ void LuaObject<SystemBody>::RegisterClass()
{ "axialTilt", l_sbody_attr_axial_tilt },
{ "averageTemp", l_sbody_attr_average_temp },
{ "metallicity", l_sbody_attr_metallicity },
{ "volatileGas", l_sbody_attr_volatileGas },
{ "atmosDensity", l_sbody_attr_atmosDensity },
{ "atmosOxidizing", l_sbody_attr_atmosOxidizing },
{ "surfacePressure", l_sbody_attr_surfacePressure },
{ "volatileLiquid", l_sbody_attr_volatileLiquid },
{ "volatileIces", l_sbody_attr_volatileIces },
{ "volcanicity", l_sbody_attr_volcanicity },
Expand Down

0 comments on commit 6837fc6

Please sign in to comment.