Page 1 of 1

insertItem into inventory?

Posted: Fri Oct 24, 2014 11:29 am
by [SMUG]Ipecac
Hey guys,

I'm trying to spawn an item in my players inventory.

When i do this:

function doThing()
party.party:getChampion(1):insertItem(11,dagger_1.item)
end

it compiles and runs, but nothing...

If I call it (11,dagger.item) or anything other than an actual dagger already placed, it says the item is a nill.

What's up here?

Re: insertItem into inventory?

Posted: Fri Oct 24, 2014 3:32 pm
by jxjxjf
I think your issue is just the index you're using. I guess there are 2 more equipment slots now, so backpack spaces start at 13. 11 should be your champion's "second" left hand.

I just tested it now and it worked, somewhat, although I was having issues with the item occupying both its original position and the new position in inventory until I picked the item up [edit: from either its original position or the new backpack slot]. Also, it would do nothing if there was already an item in that slot, so that could also be your issue.

I know it's not a solution, but hopefully that helps in the right direction. :)

Re: insertItem into inventory?

Posted: Fri Oct 24, 2014 4:39 pm
by [SMUG]Ipecac
jxjxjf you delicious bastard!! It works! Thanks a million!

Re: insertItem into inventory?

Posted: Fri Oct 24, 2014 4:42 pm
by NutJob
jxjxjf wrote: I just tested it now and it worked, somewhat, although I was having issues with the item occupying both its original position and the new position in inventory until I picked the item up [edit: from either its original position or the new backpack slot]. Also, it would do nothing if there was already an item in that slot, so that could also be your issue.
My solution was to spawn the item to a 1x1 room (basically not accessible by the party, I call the Trash Room heh) then add it to the characters inventory. When you pick up the item for the first time (in Inventory) the item in the "Trash Room" disappears (being it was the same ID).

Re: insertItem into inventory?

Posted: Sun Oct 26, 2014 4:49 am
by TheLegendaryNarwhal
If backpack spaces start at 13 what are the other spaces designated as? I've tried addItem into 13 and it works fine but things like 12,14 don't seem to do anything.

Edit: Also, and I've posted in a different post about spawning entities about this same thing, how would you addItem into your inventory in the case of something like a pellet_box since they have a count. So instead of just adding a single "pellet_box" to your bag, how would you add 5,10,or 100? Just seems like the only way I can get to the count easily is by placing the entity down and then just modifying that, which is more steps then I really want to go through.

Re: insertItem into inventory?

Posted: Sun Oct 26, 2014 4:57 am
by NutJob
Can give my script a whirl. I'll be here for a short while longer if you need help.