Jump to content

[Scripting] add component to items

Recommended Posts

Some items have the component




Is there a way to add a custom component to certain items?


My goal is to have something similar to this from wx78.lua:


for k, v in pairs(inst.components.inventory.equipslots) do    if v.components.dapperness ~= nil and v.components.dapperness.mitigates_rain then            --Mitigates rain, no sparks            return    endend

Edited by Woodside235
Link to comment
Share on other sites

@Woodside235, Maybe I'm not understanding exactly what you want to do, but why not just add the dapperness component? It starts out with dapperness == 0, by default. But when RoG rolls out, this gets separated into its own component.


So something like this:

wetprotected ={    "flowerhat",    "armor_wood",    "spear",}for k,v in pairs(wetprotected) do    AddPrefabPostInit(v, function(inst)        inst:AddComponent("dapperness")        inst.components.dapperness.mitigates_rain = true    end)end
Edited by rezecib
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...