Jump to content

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


Recommended Posts

 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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...