caninsert() function

Place to get help with not working mods / modding interface.
drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

caninsert() function

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

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: caninsert() function

Post 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.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: caninsert() function

Post 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

Post Reply

Return to “Modding help”