# generated automatically from known prototypes

from Core.template import Template

class Arithmetic_Display_16SEG_B:
    name = "Arithmetic: 16 segment"
    symbol = "16S-NB"
    width = 2
    description = "Light up 16-segment display and activate lines by bits inside single number"
    fields = []
    inputs = [("V", "Number")]
    outputs = [("bits", "Bits"),("rest", "Rest")]

class Arithmetic_Display_7SEG_B:
    name = "Arithmetic: 7 segment"
    symbol = "7S-NB"
    width = 2
    description = "Light up 7-segment display and activate lines by bits inside single number"
    fields = []
    inputs = [("V", "Number")]
    outputs = [("bits", "Bits"),("rest", "Rest")]

class Average:
    name = "Average"
    symbol = "~A"
    width = 2
    description = "Maintains a running average of <b>input</b> over up to <b>count</b> field samples (default 10). Outputs current sample count to <b>count</b> and the running mean to <b>average</b>. Errors if count < 1."
    fields = [("count", "Count", "NumberField`1")]
    inputs = [("input", "Input")]
    outputs = [("count", "Average"),("average", "Average")]

class Boolean_And_2:
    name = "Boolean: AND"
    symbol = "AND"
    width = 2
    description = "Outputs <b>c</b> = 1 if all connected inputs (<b>a</b>, <b>b</b>, plus any added extensions) are > 0; <b>not_c</b> is the inverse. Add more input pins from the right edge of the module."
    fields = []
    inputs = [("a", "A"),("b", "B")]
    outputs = [("b", "not C"),("a", "C")]

class Boolean_Latch:
    name = "Boolean: NOR-Latch"
    symbol = "NORL"
    width = 2
    description = "When signal set is triggered, output will hold value 1, when signal reset is triggered, output will hold 0. Can be created by two OR gates connected by not C."
    fields = []
    inputs = [("set", "Set"),("reset", "Reset")]
    outputs = [("on", "Stored signal")]

class Boolean_Not:
    name = "Boolean: NOT"
    symbol = "nA"
    width = 1
    description = "Outputs <b>a</b> = 1 if input <b>a</b> is 0 or negative, else 0. Logical inversion of a single input."
    fields = []
    inputs = [("a", "A")]
    outputs = [("a", "not A")]

class Boolean_Or_2:
    name = "Boolean: OR"
    symbol = "OR"
    width = 2
    description = "Outputs <b>c</b> = 1 if any connected input (<b>a</b>, <b>b</b>, or any extension) is > 0; <b>not_c</b> is the inverse. Add more input pins from the right edge of the module."
    fields = []
    inputs = [("a", "A"),("b", "B")]
    outputs = [("b", "not C"),("a", "C")]

class Boolean_Xor:
    name = "Boolean: XOR"
    symbol = "XOR"
    width = 2
    description = "Outputs <b>a</b> = 1 on <b>c</b> if exactly one of <b>a</b>, <b>b</b> is > 0 (logical XOR); otherwise 0. <b>b</b> (<b>not_c</b>) is the inverse."
    fields = []
    inputs = [("a", "A"),("b", "B")]
    outputs = [("b", "not C"),("a", "C")]

class Button_1:
    name = "Button (on/off)"
    symbol = "0/I"
    width = 1
    description = "Manual on/off toggle. Output <b>value</b> is 1 while the toggle display is active, 0 when inactive. Player clicks the display to flip it."
    fields = []
    inputs = []
    outputs = [("value", "On - 1, Off - 0")]

class Button_Pass:
    name = "Button (pass value)"
    symbol = "0/I"
    width = 1
    description = "Manual gate. When the toggle display is active, passes input <b>value</b> straight through to output <b>value</b>; when inactive, outputs 0."
    fields = []
    inputs = [("value", "Value")]
    outputs = [("value", "Value")]

class Compare_Int_Equal:
    name = "Compare: A = B"
    symbol = "A=B"
    width = 2
    description = "Outputs <b>c</b> = 1 if <b>a</b> equals <b>b</b> (input or <b>field_b</b> constant when enabled), else 0. <b>not_c</b> is the inverse."
    fields = [("field_b", "Override input 'b'", "BooleanField"),("b", "B", "NumberField`1")]
    inputs = [("a", "A"),("b", "B")]
    outputs = [("not_c", "not C"),("c", "C")]

class Compare_Int_Greater:
    name = "Compare: A > B"
    symbol = "A>B"
    width = 2
    description = "Outputs <b>c</b> = 1 if <b>a</b> is strictly greater than <b>b</b> (input or <b>field_b</b> constant when enabled), else 0. <b>not_c</b> is the inverse."
    fields = [("field_b", "Override input 'b'", "BooleanField"),("b", "B", "NumberField`1")]
    inputs = [("a", "A"),("b", "B")]
    outputs = [("not_c", "not C"),("c", "C")]

class Compare_Int_GreaterOrEqual:
    name = "Compare: A ≥ B"
    symbol = "A≥B"
    width = 2
    description = "Outputs <b>c</b> = 1 if <b>a</b> is greater than or equal to <b>b</b> (input or <b>field_b</b> constant when enabled), else 0. <b>not_c</b> is the inverse."
    fields = [("field_b", "Override input 'b'", "BooleanField"),("b", "B", "NumberField`1")]
    inputs = [("a", "A"),("b", "B")]
    outputs = [("not_c", "not C"),("c", "C")]

class Compare_Int_Lower:
    name = "Compare: A < B"
    symbol = "A<B"
    width = 2
    description = "Outputs <b>c</b> = 1 if <b>a</b> is strictly less than <b>b</b> (input or <b>field_b</b> constant when enabled), else 0. <b>not_c</b> is the inverse."
    fields = [("field_b", "Override input 'b'", "BooleanField"),("b", "B", "NumberField`1")]
    inputs = [("a", "A"),("b", "B")]
    outputs = [("not_c", "not C"),("c", "C")]

class Compare_Int_LowerOrEqual:
    name = "Compare: A ≤ B"
    symbol = "A≤B"
    width = 2
    description = "Outputs <b>c</b> = 1 if <b>a</b> is less than or equal to <b>b</b> (input or <b>field_b</b> constant when enabled), else 0. <b>not_c</b> is the inverse."
    fields = [("field_b", "Override input 'b'", "BooleanField"),("b", "B", "NumberField`1")]
    inputs = [("a", "A"),("b", "B")]
    outputs = [("not_c", "not C"),("c", "C")]

class Compare_Int_Max:
    name = "Maximum: A or B"
    symbol = "MAX"
    width = 2
    description = "Routes the larger of <b>a</b> and <b>b</b> (input or <b>field_b</b> constant when enabled) to output <b>a</b> (High) and the smaller to output <b>b</b> (Low)."
    fields = [("field_b", "Override input 'b'", "BooleanField"),("b", "B", "NumberField`1")]
    inputs = [("a", "A"),("b", "B")]
    outputs = [("b", "Low"),("a", "High")]

class Connection_Boost_Set:
    name = "Connection: Unity Boost"
    symbol = "BST"
    width = 1
    description = "Drives the Unity boost state of the linked <b>entity</b> from the <b>boost</b> input or <b>boost</b> field (toggled by <b>field_boost</b>) and reflects the current request on the <b>boost</b> output. Errors when no boost-capable entity is linked or when the building has no BoostCost."
    fields = [("entity", "Connection device", "EntityField"),("field_boost", "Override input 'boost'", "BooleanField"),("boost", "Set boost by settings", "BooleanField")]
    inputs = [("boost", "Unity boost active")]
    outputs = [("boost", "Unity boost active")]

class Connection_Controller_Input:
    name = "Connection: Controller (input)"
    symbol = "C-IN"
    width = 4
    description = "Reads pins from a paired <b>Connection_Controller_Output</b> module on a remote Controller, matched by the <b>name</b> field. Outputs the remote inputs through <b>a</b>, <b>b</b>, <b>c</b>, <b>d</b>, plus any extension pins added on the right edge; outputs 0 when no matching module is found or the matching pin is missing on the remote side."
    fields = [("controller", "Connection device", "EntityField"),("name", "Output Name", "StringField")]
    inputs = []
    outputs = [("a", "A"),("b", "B"),("c", "C"),("d", "D")]

class Connection_Controller_Output:
    name = "Connection: Controller (output)"
    symbol = "C-OUT"
    width = 4
    description = "Exposes inputs (<b>a</b>, <b>b</b>, <b>c</b>, <b>d</b>, plus any extensions) under the name set in the <b>name</b> field so a remote <b>Connection_Controller_Input</b> module can read them. Acts as a passive endpoint - it does not drive any entity. Add more input pins from the right edge of the module to bridge more values."
    fields = [("name", "Name", "StringField")]
    inputs = [("a", "A"),("b", "B"),("c", "C"),("d", "D")]
    outputs = []

class Connection_Display:
    name = "Connection: Display - active"
    symbol = "DIA"
    width = 1
    description = "Connects lights and display for activation"
    fields = [("display", "Display", "EntityField"),("field_active", "Override input 'active'", "BooleanField"),("active", "Activate display", "BooleanField")]
    inputs = [("active", "Activate display")]
    outputs = []

class Connection_Display_16SEG_B:
    name = "Connection: Display - 16 segment (2-inputs)"
    symbol = "16-SEG"
    width = 2
    description = "Light up 16-segment display and activate lines by bits inside single number"
    fields = [("display", "Display", "EntityField"),("field_N", "Override input 'N'", "BooleanField"),("N", "Encoded number (Bits, 0-65 535)", "NumberField`1"),("field_DP", "Override input 'DP'", "BooleanField"),("DP", "Dot", "BooleanField")]
    inputs = [("N", "Bits"),("DP", "Dot")]
    outputs = []

class Connection_Display_7SEG_8:
    name = "Connection: Display - 7 segment (8-inputs)"
    symbol = "7-SEGMENT"
    width = 8
    description = "Light up 7-segment display and activate lines per signal"
    fields = [("display", "Display", "EntityField"),("field_A", "Override input 'A'", "BooleanField"),("A", "Signal: A", "BooleanField"),("field_B", "Override input 'B'", "BooleanField"),("B", "Signal: B", "BooleanField"),("field_C", "Override input 'C'", "BooleanField"),("C", "Signal: C", "BooleanField"),("field_D", "Override input 'D'", "BooleanField"),("D", "Signal: D", "BooleanField"),("field_E", "Override input 'E'", "BooleanField"),("E", "Signal: E", "BooleanField"),("field_F", "Override input 'F'", "BooleanField"),("F", "Signal: F", "BooleanField"),("field_G", "Override input 'G'", "BooleanField"),("G", "Signal: G", "BooleanField"),("field_DP", "Override input 'DP'", "BooleanField"),("DP", "Dot", "BooleanField")]
    inputs = [("A", "A"),("B", "B"),("C", "C"),("D", "D"),("E", "E"),("F", "F"),("G", "G"),("DP", "Dot")]
    outputs = []

class Connection_Display_7SEG_B:
    name = "Connection: Display - 7 segment (2-inputs)"
    symbol = "7-SEG"
    width = 2
    description = "Light up 7-segment display and activate lines by bits inside single number"
    fields = [("display", "Display", "EntityField"),("field_N", "Override input 'N'", "BooleanField"),("N", "Encoded number (Bits, 0-127)", "NumberField`1"),("field_DP", "Override input 'DP'", "BooleanField"),("DP", "Dot", "BooleanField")]
    inputs = [("N", "Bits"),("DP", "Dot")]
    outputs = []

class Connection_Display_Color:
    name = "Connection: Display - color"
    symbol = "CLR"
    width = 1
    description = "Drives the LED color of the linked display from the <b>color</b> field (when <b>field_color</b> toggle is on) or <b>color</b> input. Sets both lit and dim color channels on the display entity."
    fields = [("display", "Display", "EntityField"),("field_color", "Override input 'color'", "BooleanField"),("color", "Color", "ColorField")]
    inputs = [("color", "Activate display")]
    outputs = []

class Connection_Export_Get:
    name = "Connection: Export (get)"
    symbol = "EXG"
    width = 1
    description = "Reads the export logistics mode of the linked <b>logistic</b> building to output <b>mode</b> (0 = auto, 1 = on, 2 = off). For buildings with simple logistics, outputs 1 (enabled) or 2 (disabled). Errors if no compatible building is linked."
    fields = [("logistic", "Logistic building", "EntityField")]
    inputs = []
    outputs = [("mode", """Export mode:
  0 (auto),
  1 (on),
  2 (off)""")]

class Connection_Export_Set:
    name = "Connection: Export (set)"
    symbol = "EXS"
    width = 1
    description = "Sets the export logistics mode of the linked <b>logistic</b> building from <b>mode</b> input (0 = auto, 1 = on, 2 = off). For buildings with simple logistics, only on/off is meaningful (mode 2 disables output). Errors if no compatible building is linked."
    fields = [("logistic", "Logistic building", "EntityField")]
    inputs = [("mode", """Export mode:
  0 (auto),
  1 (on),
  2 (off)""")]
    outputs = []

class Connection_Farm:
    name = "Connection: Farm"
    symbol = "FARM"
    width = 4
    description = "Reads and drives the linked <b>farm</b>: outputs current <b>crop</b> slim-id, <b>water</b> (imported + soil), <b>fertility</b> (%), and <b>fertilizer</b> level (%). Writes <b>fertility</b> target and queues the next slot from <b>crop</b> input (slim-id), GreenManure when <b>fertilize</b> > 0, or NoCrop. Errors if no farm is linked or the crop is invalid."
    fields = [("farm", "Managed farm", "EntityField")]
    inputs = [("crop", "Next growing crop"),("fertility", "Target fertility (default: 100)"),("fertilize", "Assign nature fertilizing (0/1)")]
    outputs = [("crop", "Actual growing crop"),("water", "Actual water level (including tank)"),("fertility", "Actual fertility"),("fertilizer", "Actual fertilizer level")]

class Connection_Filter_Get:
    name = "Connection: Filter (get)"
    symbol = "F-G"
    width = 2
    description = "Reads the assigned product slim-id from the linked <b>entity</b> and outputs it on <b>product</b>. Supports storages, train stations, settlement food/service, hospitals, virtual miners, and sorters; the <b>index</b> input/field selects the compartment/slot. Errors if the entity type is unsupported."
    fields = [("entity", "Connection device", "EntityField"),("field_index", "Override input 'index'", "BooleanField"),("index", "Storage compartment", "NumberField`1")]
    inputs = [("index", "Storage compartment")]
    outputs = [("product", "Product type")]

class Connection_Filter_Set:
    name = "Connection: Filter (set)"
    symbol = "F-S"
    width = 2
    description = "Assigns a product filter to the linked <b>entity</b> from the <b>product</b> input or <b>product</b> field (toggled by <b>field_product</b>); the <b>index</b> input/field picks the compartment for multi-slot buildings. Supports storages, cargo depots, train stations, settlement food, hospitals, mine towers, and sorters. Errors if the entity is unsupported or storage is non-empty when re-assigning."
    fields = [("entity", "Building with filter", "EntityField"),("field_index", "Override input 'index'", "BooleanField"),("index", "Storage compartment", "NumberField`1"),("field_product", "Override input 'product'", "BooleanField"),("product", "Filtered product", "ProductField")]
    inputs = [("index", "Storage compartment"),("product", "Product type")]
    outputs = []

class Connection_Import_Get:
    name = "Connection: Import (get)"
    symbol = "IMG"
    width = 1
    description = "Reads the import logistics mode of the linked <b>logistic</b> building to output <b>mode</b> (0 = auto, 1 = on, 2 = off). For buildings with simple logistics, outputs 1 (enabled) or 2 (disabled). Errors if no compatible building is linked."
    fields = [("logistic", "Logistic building", "EntityField")]
    inputs = []
    outputs = [("mode", """Import mode:
  0 (auto),
  1 (on),
  2 (off)""")]

class Connection_Import_Set:
    name = "Connection: Import (set)"
    symbol = "IMS"
    width = 1
    description = "Sets the import logistics mode of the linked <b>logistic</b> building from <b>mode</b> input (0 = auto, 1 = on, 2 = off). For buildings with simple logistics, only on/off is meaningful (mode 2 disables input). Errors if no compatible building is linked."
    fields = [("logistic", "Logistic building", "EntityField")]
    inputs = [("mode", """Import mode:
  0 (auto),
  1 (on),
  2 (off)""")]
    outputs = []

class Connection_IsActive:
    name = "Connection: Status"
    symbol = "STAT"
    width = 4
    description = "Reads operational status of the linked <b>entity</b>. Outputs <b>power</b> (1 when not power-starved or not power-consuming), <b>workers</b> (1 when staffed or no workers needed), <b>constructed</b> (1 when build is finished), and <b>pause</b> (1 when the entity is paused). Errors when no entity is linked."
    fields = [("entity", "Connection device", "EntityField")]
    inputs = []
    outputs = [("power", "Has enough power"),("workers", "Has enough workers"),("constructed", "Is build"),("pause", "Is Paused")]

class Connection_NuclearReactor:
    name = "Connection: Nuclear Reactor"
    symbol = "NR"
    width = 4
    description = "Reads and drives the linked NuclearReactor: outputs <b>heat</b>, <b>meltdown</b> flag, and current <b>power</b>; sets target power level from <b>target</b> input (clamped to reactor max). When <b>breed_control</b> input is on, applies <b>breed_step</b> to the enrichment cycle. Errors if no reactor is linked."
    fields = [("reactor", "Connection reactor", "EntityField"),("field_breeding", "Control breeding", "BooleanField")]
    inputs = [("breed_control", "Control breeding"),("breed_step", "Breeding step"),("target", "Target power level")]
    outputs = [("heat", "Stored Heat"),("meltdown", "Is in melt down"),("power", "Actual power")]

class Connection_Priority_Get:
    name = "Connection: Priority (get)"
    symbol = "P-G"
    width = 1
    description = "Reads the general priority (1-15) of the linked <b>building</b> and outputs it on <b>priority</b>. Errors if no priority-capable building is linked."
    fields = [("building", "Building", "EntityField")]
    inputs = []
    outputs = [("priority", "Priority: 1 - 15")]

class Connection_Priority_Set:
    name = "Connection: Priority (set)"
    symbol = "P-S"
    width = 1
    description = "Sets the general priority (1-15) of the linked <b>logistic</b> building from the <b>priority</b> input (defaults to 8 when unconnected). Errors if no priority-capable building is linked."
    fields = [("logistic", "Logistic building", "EntityField")]
    inputs = [("priority", "Priority: 1 - 15")]
    outputs = []

class Connection_Recipe_Set:
    name = "Connection: Recipe (set)"
    symbol = "REC-S"
    width = 2
    description = "Assigns the recipe selected in the <b>recipe</b> field to the linked <b>entity</b> Machine when <b>on</b> is true (input or <b>on</b> field, toggled by <b>field_on</b>). Clears existing assignments and re-assigns; does nothing while <b>on</b> is false. Errors if no machine is linked, no recipe is selected, or the recipe could not be assigned."
    fields = [("entity", "Building with filter", "EntityField"),("field_on", "Override input 'on'", "BooleanField"),("on", "Active recipe", "BooleanField"),("recipe", "Recipe", "CustomField")]
    inputs = [("on", "Active recipe")]
    outputs = []

class Connection_Settlement:
    name = "Connection: Settlement (population)"
    symbol = "SETTLE"
    width = 2
    description = "Reads the linked SettlementHousingModule <b>entity</b>. Outputs <b>pop_this</b> (population in this housing module) and <b>pop_nearby</b> (population of the parent settlement, falling back to this module). Outputs 0 when no housing is linked."
    fields = [("entity", "Connection device", "EntityField")]
    inputs = [("product", "First Product in #")]
    outputs = [("pop_this", "Population (settlement module)"),("pop_nearby", "Population (settlement total)")]

class Connection_Speaker:
    name = "Connection: Speaker - play"
    symbol = "SPK"
    width = 1
    description = "Drives a Speaker entity's playback state from the <b>play</b> input or <b>play</b> field (boolean, controlled by <b>field_play</b> toggle). Errors if no Speaker is linked in the <b>speaker</b> field."
    fields = [("speaker", "Speaker", "EntityField"),("field_play", "Override input 'play'", "BooleanField"),("play", "Activate sound", "BooleanField")]
    inputs = [("play", "Activate sound")]
    outputs = []

class Connection_Station_TrainInfo:
    name = "Connection: Station"
    symbol = "ST-TR"
    width = 4
    description = "Reads and toggles the linked <b>station</b> (TrainStationBase). Outputs <b>instation</b> (1 when a train of the station group is present) and, for station modules, <b>cargo</b> (1 = loading, 2 = unloading). The <b>direction</b> input switches the module between loading (1) and unloading (2). Errors if no station is linked."
    fields = [("station", "Train station", "EntityField")]
    inputs = [("direction", """Toggle direction:
1 - Loading
2 - Unloading""")]
    outputs = [("instation", "At station"),("cargo", """Working:
1 - Loading
2 - Unloading""")]

class Connection_Storage:
    name = "Connection: Storage"
    symbol = "STOCK"
    width = 4
    description = "Reads the linked storage <b>entity</b> (storages, in/out buffers, virtual miners, FlyWheels, ThermalStorage, Settlements, or Captain Office). Outputs <b>quantity</b>, <b>capacity</b>, <b>fullness</b> (%), and stored <b>product</b> slim-id. With <b>field_product</b> set, filters buffers by the chosen <b>product</b>."
    fields = [("entity", "Connected storage", "EntityField"),("field_product", "Override input 'product'", "BooleanField"),("product", "Product", "ProductField")]
    inputs = [("product", "Product")]
    outputs = [("quantity", "Quantity"),("capacity", "Capacity"),("fullness", "Fullness in %"),("product", "Product in #")]

class Connection_Storage_Flow_In_Get:
    name = "Connection: Flow (in, get)"
    symbol = "FG"
    width = 1
    description = ""
    fields = [("s", "Storage", "EntityField")]
    inputs = []
    outputs = [("p", "Percentage")]

class Connection_Storage_Flow_In_Set:
    name = "Connection: Flow (in, set)"
    symbol = "FS"
    width = 2
    description = ""
    fields = [("s", "Storage", "EntityField")]
    inputs = [("p", "Percentage")]
    outputs = []

class Connection_Storage_Flow_Out_Get:
    name = "Connection: Flow (out, get)"
    symbol = "FG"
    width = 1
    description = ""
    fields = [("s", "Storage", "EntityField")]
    inputs = []
    outputs = [("p", "Percentage")]

class Connection_Storage_Flow_Out_Set:
    name = "Connection: Flow (out, set)"
    symbol = "FS"
    width = 2
    description = ""
    fields = [("s", "Storage", "EntityField")]
    inputs = [("p", "Percentage")]
    outputs = []

class Connection_Storage_Logistics_In_Get:
    name = "Connection: Logistics (in, get)"
    symbol = "LG"
    width = 1
    description = ""
    fields = [("s", "Storage", "EntityField")]
    inputs = []
    outputs = [("p", "Percentage")]

class Connection_Storage_Logistics_In_Set:
    name = "Connection: Logistics (in, set)"
    symbol = "LS"
    width = 2
    description = ""
    fields = [("s", "Storage / Station", "EntityField")]
    inputs = [("p", "Percentage")]
    outputs = []

class Connection_Storage_Logistics_Out_Get:
    name = "Connection: Logistics (out, get)"
    symbol = "LG"
    width = 1
    description = ""
    fields = [("s", "Storage", "EntityField")]
    inputs = []
    outputs = [("p", "Percentage")]

class Connection_Storage_Logistics_Out_Set:
    name = "Connection: Logistics (out, set)"
    symbol = "LS"
    width = 2
    description = ""
    fields = [("s", "Storage / Station", "EntityField")]
    inputs = [("p", "Percentage")]
    outputs = []

class Connection_SwitchOff:
    name = "Connection: Switch Off"
    symbol = "S"
    width = 1
    description = "Pauses or unpauses the linked <b>entity</b> based on <b>pause</b> input (>0 pauses, otherwise resumes). Supports any pausable building and CargoDepots (forwards to the moored CargoShip). Errors if the <b>entity</b> is unset or unsupported."
    fields = [("entity", "Connection device", "EntityField")]
    inputs = [("pause", "Pause")]
    outputs = []

class Connection_Transport:
    name = "Connection: Transport"
    symbol = "TRANS"
    width = 4
    description = "Transport connectable by cable 40m from controller"
    fields = [("entity", "Connection device", "EntityField"),("fullstack", "Cap fullness to 100%", "BooleanField"),("field_product", "Override input 'product'", "BooleanField"),("product", "Product", "ProductField")]
    inputs = [("direction", """Flip direction:
1 - from close port to far port
2 - from far port to close port"""),("product", "Product filter")]
    outputs = [("quantity", "Quantity"),("capacity", "Capacity"),("fullness", "Fullness in %"),("moving", "Is moving")]

class Connection_Vehicle_Get:
    name = "Connection: Vehicle count (get)"
    symbol = "V-G"
    width = 4
    description = "Reads the vehicle count assigned to the linked <b>building</b>. With a vehicle type chosen via the <b>vehicle</b> input or <b>vehicle</b> field (toggled by <b>field_vehicle</b>), outputs the count of that type to <b>count</b>; otherwise outputs the total count of all assigned vehicles. Errors if no building is linked or the type is invalid."
    fields = [("building", "Building", "EntityField"),("field_vehicle", "Override input 'vehicle'", "BooleanField"),("vehicle", "Vehicle", "EntityTypeField`1")]
    inputs = [("vehicle", "Vehicle type")]
    outputs = [("count", "Vehicle count")]

class Connection_Vehicle_Set:
    name = "Connection: Vehicle count (set)"
    symbol = "V-S"
    width = 4
    description = "Sets count of vehicles assigned to the building, by default it takes vehicles from all zones."
    fields = [("building", "Building", "EntityField"),("field_vehicle", "Override input 'vehicle'", "BooleanField"),("vehicle", "Vehicle", "EntityTypeField`1"),("field_count", "Override input 'count'", "BooleanField"),("count", "Vehicle count", "NumberField`1"),("zone", "Vehicle zone", "CustomField")]
    inputs = [("count", "Vehicle count"),("vehicle", "Vehicle type")]
    outputs = []

class Constant:
    name = "Constant (integer)"
    symbol = "#I"
    width = 1
    description = "Outputs the integer stored in the <b>number</b> field on output <b>value</b>. Used as a literal source in arithmetic chains."
    fields = [("number", "Number", "NumberField`1")]
    inputs = []
    outputs = [("value", "Value")]

class Constant_Boolean:
    name = "Constant (boolean)"
    symbol = "#B"
    width = 1
    description = "Outputs 1 if the <b>boolean</b> field is checked, 0 otherwise. The output value is a Fix32 of 0 or 1."
    fields = [("boolean", "Boolean", "BooleanField")]
    inputs = []
    outputs = [("value", "Value")]

class Constant_Crop:
    name = "Constant (crop)"
    symbol = "#C"
    width = 1
    description = "Outputs the crop product slim-id selected in the <b>crop</b> field on output <b>value</b>. Field is restricted to crop products only via FarmProductFilter."
    fields = [("crop", "Crop", "ProductField")]
    inputs = []
    outputs = [("value", "Value")]

class Constant_Float:
    name = "Constant (float)"
    symbol = "#F"
    width = 1
    description = "Outputs the fixed-point decimal stored in the <b>float</b> field on output <b>value</b>. Use when fractional constants are needed (e.g. ratios, multipliers)."
    fields = [("float", "Float", "NumberField`1")]
    inputs = []
    outputs = [("value", "Value")]

class Constant_Hex:
    name = "Constant (hex)"
    symbol = "#H"
    width = 1
    description = "Outputs the hexadecimal integer stored in the <b>number</b> field on output <b>value</b>. Useful as a bitmask source for boolean/bit operations."
    fields = [("number", "Number", "NumberField`1")]
    inputs = []
    outputs = [("value", "Value")]

class Constant_Machine:
    name = "Constant (machine)"
    symbol = "#M"
    width = 1
    description = "Outputs the MachineProto id selected in the <b>machine</b> field on output <b>value</b>. Used to identify a machine type for downstream connection modules."
    fields = [("machine", "Machine", "EntityTypeField`1")]
    inputs = []
    outputs = [("value", "Value")]

class Constant_Product:
    name = "Constant (product)"
    symbol = "#P"
    width = 1
    description = "Outputs the product slim-id selected in the <b>product</b> field on output <b>value</b>. Pair with filter/sorter modules to identify a product type."
    fields = [("product", "Product", "ProductField")]
    inputs = []
    outputs = [("value", "Value")]

class Constant_Vehicle:
    name = "Constant (vehicle)"
    symbol = "#V"
    width = 1
    description = "Outputs the DrivingEntityProto (vehicle) id selected in the <b>vehicle</b> field on output <b>value</b>. Used to identify a vehicle type for downstream connection modules."
    fields = [("vehicle", "vehicle", "EntityTypeField`1")]
    inputs = []
    outputs = [("value", "Value")]

class Decision_Select_4:
    name = "Select (3 pins, integer)"
    symbol = "SEL-3"
    width = 4
    description = "Routes the first input whose threshold field (<b>a</b>..<b>b</b>) is >= <b>index</b> to <b>selected</b>; falls back to <b>else</b> if none match."
    fields = [("a", "A: Index ≤", "NumberField`1"),("b", "B: Index ≤", "NumberField`1")]
    inputs = [("index", "Index"),("a", "A"),("b", "B"),("else", "Else")]
    outputs = [("selected", "Selected")]

class Decision_Select_8:
    name = "Select (7 pins, integer)"
    symbol = "SEL-7"
    width = 8
    description = "Routes the first input whose threshold field (<b>a</b>..<b>f</b>) is >= <b>index</b> to <b>selected</b>; falls back to <b>else</b> if none match."
    fields = [("a", "A: Index ≤", "NumberField`1"),("b", "B: Index ≤", "NumberField`1"),("c", "C: Index ≤", "NumberField`1"),("d", "D: Index ≤", "NumberField`1"),("e", "E: Index ≤", "NumberField`1"),("f", "F: Index ≤", "NumberField`1")]
    inputs = [("index", "Index"),("a", "A"),("b", "B"),("c", "C"),("d", "D"),("e", "E"),("f", "F"),("else", "Else")]
    outputs = [("selected", "Selected")]

class Display_Bool:
    name = "Display: LED"
    symbol = "F-B"
    width = 1
    description = "Lights an LED on display <b>a</b> when input <b>a</b> is greater than 0; otherwise the LED is off. Treats any positive numeric value as truthy."
    fields = []
    inputs = [("a", "Product")]
    outputs = []

class Display_Entity:
    name = "Display: entity"
    symbol = "F-E"
    width = 1
    description = "Renders the icon of the entity prototype referenced by input <b>a</b> (machine, vehicle, etc.) to display <b>a</b>. Useful for identifying entity types visually."
    fields = []
    inputs = [("a", "Entity")]
    outputs = []

class Display_Int:
    name = "Display: number"
    symbol = "F#"
    width = 2
    description = "Formats input <b>a</b> as a decimal number display.  Use the <b>+</b> / <b>-</b> buttons in the display row to grow the digit count (4 digits at minimum, up to 32 by adding cells); the <b>float</b> field picks how many of those digits are fractional."
    fields = [("float", "Floating numbers", "NumberField`1")]
    inputs = [("a", "A")]
    outputs = []

class Display_Product:
    name = "Display: product"
    symbol = "F-P"
    width = 1
    description = "Renders the icon of the product whose slim-id arrives on input <b>a</b> to display <b>a</b>. Used to visually identify the current product in a chain."
    fields = []
    inputs = [("a", "Product")]
    outputs = []

class Divide:
    name = "C = A divide by B"
    symbol = "A/B"
    width = 2
    description = "Outputs <b>a</b> / <b>b</b> to <b>c</b>. If <b>b</b> is zero, sets output <b>error</b> to 1 and <b>c</b> to Fix32.MaxValue; otherwise <b>error</b> is 0. <b>field_b</b> switches <b>b</b> to the constant field."
    fields = [("field_b", "Override input 'b'", "BooleanField"),("b", "B", "NumberField`1")]
    inputs = [("a", "A"),("b", "B")]
    outputs = [("c", "C"),("error", "Error")]

class Fork_2:
    name = "Fork: 1 pin to 2"
    symbol = "F-2"
    width = 2
    description = "Is used for organizing of pin connection. Is not required to use, output may be connected to multiple inputs"
    fields = []
    inputs = [("a", "A")]
    outputs = [("a", "A"),("b", "B")]

class Fork_4:
    name = "Fork: 1 pin to 4"
    symbol = "F-4"
    width = 4
    description = "Is used for organizing of pin connection. Is not required to use, output may be connected to multiple inputs"
    fields = []
    inputs = [("a", "A")]
    outputs = [("a", "A"),("b", "B"),("c", "C"),("d", "D")]

class Game_Pause:
    name = "Pause game (DEBUG)"
    symbol = "GP"
    width = 1
    description = "Debug-only module: when input <b>pause</b> > 0, requests a global game pause via GameSpeedController and lights the info indicator."
    fields = []
    inputs = [("pause", "Pause")]
    outputs = []

class Invert:
    name = "B = -A"
    symbol = "-A"
    width = 1
    description = "Outputs the arithmetic negation of <b>a</b> (i.e. <b>0 - a</b>) to <b>b</b>. Use to flip the sign of a numeric signal."
    fields = []
    inputs = [("a", "A")]
    outputs = [("b", "B")]

class Modulo:
    name = "C = A modulo B"
    symbol = "A%B"
    width = 2
    description = "Outputs <b>a</b> % <b>b</b> to <b>c</b>. If <b>b</b> is zero, sets output <b>error</b> to 1 and <b>c</b> to 0; otherwise <b>error</b> is 0. <b>field_b</b> switches <b>b</b> to the constant field."
    fields = [("field_b", "Override input 'b'", "BooleanField"),("b", "B", "NumberField`1")]
    inputs = [("a", "A"),("b", "B")]
    outputs = [("c", "C"),("error", "Error")]

class Multiply:
    name = "C = A multiply by B"
    symbol = "A*B"
    width = 2
    description = "Outputs <b>a</b> * <b>b</b> to <b>c</b>. If the <b>field_b</b> toggle is on, the constant <b>b</b> field is used as the multiplier instead of the input pin."
    fields = [("field_b", "Override input 'b'", "BooleanField"),("b", "B", "NumberField`1")]
    inputs = [("a", "A"),("b", "B")]
    outputs = [("c", "C")]

class Notification_Error:
    name = "Notification: Error"
    symbol = """NOTIF
ERR"""
    width = 2
    description = "Returns Error status while input <b>in</b> is on so the controller raises an error notification; otherwise returns Running."
    fields = []
    inputs = [("in", "State")]
    outputs = []

class Notification_Info:
    name = "Notification: Info"
    symbol = """NOTIF
INF"""
    width = 2
    description = "Sets the controller's <b>Info</b> flag from input <b>in</b>; the controller surfaces an info notification while the input is on."
    fields = []
    inputs = [("in", "State")]
    outputs = []

class Notification_Warning:
    name = "Notification: Warning"
    symbol = """NOTIF
WRN"""
    width = 2
    description = "Sets the controller's <b>Warning</b> flag from input <b>in</b>; the controller surfaces a warning notification while the input is on."
    fields = []
    inputs = [("in", "State")]
    outputs = []

class PLC_PY:
    name = "Custom: PLC (Python)"
    symbol = "PLC-PY"
    width = 4
    description = "Player-programmable logic controller — Python flavor. Write a Python script in the <b>code</b> field that reads <b>self.Input</b>, writes <b>self.Output</b>, and accesses <b>self.Field</b>/<b>self.Display</b>/<b>self.Array</b> like any other module. The script may use <b>init:</b> (runs once / on recovery) and <b>main:</b> (runs every tick) sections; top-level <b>def</b>s outside the sections are shared between them. Computing cost scales with the script size (0.5 + 0.01 per lexer token); requires T3 maintenance."
    fields = [("name", "Name", "StringField"),("code", "Code", "StringField"),("editor", "Edit code", "CustomField")]
    inputs = [("A", "A"),("B", "B"),("C", "C"),("D", "D")]
    outputs = [("A", "A"),("B", "B"),("C", "C"),("D", "D")]

class Radio_In_AM:
    name = "AM receiver"
    symbol = "AM-R"
    width = 2
    description = "Reads the AM channel selected in the <b>am</b> field via the linked <b>antena</b> and outputs the received value on <b>am</b>. Errors and outputs 0 if no antena is connected."
    fields = [("am", "AM", "CustomField"),("antena", "Antena", "EntityField")]
    inputs = []
    outputs = [("am", "AM signal")]

class Radio_In_FM_16:
    name = "FM receiver (16 signals)"
    symbol = "FM-R"
    width = 16
    description = "Listens on the FM channel from the <b>fm</b> field and emits up to 16 signals on outputs <b>a</b>..<b>q</b>, plus reception strength on <b>signal</b> and ID3 channel name on display <b>id3</b>. Outputs zero when out of range."
    fields = [("fm", "FM", "CustomField"),("id3", "ID3 (name)", "CustomField"),("logging", "Enable debug log of antene", "BooleanField")]
    inputs = []
    outputs = [("a", "A"),("b", "B"),("c", "C"),("d", "D"),("e", "E"),("f", "F"),("g", "G"),("h", "H"),("i", "I"),("j", "J"),("k", "K"),("m", "M"),("n", "N"),("o", "O"),("p", "P"),("q", "Q")]

class Radio_In_FM_2:
    name = "FM receiver (2 signals)"
    symbol = "FM-R"
    width = 2
    description = "Listens on the FM channel from the <b>fm</b> field and emits up to 2 signals on outputs <b>a</b>..<b>b</b>, plus reception strength on <b>signal</b> and ID3 channel name on display <b>id3</b>. Outputs zero when out of range."
    fields = [("fm", "FM", "CustomField"),("id3", "ID3 (name)", "CustomField"),("logging", "Enable debug log of antene", "BooleanField")]
    inputs = []
    outputs = [("a", "A"),("b", "B")]

class Radio_In_FM_4:
    name = "FM receiver (4 signals)"
    symbol = "FM-R"
    width = 4
    description = "Listens on the FM channel from the <b>fm</b> field and emits up to 4 signals on outputs <b>a</b>..<b>d</b>, plus reception strength on <b>signal</b> and ID3 channel name on display <b>id3</b>. Outputs zero when out of range."
    fields = [("fm", "FM", "CustomField"),("id3", "ID3 (name)", "CustomField"),("logging", "Enable debug log of antene", "BooleanField")]
    inputs = []
    outputs = [("a", "A"),("b", "B"),("c", "C"),("d", "D")]

class Radio_In_FM_8:
    name = "FM receiver (8 signals)"
    symbol = "FM-R"
    width = 8
    description = "Listens on the FM channel from the <b>fm</b> field and emits up to 8 signals on outputs <b>a</b>..<b>h</b>, plus reception strength on <b>signal</b> and ID3 channel name on display <b>id3</b>. Outputs zero when out of range."
    fields = [("fm", "FM", "CustomField"),("id3", "ID3 (name)", "CustomField"),("logging", "Enable debug log of antene", "BooleanField")]
    inputs = []
    outputs = [("a", "A"),("b", "B"),("c", "C"),("d", "D"),("e", "E"),("f", "F"),("g", "G"),("h", "H")]

class Radio_Out_AM:
    name = "AM broadcaster"
    symbol = "AM-B"
    width = 2
    description = "Broadcasts input <b>am</b> on the AM channel selected in the <b>am</b> field via the linked <b>antena</b>. Skips while the antena is disabled or paused; errors if no antena is connected."
    fields = [("am", "AM", "CustomField"),("antena", "Antena", "EntityField")]
    inputs = [("am", "AM signal")]
    outputs = []

class Radio_Out_FM_16:
    name = "FM broadcaster (16 signals)"
    symbol = "FM-B"
    width = 16
    description = "Broadcasts up to 16 input signals (<b>a</b>..<b>q</b>) on the FM channel from the <b>fm</b> field via the linked <b>antena</b>, tagging the stream with the <b>id3</b> field. Errors if no antena is connected."
    fields = [("fm", "FM", "CustomField"),("id3", "ID3 (name)", "StringField"),("antena", "Antena", "EntityField"),("logging", "Enable debug log of antene", "BooleanField")]
    inputs = [("a", "A"),("b", "B"),("c", "C"),("d", "D"),("e", "E"),("f", "F"),("g", "G"),("h", "H"),("i", "I"),("j", "J"),("k", "K"),("m", "M"),("n", "N"),("o", "O"),("p", "P"),("q", "Q")]
    outputs = []

class Radio_Out_FM_2:
    name = "FM broadcaster (2 signals)"
    symbol = "FM-B"
    width = 2
    description = "Broadcasts up to 2 input signals (<b>a</b>..<b>b</b>) on the FM channel from the <b>fm</b> field via the linked <b>antena</b>, tagging the stream with the <b>id3</b> field. Errors if no antena is connected."
    fields = [("fm", "FM", "CustomField"),("id3", "ID3 (name)", "StringField"),("antena", "Antena", "EntityField"),("logging", "Enable debug log of antene", "BooleanField")]
    inputs = [("a", "A"),("b", "B")]
    outputs = []

class Radio_Out_FM_4:
    name = "FM broadcaster (4 signals)"
    symbol = "FM-B"
    width = 4
    description = "Broadcasts up to 4 input signals (<b>a</b>..<b>d</b>) on the FM channel from the <b>fm</b> field via the linked <b>antena</b>, tagging the stream with the <b>id3</b> field. Errors if no antena is connected."
    fields = [("fm", "FM", "CustomField"),("id3", "ID3 (name)", "StringField"),("antena", "Antena", "EntityField"),("logging", "Enable debug log of antene", "BooleanField")]
    inputs = [("a", "A"),("b", "B"),("c", "C"),("d", "D")]
    outputs = []

class Radio_Out_FM_8:
    name = "FM broadcaster (8 signals)"
    symbol = "FM-B"
    width = 8
    description = "Broadcasts up to 8 input signals (<b>a</b>..<b>h</b>) on the FM channel from the <b>fm</b> field via the linked <b>antena</b>, tagging the stream with the <b>id3</b> field. Errors if no antena is connected."
    fields = [("fm", "FM", "CustomField"),("id3", "ID3 (name)", "StringField"),("antena", "Antena", "EntityField"),("logging", "Enable debug log of antene", "BooleanField")]
    inputs = [("a", "A"),("b", "B"),("c", "C"),("d", "D"),("e", "E"),("f", "F"),("g", "G"),("h", "H")]
    outputs = []

class Randomizer:
    name = "Randomizer"
    symbol = "RAN"
    width = 1
    description = "Pseudo-random generator: emits a deterministic sequence on <b>value</b> seeded by the <b>seed</b> field; each tick advances by input <b>addition</b> (default 256). Re-seeding restarts the sequence."
    fields = [("seed", "Number seed", "NumberField`1")]
    inputs = [("addition", "Grain value")]
    outputs = [("value", "Random value")]

class Runtime_Clock_1:
    name = "Control: Clock (1 output)"
    symbol = "CLK"
    width = 1
    description = "Outputs an integer counter on <b>clock</b> that increments every <b>clock_period</b> ticks and wraps to zero at <b>max_count</b>. With the <b>mode</b> field on, output instead pulses true only on the tick where the counter would change. An optional <b>reset</b> input holds the clock at zero and suppresses output while non-zero; counting resumes when reset goes back to zero."
    fields = [("mode", "Pulse mode", "BooleanField"),("clock_period", "Clock Period", "NumberField`1"),("max_count", "Max Output", "NumberField`1")]
    inputs = [("reset", "Reset (hold non-zero to freeze at 0)")]
    outputs = [("clock", "Clock")]

class Runtime_Clock_2:
    name = "Control: Clock (2 outputs)"
    symbol = "CLK"
    width = 2
    description = "Outputs an integer counter on <b>clock</b> that increments every <b>clock_period</b> ticks and wraps to zero at <b>max_count</b>, plus an <b>update</b> boolean that pulses true on every tick where the counter changes. An optional <b>reset</b> input holds the clock at zero and suppresses output while non-zero; counting resumes when reset goes back to zero."
    fields = [("clock_period", "Clock Period", "NumberField`1"),("max_count", "Reset value", "NumberField`1")]
    inputs = [("reset", "Reset (hold non-zero to freeze at 0)")]
    outputs = [("update", "Updated this tick"),("clock", "Clock")]

class Runtime_Delay_1:
    name = "Control: Delay (configurable)"
    symbol = "DLY"
    width = 1
    description = "Delays input <b>input</b> by the number of ticks set in the <b>delay</b> field, then emits the same signal on <b>output</b>. A delay of 1 (or less) passes the value through unchanged. Maximum delay is 64 ticks. When the field is increased the new tail of the buffer is seeded with the most recent sample so the output stays continuous; when shrunk the oldest pending samples continue to emit in order."
    fields = [("delay", "Delay", "NumberField`1")]
    inputs = [("input", "Signal input")]
    outputs = [("output", "Signal output")]

class Runtime_Delay_Tap:
    name = "Control: Delay (taps)"
    symbol = "DLY"
    width = 2
    description = "Multi-stage shift register: each output tap holds the input from N ticks ago, where N matches the tap label.  Add more taps from the right edge of the module."
    fields = []
    inputs = [("0", "Signal input")]
    outputs = [("1", "Delay by 1 tick")]

class Runtime_Equal_Selector:
    name = "Control: Equal Selector"
    symbol = "MS"
    width = 2
    description = "Compares <b>main</b> against the connected data inputs (<b>in_0</b>, plus any added extensions); outputs the index of the lowest match on <b>matching_index</b> and sets <b>output</b> to 1.  If nothing matches, <b>matching_index</b> is 99 and <b>output</b> is 0.  Add more input pins from the right edge of the module."
    fields = []
    inputs = [("main", "Main Input"),("in_0", "Input 0")]
    outputs = [("matching_index", "Index of equal input"),("output", "Match with any input")]

class Runtime_FlipFlop:
    name = "Control: Flip-Flop"
    symbol = "FLIP-FLOP"
    width = 2
    description = "When <b>enable</b> is on, copies each connected channel input to the matching output and remembers it; while <b>enable</b> is off, outputs keep their last stored values. Add more channel pin pairs from the right edge of the module."
    fields = []
    inputs = [("enable", "Enable"),("in_1", "A")]
    outputs = [("out_1", "A")]

class Runtime_Max:
    name = "Max"
    symbol = "MAX"
    width = 2
    description = "Outputs the smallest of all connected inputs (<b>A</b>, <b>B</b>, plus any added extensions) on <b>min</b> and the largest on <b>max</b>. Add more input pins from the right edge of the module. Unconnected inputs are ignored."
    fields = []
    inputs = [("A", "A"),("B", "B")]
    outputs = [("min", "Min"),("max", "Max")]

class Runtime_Memory_Selector_1:
    name = "Control: Memory Selector (1 input)"
    symbol = "MS"
    width = 1
    description = "When <b>in_1</b> is positive, outputs the value of field <b>field_1</b>; otherwise outputs the <b>default</b> field. Single-input lookup table."
    fields = [("default", "Default", "NumberField`1"),("field_1", "1 value", "NumberField`1")]
    inputs = [("in_1", "Signal input")]
    outputs = [("output", "Signal output")]

class Runtime_Memory_Selector_2:
    name = "Control: Memory Selector (2 inputs)"
    symbol = "MS"
    width = 2
    description = "Priority lookup: outputs the value of <b>field_2</b> if <b>in_2</b> is positive, else <b>field_1</b> if <b>in_1</b> is positive, else the <b>default</b> field. Higher-numbered inputs win ties."
    fields = [("default", "Default", "NumberField`1"),("field_1", "1 value", "NumberField`1"),("field_2", "2 value", "NumberField`1")]
    inputs = [("in_1", "Input 1"),("in_2", "Input 2")]
    outputs = [("output", "Signal output")]

class Runtime_Memory_Selector_4:
    name = "Control: Memory Selector (4 inputs)"
    symbol = "MEM SELECT"
    width = 4
    description = "Priority lookup: scans inputs <b>in_4</b> down to <b>in_1</b> and outputs the value of the matching <b>field_n</b> for the first positive input; falls back to the <b>default</b> field. Higher-numbered inputs win ties."
    fields = [("default", "Default", "NumberField`1"),("field_1", "1 value", "NumberField`1"),("field_2", "2 value", "NumberField`1"),("field_3", "3 value", "NumberField`1"),("field_4", "4 value", "NumberField`1")]
    inputs = [("in_1", "Input 1"),("in_2", "Input 2"),("in_3", "Input 3"),("in_4", "Input 4")]
    outputs = [("output", "Signal output")]

class Runtime_Memory_Selector_6:
    name = "Control: Memory Selector (6 inputs)"
    symbol = "Memory Selector"
    width = 6
    description = "Priority lookup: scans inputs <b>in_6</b> down to <b>in_1</b> and outputs the value of the matching <b>field_n</b> for the first positive input; falls back to the <b>default</b> field. Higher-numbered inputs win ties."
    fields = [("default", "Default", "NumberField`1"),("field_1", "1 value", "NumberField`1"),("field_2", "2 value", "NumberField`1"),("field_3", "3 value", "NumberField`1"),("field_4", "4 value", "NumberField`1"),("field_5", "5 value", "NumberField`1"),("field_6", "6 value", "NumberField`1")]
    inputs = [("in_1", "Input 1"),("in_2", "Input 2"),("in_3", "Input 3"),("in_4", "Input 4"),("in_5", "Input 5"),("in_6", "Input 6")]
    outputs = [("output", "Signal output")]

class Runtime_Memory_Selector_8:
    name = "Control: Memory Selector (8 inputs)"
    symbol = "Memory Selector"
    width = 8
    description = "Priority lookup: scans inputs <b>in_8</b> down to <b>in_1</b> and outputs the value of the matching <b>field_n</b> for the first positive input; falls back to the <b>default</b> field. Higher-numbered inputs win ties."
    fields = [("default", "Default", "NumberField`1"),("field_1", "1 value", "NumberField`1"),("field_2", "2 value", "NumberField`1"),("field_3", "3 value", "NumberField`1"),("field_4", "4 value", "NumberField`1"),("field_5", "5 value", "NumberField`1"),("field_6", "6 value", "NumberField`1"),("field_7", "7 value", "NumberField`1"),("field_8", "8 value", "NumberField`1")]
    inputs = [("in_1", "Input 1"),("in_2", "Input 2"),("in_3", "Input 3"),("in_4", "Input 4"),("in_5", "Input 5"),("in_6", "Input 6"),("in_7", "Input 7"),("in_8", "Input 8")]
    outputs = [("output", "Signal output")]

class Runtime_Shift:
    name = "Control: Shift"
    symbol = "SHIFT"
    width = 3
    description = "Cyclic shifter: <b>index</b> picks how far to rotate the channel inputs (<b>0</b>, <b>1</b>, plus any added extensions) onto the matching outputs.  Output <b>index</b> echoes the wrapped index.  Add more channel pin pairs from the right edge of the module."
    fields = []
    inputs = [("index", "Index"),("0", "Input 0"),("1", "Input 1")]
    outputs = [("index", "Index"),("0", "Output 0"),("1", "Output 1")]

class Runtime_Timer:
    name = "Control: Timer"
    symbol = "TMR"
    width = 2
    description = "Counts up by 1 each tick on output <b>timer</b> until it reaches the period (input <b>timer_period</b> or the field, ~10 ticks/s); when it does, <b>done</b> turns on and the counter holds. Triggering <b>reset</b> clears <b>timer</b> and <b>done</b>."
    fields = [("timer_period", "Timer Period (ticks)", "NumberField`1")]
    inputs = [("reset", "Reset Timer"),("timer_period", "Timer Period")]
    outputs = [("timer", "Timer"),("done", "Is done")]

class Stats_Electricity:
    name = "Statistic: Electricity"
    symbol = "PWR"
    width = 4
    description = "Reads global ElectricityManager metrics for the current tick. Outputs <b>consumption</b> (DemandedThisTick), <b>production</b> (GeneratedThisTick), <b>capacity</b> (GenerationCapacityThisTick) in kW, and <b>usage</b> as percentage 0-100 of consumption / capacity."
    fields = []
    inputs = []
    outputs = [("consumption", "Consumption"),("production", "Production"),("capacity", "Power capacity"),("demand", "Power demand")]

class Stats_Maintenance:
    name = "Connection: Maintenance"
    symbol = "MAINT"
    width = 4
    description = "Reads maintenance buffer of the linked MaintenanceDepot for the selected tier (<b>m</b> field). Outputs current <b>a</b> amount, <b>c</b> capacity, <b>p</b> percentage 0-100, and monthly <b>u</b> use (positive surplus / negative deficit)."
    fields = [("depot", "Maintenance depot", "EntityField"),("m", "Maintenance tier", "ProductField")]
    inputs = []
    outputs = [("a", "Amount"),("c", "Capacity"),("p", "Percentage (0-100)"),("u", "Use (monthly +surplus / -deficit)")]

class Stats_Unity:
    name = "Connection: Office - Unity"
    symbol = "UNI"
    width = 1
    description = "Reads the captain's current Unity total via UpointsManager and outputs it on <b>v</b>. Errors if no CaptainOffice is linked in the <b>office</b> field."
    fields = [("office", "Captains office", "EntityField")]
    inputs = []
    outputs = [("v", "Unity value")]

class Stats_Vehicle:
    name = "Connection: Office - Vehicles"
    symbol = "VEH"
    width = 2
    description = "Reads vehicle stats via IVehiclesManager. With a vehicle type chosen via input or <b>vehicle</b> field: outputs <b>count</b> (owned) and <b>assignable</b>. Without selection: outputs total fleet count to <b>count</b> and 0 to <b>assignable</b>. Errors if no CaptainOffice is linked."
    fields = [("office", "Captains office", "EntityField"),("field_vehicle", "Override input 'vehicle'", "BooleanField"),("vehicle", "Vehicle", "EntityTypeField`1")]
    inputs = [("vehicle", "Amount of owned vehicle/ship (all when unselected)"),("vehicle", "Vehicle type")]
    outputs = [("count", "Amount of owned vehicle/ship (all when unselected)"),("assignable", "Amount of assignable vehicle/ship (all when unselected)")]

class Stats_Workers:
    name = "Connection: Office - Workers"
    symbol = "WRK"
    width = 4
    description = "Reads worker statistics from WorkersManager. Outputs used <b>u</b>, available <b>a</b>, missing <b>m</b> (deficit, positive when short), and total <b>t = u + a</b>. Errors if no CaptainOffice is linked."
    fields = [("office", "Captains office", "EntityField")]
    inputs = []
    outputs = [("u", "Used workers"),("a", "Available workers"),("m", "Missing workers"),("t", "Total workers")]

class Sub:
    name = "C = A - B"
    symbol = "A-B"
    width = 2
    description = "Outputs <b>a</b> - <b>b</b> to <b>c</b>. If the <b>field_b</b> toggle is on, the constant <b>b</b> field is subtracted instead of the input pin."
    fields = [("field_b", "Override input 'b'", "BooleanField"),("b", "B", "NumberField`1")]
    inputs = [("a", "A"),("b", "B")]
    outputs = [("c", "C")]

class Sum:
    name = "C = A + B"
    symbol = "A+B"
    width = 2
    description = "Outputs <b>a</b> + <b>b</b> (+ extra inputs) to <b>c</b>. If the <b>field_b</b> toggle is on, the constant <b>b</b> field is used instead of the input pin (see FieldOrInput). Up to six extra input pins (<b>c</b> through <b>h</b>) can be added on the right via the inspector and are included in the sum."
    fields = [("field_b", "Override input 'b'", "BooleanField"),("b", "B", "NumberField`1")]
    inputs = [("a", "A"),("b", "B")]
    outputs = [("c", "Sum")]

class VariableNetwork_Read:
    name = "Network Variable (read)"
    symbol = "*N"
    width = 1
    description = "Reads the global network variable identified by the <b>name</b> field via VariableManager and outputs its current value on <b>value</b>. Errors if <b>name</b> is empty."
    fields = [("name", "Variable name", "StringField"),("variables", "Variables", "CustomField")]
    inputs = []
    outputs = [("value", "Value")]

class VariableNetwork_Write:
    name = "Network Variable (write)"
    symbol = "*N"
    width = 1
    description = "Writes input <b>value</b> (or the constant <b>value</b> field when <b>field_value</b> is on) into the global network variable identified by the <b>name</b> field via VariableManager. Errors if <b>name</b> is empty."
    fields = [("name", "Variable name", "StringField"),("field_value", "Override input 'value'", "BooleanField"),("value", "Value", "NumberField`1"),("variables", "Variables", "CustomField")]
    inputs = [("value", "Value")]
    outputs = []

class Variable_Read:
    name = "Variable (read)"
    symbol = "*C"
    width = 1
    description = "Reads a controller-local variable: searches the same Controller for a <b>Variable_Write</b> module with a matching <b>name</b> field and outputs its <b>value</b> on <b>value</b>. Outputs 0 when none is found; errors if <b>name</b> is empty."
    fields = [("name", "Variable name", "StringField")]
    inputs = []
    outputs = [("value", "Value")]

class Variable_Write:
    name = "Variable (write)"
    symbol = "*C"
    width = 1
    description = "Holds a controller-local variable named by the <b>name</b> field. Stores input <b>value</b> (or the constant <b>value</b> field when <b>field_value</b> is on) so a paired <b>Variable_Read</b> on the same controller can fetch it. Errors if <b>name</b> is empty."
    fields = [("name", "Variable name", "StringField"),("field_value", "Override input 'value'", "BooleanField"),("value", "Value", "NumberField`1")]
    inputs = [("value", "Value")]
    outputs = []

