Jump to content

Recommended Posts

I want to make a mod that changes the number of drops I get from hacking a vine bush and a bamboo tree.  

 

I know you can easily do this with grass and saplings by typing this code:

function grasspostinit(inst)    inst.components.pickable.numtoharvest = --Number of how much grass I wantendAddPrefabPostInit("grass", grasspostinit)

But, bamboo trees and vine bushes aren't pickable. So I can't use 

inst.components.pickable.numtoharvest

Instead, bamboo trees/vine bushes are hackable. So naturally I would try 

inst.components.hackable.numtoharvest

However after looking closely in the hackable.lua file, there is no numtoharvest. So any ideas how I would go making this mod? 

The 'hackable' component uses the 'lootdropper' component to drop it's loot, which is specified and can be modified at 'inst.components.hackable.product' (where 'inst' is the prefab's instance). Unfortunately, the number of drops cannot be modified. I suggest that you create a prefab that, instead of initializing in it's 'fn' function, does the following:

  1. Spawn a 'bamboo' prefab with 'SpawnPrefab'.
  2. Edit the 'stackable' component of the bamboo to have a specific stack size.
  3. Return the bamboo.

The 'product' field of the 'hackable' component can then be overridden with the identifier of this new prefab (eg. 'bamboostack').

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