Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Gas

From Stationeers Community Wiki
Revision as of 05:17, 13 March 2026 by RA2lover (talk | contribs) (Initial version. No infobox functionality implemented.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module can be edited at Module:Gas/doc

Methods

GetGas

Use: GetGas(User input)

Returns a read-only Gas object containing information for a given gas.

If no gas is found that can match the input, throws an error.

Phase change methods

Evaporation Pressure

EvaporationPressureUnclamped

Use: EvaporationPressureClamped(gasTable, Temperature)
gasTable: a table containing information for a given gas (obtainable through GetGas)
Temperature: The current gas gemperature in kelvin

Evaluates the gas's evaporation pressure curve for a given Temperature, returning its corresponding evaporation pressure in kPa. This is just the curve function without any compensation for phase change characteristics.

EvaporationPressureClamped

Use: EvaporationPressureUnclamped(gasTable, Temperature)
gasTable: a table containing information for a given gas (obtainable through GetGas)
Temperature: The current gas gemperature in kelvin

Evaluates the gas's evaporation pressure curve for a given Temperature, returning its corresponding evaporation pressure in kPa. Unlike EvaporationPressureClamped, this first clamps the input temperature to values within the range where the gas can exist as a non-frozen liquid.

EvaporationPressure

Use: EvaporationPressure(gasTable, Temperature)
gasTable: a table containing information for a given gas (obtainable through GetGas)
Temperature: The current gas gemperature in kelvin

Evaluates the gas's evaporation pressure curve for a given Temperature, returning its corresponding evaporation pressure in kPa. Unlike the other methods, this provides additional handling to return the evaporation pressure for supercooled liquids when given a liquid as input.

Evaporation Temperature

EvaporationTemperatureUnclamped

Use: EvaporationPressureUnclamped(gasTable, Pressure)
gasTable: a table containing information for a given gas (obtainable through GetGas)
Pressure: The current gas pressure in kPa

Evaluates the gas's evaporation pressure curve for a given Pressure, returning its corresponding evaporation temperature in kelvin. This is just the curve function without any compensation for phase change characteristics.

EvaporationTemperatureClamped

Use: EvaporationTemperatureClamped(gasTable, Pressure)
gasTable: a table containing information for a given gas (obtainable through GetGas)
Pressure: The current gas pressure in kPa

Evaluates the gas's evaporation pressure curve for a given Pressure, returning its corresponding evaporation temperature in kelvin. Pressure values are clamped to the range of values the gas can exist as a non-frozen, non-supercritical liquid.

EvaporationTemperature

Use: EvaporationTemperatureClamped(gasTable, Temperature)
gasTable: a table containing information for a given gas (obtainable through GetGas)
Pressure: The current gas pressure in kPa

Evaluates the gas's evaporation pressure curve for a given Pressure, returning its corresponding evaporation temperature in kelvin. This is currently the same as EvaporationTemperatureUnclamped(gasTable, Pressure).

Objects

Gas

A table containing data for a gas. Editing these should be done through Module:Gas/data.

Fields

See Module:Gas/data/doc.


--Wikitext methods:
--Infobox(GasName): Creates an infobox for the gas type. (NYI)

--Lua methods:
--GetGas(?): Try to find a gas matching the input. Returns a table containing data for that gas or throws an error.


local GasData = mw.loadData("Module:Gas/data")




local p = {}

local function GetGas(input)
    --Attempts to get a Gas object from user input.
    if input == nil then return nil end

    --Frame handling
    if type(input)=="table" and type(input.args)=="table" then return GetGas(p.args.Name) or GetGas(p.args[1]) or GetGas(p.args[2]) or GetGas(p.args[3]) end

    --Gas handling
    if type(input)=="table" and type(input.Name)=="String" and type(input.State)=="String" and type(input.MolarMass)=="number" then return input end

    --Number handling
    if type(input)=="number" then return GasData[input] or error("Could not find GasData for Gas number: "..input) end
    
    --String handling
    if type(input)=="string" then
        -- See if there's a direct name match
        if type(GasData[input])=="table" and GasData[input].Name == input then return GasData[input] end

        -- search for human readable names
        for k,v in pairs(GasData.HumanReadableName) do
            if v==input then return GetGas(k) end
        end

        -- search for human readable symbols, preferring gases first
        local LiquidWithSymbol
        for k,v in pairs(GasData.HumanReadableSymbol) do
            if v==input and GasData[k].State=="Gas" then return p.GetGas(k) end
            if v==input and GasData[k].State=="Liquid" then LiquidWithSymbol = k end
        end
        if LiquidWithSymbol then return GetGas(LiquidWithSymbol) end

        -- Hail mary: Try to find a liquid version of the gas.
        if input:sub(1,6)=="Liquid" then error("Could not find GasData for gas: "..input) end --fail if we're already doing that

        -- If there's a space in our name we'll probably have better luck by also using a space.
        if string.match(input, " .") then return p.GetGas("Liquid "..input) else return p.GetGas("Liquid"..input) end

    end
  
end
p.GetGas = GetGas

return p