Original Post — Direct link

Hello, i am making a mod that handles the sorting of the most cluttered modded groups and i hit a roadblock when i extend the item-groups

i am focusing on ammo_category for the moment, i want to be able to create a sub for each ammo_category, then i throw GUNS(and turrets) first and ammo later as to obtain pistol>submachinegun>bullet>piercing>uranium(for example) but done dynamically with ANY MOD may be installed.

The code is on github if you'd like to read the dirt and cheap workarounds i have been using to understand lua behaviours, and hopefully you can see my mistakes better than i do

Zsorter dev (github.com)

The vanilla sorting actually used to work (in pic2) but this is no more the case as a function into item-groups started to return the "error loading mods"(in pic1).

By using the function "zrtNewSubGroup" and using string values i would expect said function to create a new subgroup with said values. I feel like i am missing something, i know data:extend has a strict format of types to follow but i think this should be correct, as the same format is used in other piece of code that runs.
I wish for some help in understanding what i am getting wrong and why. Many thanks!

-------------------------

zrtNewSubGroup(localvalname,localvalgroup,localvalorder)

data:extend({{
type="item-subgroup",
name=localvalname,
group=localvalgroup,
order=localvalorder
}})

The error generated during data:extend

a screen i managed to snatch and send a frind during development of the somewhat correct behaviour the system had(vortik's cannons and others mods)

External link →
over 2 years ago - /u/Klonan - Direct link

Lua is global by default, Somewhere you are doing type = item.name or something, And that is overriding the global type() method.

You need to declare the variables as local type = item.name.