Panakotta00 / FicsIt-Networks

Control, Monitor, Manage and Automate your Satisfactory.
https://ficsit.app/mod/FicsItNetworks
GNU General Public License v3.0
155 stars 50 forks source link

Train time table rule sets ignore setting item filters #268

Closed jvanbruegge closed 8 months ago

jvanbruegge commented 10 months ago

Describe the bug TrainStop:setRuleSet() ignores load and unload filters of the rule set.

To Reproduce Steps to reproduce the behavior:

  1. Build a computer and connect it with a train station
  2. Build a train in the train station
  3. Create a timetable in the train with the station
  4. Build a container and fill the first slot with any item
  5. connect the container to the computer
  6. Run this code:
    station = component.proxy(component.findComponent(findClass('Build_TrainStation_C'))[1])
    container = component.proxy(component.findComponent(findClass('Build_StorageContainerMk2_C'))[1])
    train = station:getTrackGraph():getTrains()[1]
    stop = train:getTimeTable():getStops()[1]
    rules = stop:getRuleSet()
    type = container:getInventories()[1]:getStack(0).item.type
    rules.loadFilters = { type }
    stop:setRuleSet(rules)
    print(type.name)
    print(station.name)
    print(train:getName())

Expected behavior The timetable of the train was changed to add the item in the container as load filter to the stop

Actual behavior The train has the old time table without load filters

Additional context v0.3.15

Panakotta00 commented 10 months ago

the getStops returns a struct array... which is done by value... so you have set the stops to the timetable again... instead of stop = train:getTimeTable():getStops()[1] you should do

stops = train:getTimeTable():getStops()
stop = stops[1]
[...]
stop:setRuleSet(rules)
train:setStops(stops)
jvanbruegge commented 10 months ago

Thanks, I will try this later. Btw, calling train:setStops() (so without argument) will crash the game. I can get the crash report later as well