Sign in to follow this  
Woodside235

[Scripting] add component to items

Recommended Posts

Woodside235    1

Some items have the component

 

components.dapperness.mitigates_rain

 

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

Share this post


Link to post
Share on other sites
Woodside235    1

Nevermind, I just created a string array of the items I wanted to have the component and used it. Works just fine.

 

EDIT: however it'd still be nice to know how

Edited by Woodside235

Share this post


Link to post
Share on other sites
rezecib    3182

@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

Share this post


Link to post
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
Sign in to follow this