#You could put screenshots of the

1 messages · Page 1 of 1 (latest)

molten belfry
#

Here's an example of the psuedocode output:

# ——————————————————————————————————————————
# 1) CONFIGURATION (constant combinators)
# ——————————————————————————————————————————

# These two dicts come from your CCs:
PARTIAL_TARGET = {
  "wall": 50,
  "inserter": 50,
  "pipe": 100,
  # … etc for all the “partial” items …
}

FULL_TARGET = {
  "wall": 200,
  "inserter": 100,
  "pipe": 100,
  # … etc for all the “full” items …
}

ALL_ITEMS = PARTIAL_TARGET.keys()  # assume same keys in FULL_TARGET
#

# ——————————————————————————————————————————
# 2) TRAIN CONTENTS → choose PARTIAL vs FULL
# ——————————————————————————————————————————

# Read the train-stop’s current contents each tick:
train_contents = TrainStop.read_contents()  
#   → dict: item → count_in_train

# Compute how far “under” each kit we are:
partial_deficit = {
  item: train_contents.get(item, 0) - PARTIAL_TARGET[item]
  for item in ALL_ITEMS
}
full_deficit = {
  item: train_contents.get(item, 0) - FULL_TARGET[item]
  for item in ALL_ITEMS
}

# If any partial_deficit is negative → we still need to fill the partial kit first:
if any(v < 0 for v in partial_deficit.values()):
    # Gate into “partial mode”
    current_deficit = partial_deficit

else:
    # All partial minima are met → switch into “full mode”
    current_deficit = full_deficit

    # And if even the full kit is now satisfied, send the green “check”:
    if all(v >= 0 for v in full_deficit.values()):
        TrainStop.set_station_signal("check")  
        # (this is what makes the green tick above the station)


# ——————————————————————————————————————————
# 3) BELT LOADING LOOP
# ——————————————————————————————————————————

# Your belt-loop-reading inserter (in “Hold” mode, 
# reading the entire loop + its hand) outputs each item’s count on the red wire.
belt_counts = BeltLoopInserter.read_total_contents()
#   → dict: item → (count_on_belt + count_in_hand)

# Invert that so we know “how many more to put on the belt”:
belt_deficit = { item: 0 - belt_counts.get(item, 0)
                 for item in ALL_ITEMS }

# Finally, for every item-type i you have a “load-i” inserter downstream:
for i in ALL_ITEMS:
    # We only want to drop more of item i onto the belt if:
    #  1) the train still wants some of i (current_deficit[i] < 0), AND
    #  2) the belt isn’t already full of i (belt_deficit[i] < 0).
    should_load = (current_deficit[i] < 0) and (belt_deficit[i] < 0)
    Inserter.load(i).enabled = should_load