Cursed Programable Inserters

by L0771

Inserters programables via GUI. All possible convinations.

Utilities
3 years ago
0.15 - 0.18
45

i Renai Transportation inserters support (and other inserters too)

3 years ago

To add Renai Transportation mod support (throwing inserters) - tbh, for any unknown inserters ...
Problem: your code for dynamic sprite name/path is not correct - sometime there are no that sprite
Solution: Check dynamic sprite path via function LuaGui.is_valid_sprite_path, and if it is not correct one - replace for default inserter sprite: "item/inserter"

Patch----
after fix: https://mods.factorio.com/mod/Cursed-PI/discussion/5f654e7dff628f8b5856ffd7
also, follow those steps:

Could we fix following code based on v0.6.4:
1) find code chunk:
event.element.sprite = "item/" .. global.cursedPI[event.player_index].name

and replace it for:
local elemSprite = "item/" .. global.cursedPI[event.player_index].name
if not game.players[event.player_index].gui.is_valid_sprite_path(elemSprite) then
-- SAFE replacement, if we do not have that sprite as already loaded
elemSprite = "item/inserter"
end
event.element.sprite = elemSprite

2) find code chunk:
function selectActualPositions(tablePI1, tablePI2, rango, entity)

and replace for:
function selectActualPositions(tablePI1, tablePI2, rango, entity, playerGui)

3) find code chunk:
end
end

    selectActualPositions(tablePI1, tablePI2, rango, entity)
end

end)

and replace for:
end
end

    selectActualPositions(tablePI1, tablePI2, rango, entity, game.players[event.player_index].gui)
end

end)

4) find code chunk:
makeTable(tablePI1,rango.pick,tam)
makeTable(tablePI2,rango.drop,tam)

selectActualPositions(tablePI1, tablePI2, rango, entity)

end

and replace for:
makeTable(tablePI1,rango.pick,tam)
makeTable(tablePI2,rango.drop,tam)

selectActualPositions(tablePI1, tablePI2, rango, entity, player.gui)

end

5) find code chunk:
tablePI1["datosPI_" .. py .. "" .. px].style = "cursed-PI-hand"
tablePI1["datosPI
" .. py .. "" .. px].sprite = "item/" .. entity.name
tablePI2["datosPI
" .. dy .. "" .. dx].style = "cursed-PI-hand"
tablePI2["datosPI
" .. dy .. "_" .. dx].sprite = "item/" .. entity.name

and replace for:
local elemSprite = "item/" .. entity.name
if not playerGui.is_valid_sprite_path(elemSprite) then
-- SAFE replacement, if we do not have that sprite as already loaded
elemSprite = "item/inserter"
end

    tablePI1["datosPI_" .. py .. "_" .. px].style = "cursed-PI-hand"
    tablePI1["datosPI_" .. py .. "_" .. px].sprite = elemSprite
    tablePI2["datosPI_" .. dy .. "_" .. dx].style = "cursed-PI-hand"
    tablePI2["datosPI_" .. dy .. "_" .. dx].sprite = elemSprite

Now it should work, but it does not show pick and drop position for new unknown inserters.
Once user set drop and pick position, it should work and show drop and pick positions on second GUI opening.

To fix last issue, we need fix following lines:
if not (tablePI1 and tablePI1.valid and tablePI1["datosPI_" .. py .. "" .. px] and tablePI1["datosPI" .. py .. "" .. px].valid) then return end
if not (tablePI2 and tablePI2.valid and tablePI2["datosPI
" .. dy .. "" .. dx] and tablePI2["datosPI" .. dy .. "_" .. dx].valid) then return end

I do not know how to replace it, but instead of "return" operation, we need generate missed tables here.

Could you apply this patch at least as a temporary solution?

3 years ago
(updated 3 years ago)

New response