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, ...
local SI  = ic.enums.SorterInstruction  -- Logic Sorter stack opcodes (memory API)
local CO  = ic.enums.ConditionOperation   -- Compare ops inside packed stack words

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
Channel0–Channel7Data 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

SorterInstruction ​

Opcode names for Logic Sorter program rows. Values match the game enum; use them when building filter programs via ic.mem_put / ic.mem_get on the sorter device (same semantics as IC10 memory on the sorter pin). Full bit packing is vanilla game behavior; see the Logic Sorter wiki for row layout.

NameRole
NoneUnused row / padding
FilterPrefabHashEqualsPrefab hash equality filter
FilterPrefabHashNotEqualsPrefab hash inequality filter
FilterSortingClassCompareSorting class compare
FilterSlotTypeCompareSlot type compare
FilterQuantityCompareQuantity compare
LimitNextExecutionByCountCap executions of the following row

ConditionOperation ​

Comparison mode embedded in packed stack words (for example prefab hash filters pair an opcode with Equals or NotEquals).

NameRole
EqualsEqual
GreaterGreater than
LessLess than
NotEqualsNot equal

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)

Editor Completions ​

Both the in-game IC10Editor and VS Code provide contextual autocomplete for enums and constants:

  • Typing ic.enums. shows all available enum tables (LogicType, LogicSlotType, SorterInstruction, ConditionOperation, etc.)
  • Typing ic.enums.LogicType. shows all members with their numeric values
  • Typing ic.const. shows all available constants
  • When typing the second argument of ic.read() or ic.write(), LogicType members are suggested automatically
  • When typing the third argument of ic.read_slot(), LogicSlotType members are suggested automatically

In VS Code, this requires EnableLspServer = true in the mod config. The in-game editor provides these completions automatically.

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.