Request for Mod prototype userflags
Posted: Tue Aug 30, 2016 5:32 am
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_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.