Skip to content

Enumerations & Constants

Built-in enumerations

Game enumerations are exposed via names and numeric codes under ic.enums. Each table maps name → integer value (for use with ic.read(), ic.write(), and batch helpers).

lua
local LT  = ic.enums.LogicType         -- On, Off, Temperature, Pressure, ...
local LST = ic.enums.LogicSlotType      -- Occupied, Quantity, Charge, ...
local LBM = ic.enums.LogicBatchMethod   -- Average, Sum, Minimum, Maximum
local LRM = ic.enums.LogicReagentMode   -- TotalContents, ...

LogicType (commonly used values)

NameDescription
OnDevice power state (0/1)
OpenDoor/vent open state
TemperatureTemperature in Kelvin
PressurePressure in kPa
SettingGeneric setting value
ModeDevice operating mode
ActivateSensor activation state
ChargeBattery charge (Joules)
MaximumBattery max charge
RatioGeneric ratio (0-1)
PowerPower draw (Watts)
VerticalVertical angle
HorizontalHorizontal angle
ColorPaint color index
ErrorError flag
PrefabHashDevice prefab hash
Channel0Channel7Data network channels
RatioOxygenO₂ gas ratio
RatioCarbonDioxideCO₂ gas ratio
RatioNitrogenN₂ gas ratio
RatioPollutantPollutant gas ratio
RatioMethaneMethane gas ratio (older scripts may still say RatioVolatiles)
RatioWaterH₂O gas ratio
RatioNitrousOxideN₂O gas ratio
RatioHydrogenH₂ gas ratio
RatioSteamSteam ratio
RatioPollutedWaterPolluted water ratio
RatioHydrazineHydrazine ratio
RatioLiquidAlcoholEthanol ratio
RatioHeliumHelium ratio
RatioSilanolSilanol/Coolant ratio
RatioHydrochloricAcidHCl ratio
RatioOzoneOzone ratio
RatioLiquidOzoneLiquid ozone ratio

More ratio names (liquids and pipes)

Analysers, tanks, and many pipe machines expose molar ratios as separate names. Gases use names like RatioOxygen; liquids use RatioLiquid… (for example liquid methane is RatioLiquidMethane). Machines with multiple ports often add Input, Input2, Output, and Output2 suffixes for the same substance.

Typical liquid ratio names you can use with ic.read() / ic.write():

Substance (liquid form)Ratio name
Liquid nitrogenRatioLiquidNitrogen
Liquid oxygenRatioLiquidOxygen
Liquid methaneRatioLiquidMethane
Liquid CO₂RatioLiquidCarbonDioxide
Liquid pollutantRatioLiquidPollutant
Liquid nitrous oxideRatioLiquidNitrousOxide
Liquid hydrogenRatioLiquidHydrogen
Liquid hydrazineRatioLiquidHydrazine
Liquid silanolRatioLiquidSilanol
Liquid hydrochloric acidRatioLiquidHydrochloricAcid
Liquid ozoneRatioLiquidOzone

You can use the optional gas library (Examples/LibraryModule_Gas.lua): it maps gas.TYPE flags to the right ratio name for each substance.

LogicBatchMethod

NameDescription
AverageAverage of all matching values
SumSum of all matching values
MinimumSmallest value
MaximumLargest value

LogicSlotType (commonly used)

NameDescription
OccupiedWhether the slot has an item (0/1)
QuantityStack count in slot
ChargeCharge level of item in slot
MaxQuantityMax stack size
PrefabHashPrefab hash of item in slot

Constants

Constants are under ic.const:

lua
local DB = ic.const.BASE_UNIT_INDEX      -- Housing device index (typically 6)
local BN = ic.const.BASE_NETWORK_INDEX   -- Base network index

BASE_UNIT_INDEX

This is the device index for the IC Housing itself (equivalent to db in IC10). Use it to read/write the housing's own logic values:

lua
-- Write a value to the housing's Setting display
ic.write(ic.const.BASE_UNIT_INDEX, LT.Setting, 42)

-- Read the housing's power state
local powered = ic.read(ic.const.BASE_UNIT_INDEX, LT.On)

Using Enums

lua
local LT = ic.enums.LogicType

-- Use enum names for readable code
print(LT.Temperature)  -- prints the integer value
print(LT.On)           -- prints the integer value

-- Compare with enum values
local temp = ic.read(0, LT.Temperature)

⚠️ This documentation was AI-generated and may contain inaccuracies. Please submit pull requests with corrections as needed.