Report an error: 'allowed_module_categorys' is invalid

Place to get help with not working mods / modding interface.
sdgmlj
Fast Inserter
Fast Inserter
Posts: 174
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

Report an error: 'allowed_module_categorys' is invalid

Post by sdgmlj »

Game version:2.0.42

Code: Select all

local function get_module_names(name)          --name = "assembling-machine-3"
	local names = {}
	local cs = prototypes.entity[name].allowed_module_categories
	local items = prototypes.get_item_filtered({{filter = "type", type = "module"}})
	for im,item in pairs(items) do 
		local c = item.category
		if cs[c]
		then table.insert(names,im)
		end
	end
	return names
end
The error message is: cs is nil
Rseding91
Factorio Staff
Factorio Staff
Posts: 15717
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Report an error: 'allowed_module_categorys' is invalid

Post by Rseding91 »

Sorry but I do not understand this report. Please explain better what is going wrong and what you expect to be happening instead.
If you want to get ahold of me I'm almost always on Discord.
sdgmlj
Fast Inserter
Fast Inserter
Posts: 174
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

Re: Report an error: 'allowed_module_categorys' is invalid

Post by sdgmlj »

Rseding91 wrote: Sun Mar 30, 2025 5:47 am Sorry but I do not understand this report. Please explain better what is going wrong and what you expect to be happening instead.
prototypes.entity[name].allowed_module_categories
We should get an array, but the result it gives is empty
Rseding91
Factorio Staff
Factorio Staff
Posts: 15717
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Report an error: 'allowed_module_categorys' is invalid

Post by Rseding91 »

https://lua-api.factorio.com/latest/cla ... categories Indicates its optional and if not defined for an entity will return nil. So this is working correctly.
If you want to get ahold of me I'm almost always on Discord.
sdgmlj
Fast Inserter
Fast Inserter
Posts: 174
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

Re: Report an error: 'allowed_module_categorys' is invalid

Post by sdgmlj »

Rseding91 wrote: Sun Mar 30, 2025 6:17 am https://lua-api.factorio.com/latest/cla ... categories Indicates its optional and if not defined for an entity will return nil. So this is working correctly.
Can I understand it this way?
This one is prepared for mods, as all default prototypes in the game have not been added, so it is invalid.
Post Reply

Return to “Modding help”