Jump to content

Recommended Posts

I'd like to make a few items automatically stack the way hounds teeth, monster meat, and some others do. I know I need to add the "selfstacker" component to the items to do so, but I'm wondering if (and hoping) it's possible to add that component to them without having to replace the entire prefab file?

5 minutes ago, TheHalcyonOne said:

I'd like to make a few items automatically stack the way hounds teeth, monster meat, and some others do. I know I need to add the "selfstacker" component to the items to do so, but I'm wondering if (and hoping) it's possible to add that component to them without having to replace the entire prefab file?

--modmain.lua
AddPrefabPostInit("cutgrass", function(inst)
    if not GLOBAL.TheWorld.ismastersim then--needed for components to not crash clients I believe
        return inst
    end

    inst:AddComponent("healer")
end)

^ just an example

3 minutes ago, Aquaterion said:

--modmain.lua
AddPrefabPostInit("cutgrass", function(inst)
    if not GLOBAL.TheWorld.ismastersim then--needed for components to not crash clients I believe
        return inst
    end

    inst:AddComponent("healer")
end)

^ just an example

Awesome, thanks. Though, wouldn't a change like this make for a server-only mod? Is that check still necessary?

4 hours ago, TheHalcyonOne said:

Awesome, thanks. Though, wouldn't a change like this make for a server-only mod? Is that check still necessary?

If it's server-only, yes. But if this were to be included in an all-clients mod, you would need it.

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...