Jump to content

Recommended Posts

So I am trying to make interacting with an object yield 2 items instead of one.  I started with adding a new pick function to double the input on Pickable:SetUp and then wrote new code for calling Pickable:Pick(picker) in varying ways to support looting 1 item and 2 items.  On one of the iterations it worked, but now I cant duplicate it.  So I moved on to try to force the game to add an item to the players inventory when told to pick in the items code itself.  I thought using

local loot1 = SpawnPrefab("X")
GetPlayer().components.inventory:GiveItem(loot1, nil, Vector3(TheSim:GetScreenPos(self.inst.Transform:GetWorldPosition())))

would work, but it is failing as well. Any help would be appreciated.  Maybe I am just doing it an overly complicated way?

Just an FYI, I was able to solve the problem by editing the components.pickable.lua more and having it pick 2 different items.  So I can now pick cave bananas/berries and occasionally get a banana/berry and additional seed for planting in the same action! So excited...

However, I am still interested to know how to use the GiveItem function if anyone would still care to explain.  THANKS!

Edited by Nappy

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