From 6837fc6e0565246efa6dc18daad78014f9e2083f Mon Sep 17 00:00:00 2001 From: Webster Sheets Date: Mon, 29 Jan 2024 19:05:46 -0500 Subject: [PATCH] Lua API: rename SystemBody.volatileGas -> atmosDensity - Rename misleading volatileGas field to atmospheric density (its real value) - Add surfacePressure field --- data/meta/SystemBody.lua | 9 ++++++--- data/modules/Scout/Scout.lua | 2 +- src/lua/LuaSystemBody.cpp | 33 +++++++++++++++++++++++++++------ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/data/meta/SystemBody.lua b/data/meta/SystemBody.lua index c95d19dda7e..fb3c7197f34 100644 --- a/data/meta/SystemBody.lua +++ b/data/meta/SystemBody.lua @@ -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 diff --git a/data/modules/Scout/Scout.lua b/data/modules/Scout/Scout.lua index dfdca35f18f..dc412bcc0a7 100644 --- a/data/modules/Scout/Scout.lua +++ b/data/modules/Scout/Scout.lua @@ -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 diff --git a/src/lua/LuaSystemBody.cpp b/src/lua/LuaSystemBody.cpp index 1bb734a269c..f276750d1bb 100644 --- a/src/lua/LuaSystemBody.cpp +++ b/src/lua/LuaSystemBody.cpp @@ -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: * @@ -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::CheckFromLua(1); - lua_pushnumber(l, sbody->GetVolatileGas()); + lua_pushnumber(l, sbody->GetAtmSurfaceDensity()); return 1; } @@ -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::CheckFromLua(1); + lua_pushnumber(l, sbody->GetAtmSurfacePressure()); + return 1; +} + /* * Attribute: volatileLiquid * @@ -810,8 +830,9 @@ void LuaObject::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 },