Request for Mod prototype userflags

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Request for Mod prototype userflags

Post by Nexela »

I would like a way to set user flag strings on a prototype. The sole purpose for these is for the mod scripting side of things. Here is an idea I have come up with.

user_flags could be assigned to these prototypes in the data stage. the default would just be an empty user_flags table.
luaDamagePrototype
LuaEntityPrototype
LuaEquipmentGridPrototype
LuaEquipmentPrototype
LuaFluidPrototype
LuaItemPrototpye
LuaTilePrototype
LuaVirtualSignalPrototype

for the data stage using a fluid-type as an example:
fluid-name.user_flags={"fluid", "flammable"}
fluid-name2.user_flags={"gas", "flammable"}
data:extend:({fluid-name, fluid-name2})

if data.raw.fluid[fluid-name].user_flags["gas"] then do something here! end
some mods that come to mind that could Benefit from this are Omnibarrels, Flare stack, and Petrochem. Allowing them to dynamically create recipes depending on the user_flags of a prototype.
if a mod maker flags their fluid as flammable and gas then flare stack could dynamically create a recipe for use in either the "flare stack" or the "gas vent"

Moving on to the api side of things
luaXPrototype.has_user_flag("gas") return true or false if the prototype has this flag (read)


This could possibly be further expanded to surfaces and forces
game.create_surface{blah, blah, user_flags={"underground, nopower"}} -- user_flags as optional, nil if not present
surface.set__user_flags({"moon", "underground"})
surface.has_user_flag("moon") -- returns true if present, false if not present or no user_flags set

Thanks for reading! Let me know what your thoughts are.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Request for Mod prototype userflags

Post by aubergine18 »

+1, although I'd call the property .meta (or .tags) instead of .user_flags

Also nice to have on gui elements too viewtopic.php?f=28&t=31738

Would be nice if, in control.lua, we didn't need to dig down to the prototypes to read flags, ie. they should be accessible in a lazy property on the entity/item/etc objects themselves.

Code: Select all

if event.entity.foo then ...
Factorio is a game about using automation to achieve more, yet with mods we're still stuck hardcoding everything, over and over again. It's the coding equivalent of manually mining ore. Having a folksonomy (flags/meta/tags/whatever) enables us to create custom meta categories within the existing rigid taxonomy, and then we can apply logic to the meta categories. The fluids example in OP illustrates this perfectly.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Post Reply

Return to “Modding interface requests”