Sign in to follow this  
parityb1t

Cannot use ACTIONS.PICKUP on 'carrot' and 'berries'?

Recommended Posts

parityb1t    0
Posted (edited)

 In 'carrot' and 'berrybush' prefab files, the pickable component has 'carrot' and 'berries' prefab set, respectively, to be spawned when `Pick()` is called. This drops is directly into the inventory.

product set:
 

inst:AddComponent("pickable")
inst.components.pickable.picksound = "dontstarve/wilson/pickup_plants"
inst.components.pickable:SetUp("carrot", 10)


extract from `Pick()`

local loot = nil
 if picker and picker.components.inventory and self.product then
    loot = SpawnPrefab(self.product)
    ...
   picker.components.inventory:GiveItem(loot, nil, Vector3(TheSim:GetScreenPos(self.inst.Transform:GetWorldPosition())))


so we can use ACTIONS.PICK on 'carrot' and 'berrybush', but how could I make a character pick up 'carrot' or 'berries' if they are not in the inventory, i.e. on the ground and have already been harvested? How would I use ACTIONS.PICKUP? I cannot even seem to find the prefab files for the 'carrot' and 'berries' (only their planted version) and the code seems to suggest they do not have the component `inventoryitem` hence cannot be picked up.

Edited by parityb1t

Share this post


Link to post
Share on other sites
parityb1t    0

Answering my own question. Still don't know where the prefab files for the produce are, but they are inventoryitem. Debugging showed me that my character was missing the ActionHandler for ACITONS.PICKUP in the stategraph, hence it was failing. Adding it solved it.

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