ModMash Splinter, Underground + Subways


Mod Mash Splinter for Undergrounds + Subways, Now you can go underground and expand your base in multiple dimensions

Content
2 months ago
1.0 - 1.1
8.22K
Environment

b duping

2 years ago

this is my setup:

train wagon before enter:

train wagon after enter:

and its order are different,I found this because my wagon setup are specialized.

2 years ago

and this is another experiment:


it seem like it take the wagon inventory,sort it,and insert into wagon 3 time.

so its like
raw content:[iron_orex1,redx5,yellowx200,greenx5,greenx200]
1.sort:[iron_orex1,yellowx200,redx5,greenx200,greenx5]
2.insert_1st:[iron_orex1,yellowx200,redx5,greenx200,greenx5]
3.insert_2nd:[iron_orex2,yellowx200,redx10,greenx200,greenx200,yellowx200,greenx10]
4.insert_3rd:[iron_orex3,yellowx200,redx15,greenx200,greenx200,yellowx200,greenx200,yellowx200,greenx15]

so it will become that pattern.

2 years ago
(updated 2 years ago)

so it seems like two problem:

1.Why cargo content are not in the same order?
2.Why it insert 3 time?

2 years ago
(updated 2 years ago)

and I can fix the first one

at file prototype/scripts/underground.lua
at line 1048

replace section

for name, count in pairs(inventory.get_contents()) do 
            to_inventory.insert({name=name,count=count})
        end

to this

for index=1,#inventory do 
            to_inventory[index].set_stack(inventory[index]);
        end

and this is demo:
https://mega.nz/file/Z7o2zagY#LCXuJuxvkv4fba4PWdJRU5_WbXJgReCyNVVOHvkDBAE

2 years ago

but is still causing dupe,but at least it is much more like it should be.

2 years ago
(updated 2 years ago)

oh,I can fix both now:

local local_transfer_carrrige_state = function(from,to)
    local inventory = from.get_inventory(defines.inventory.fuel)
    if inventory ~= nil then
        local to_inventory = to.get_inventory(defines.inventory.fuel)
        for index=1,#inventory do 
            to_inventory[index].set_stack(inventory[index]);
        end
    end
    inventory = from.get_inventory(defines.inventory.burnt_result) --Maybe no but who know what people can do
    if inventory ~= nil then        
        local to_inventory = to.get_inventory(defines.inventory.burnt_result)
        for index=1,#inventory do 
            to_inventory[index].set_stack(inventory[index]);
        end
    end
    inventory = from.get_inventory(defines.inventory.cargo_wagon)
    if inventory ~= nil then
        local to_inventory = to.get_inventory(defines.inventory.cargo_wagon)
        if inventory.supports_filters() then
            for i = 1, #inventory do
                to_inventory.set_filter(i, inventory.get_filter(i))
            end
        end
        for index=1,#inventory do 
            to_inventory[index].set_stack(inventory[index]);
        end
        if inventory.supports_bar() then
            to_inventory.set_bar(inventory.get_bar())
        end     
    end
    inventory = from.get_inventory(defines.inventory.artillery_wagon_ammo)
    if inventory ~= nil then
        local to_inventory = to.get_inventory(defines.inventory.artillery_wagon_ammo)
        for index=1,#inventory do 
            to_inventory[index].set_stack(inventory[index]);
        end
    end
    local fluidbox = from.fluidbox
    if fluidbox ~= nil and #fluidbox > 0 then
        for i = 1, #fluidbox do
            if fluidbox[i] ~= nil and fluidbox[i].name ~= nil then
                to.fluidbox[i] = {
                    name = fluidbox[i].name,
                    amount  = fluidbox[i].amount,
                    temperature  = fluidbox[i].temperature 
                }
            end
        end
    end

    to.color = from.color
    to.health = from.health

    local driver = from.get_driver()
    if driver~= nil and driver.is_player() then
        --local opened = driver.opened      
        local_safe_teleport(driver,to.surface,to.position, driver.index)
        to.set_driver(driver)
        --if is_valid(opened) then opened.visible = true end
    end

    for k = 1, #from.train.passengers do passenger = from.train.passengers[k]
        if passenger~= nil and passenger.is_player() then   
            --local opened = passenger.opened   
            local_safe_teleport(passenger,to.surface,to.position, passenger.index)
            to.set_driver(passenger)
            --if is_valid(opened) then passenger.opened = opened end
        end
    end


    if from.energy > 0 then
        to.energy = from.energy
        if from.burner then
            to.burner.currently_burning = from.burner.currently_burning
            to.burner.remaining_burning_fuel = from.burner.remaining_burning_fuel
        end
    end
    --todo check worked
    if from.grid then
        local position = {0,0}
        local width, height = from.grid.width, from.grid.height
        local processed = {}
        for y = 0, height - 1 do
            for x = 0, width - 1 do
                local equipment = from.grid.get({x,y})
                if equipment ~= nil then
                    to.grid.put({equipment = equipment.name, energy =equipment.energy, shield = equipment.shield})
                end
            end
        end
    end

    for player_index, id in pairs(global.modmashsplinterunderground.train_ui) do
        if  from.unit_number == id then
            game.players[player_index].opened = to
        end
    end
end

and demo is here:
https://mega.nz/file/8yhmDYxJ#NU3_l3bF-bveSUe9jqn1WmQNFNZmxsttrQRCKE3H2-Q

and this is proof

ya totally the same,as all thing should be.

2 years ago
(updated 2 years ago)

so I got the answer
:
1.Why cargo content are not in the same order?
because it is using simple insert in api,so it just sorted it and insert it without order.

2.Why it insert 3 time?
because somehow

defines.inventory.fuel
defines.inventory.burnt_result
defines.inventory.artillery_wagon_ammo

are also insert it,maybe it is bug from game itself?

2 years ago

I will try my best to look at in the weekend

This thread has been locked.