Internal
5 months ago
2.0
38

g Hello new modder

5 months ago

I’m not sure if you're aware, but

function remove_table_element(array, to_be_removed)

creates a global function, which becomes visible to every mod, not just your own.

Especially in data.lua, it's important to avoid polluting the global namespace –
many mods carelessly dump things there, and that can lead to name collisions or subtle bugs.

A better design would be:

local utils = {}

function utils.remove_table_element(...) ... end

return utils

Then use it like this:

local utils = require("__ylwlib__.utils")
utils.remove_table_element(...)

This keeps things clean, modular, and safe – especially in large modpacks.

Good luck with your mods – and thanks for sharing it!
best regards kux

5 months ago

you are very right, i have been spending far to much time doing this stuff at like 2am lmao, thank you.

5 months ago

Pushed changes to make all functions local. I plan on making a bigger mod at some point, but I'm still learning. I figured I might have functions I want to use elsewhere in other mods, and I didn't want to duplicate work. So, I decided to dump them all here, which seems to be a common practice.

5 months ago

which seems to be a common practice.

yes it is (unfortunately) everyone makes their own lib mod instead of working together on a single one

BTW the category of you lib mod should be "internal"
there you will also find good existing ones like Factorio Library by raiguard. even though i personally don't use it, it seems suitable for many modders

5 months ago
(updated 5 months ago)

yes it is (unfortunately) everyone makes their own lib mod instead of working together on a single one

talking to other people is scary :(
also yea good idea

New response