Page 1 of 1

caninsert() function

Posted: Wed Aug 07, 2013 7:58 am
by drs9999
So because caninsert() allways returns true if at least some of the given itemstack can be inserted. My question is, is there a workaround to check if the given itemstack can be inserted completly?

I was thinking about a function that needs same parameter than caninsert(), but returns true if the whole given stack can be inserted, otherwise it return the amount of items that can be inserted.

Re: caninsert() function

Posted: Tue Aug 27, 2013 1:48 am
by rk84
Workaround would be. Get item count, try to insert the itemstack, get item count again, check difference between counts, remove inserted items and return value. Minor problem is that character has no remove method so you need to get all individual inventories and make the subtraction yourself.

Re: caninsert() function

Posted: Tue Aug 27, 2013 4:44 pm
by drs9999
Thanks that might work.
rk84 wrote:Minor problem is that character has no remove method so you need to get all individual inventories and make the subtraction yourself.
Actually that is not a problem.
I found

Code: Select all

game.player.controller.removeitem{name,count}
in the scenariopack, some time ago