Loaders snaps, works and utils

by Thaui

Provide smart auto-snap feature of loaders to belt items and compatibility to loaders mods.

Utilities
11 days ago
0.18 - 2.0
2.55K

FAQ

Snapping

How to add Loader compatibility for snapping:

Under you control.lua put this condition around your snapping logic:

-- if setting loaders-snap don't exist or is set to YOURMOD then allow this loader logic
if (not settings.startup["loaders-snap"] or settings.startup["loaders-snap"].value == "YOURMOD") then
  -- snapping logic
end

Under settings-updates.lua, you'll need to add:

-- if loaders-snap setting is present then add YOURMOD as an option
if data.raw["string-setting"] and data.raw["string-setting"]["loaders-snap"] then
    table.insert(data.raw["string-setting"]["loaders-snap"].allowed_values, "YOURMOD")
end

How to prevent custom placed loader to snap

Under you control.lua:

Set native rotatable property of your loader to false just after it's creation

my_loader.rotatable = false

Or set native force property of your loader to an enemy force

my_loader.force = game.forces.enemy

A loader snaped and displayed a mesage that it can't rotate

The snapping logic use invisible rotations to find any belt connectable entities, those are made to reset to the original position when the search is done.
Then a special function does the rotation by mimicking the player, so it can't rotate the entity if the player can't.
If a rotation still occured it's mainly because another mod doing snapping is also running.