Jump to content

Dropping player's items will result in loss of items?


Recommended Posts

So, I was messing around with some modding commands, and I encountered this weird scenario.

When the player is trying to deploy something ( let's say, they have 20 stone walls - prefab wall_stone_item - and they are trying to deploy them ), they will click a stack, and then right click to deploy. That means, a stack of for example 20 is selected. Now, if you drop the player's inventory while this is happening, only 1 instance of that particular item will be dropped. Here's some code to reproduce:

 

local global_ActionDeploy	= _G.ACTIONS.DEPLOY.fn
_G.ACTIONS.DEPLOY.fn = function(act)
	act.doer.components.inventory:DropEverything()
	return global_ActionDeploy(act)
end

Try putting this into a mod, select a stack of walls and deploy one. Only one wall item will be dropped. But, if you distribute that stack in your inventory ( let's say, you put 1 wall item in each inventory slot ) and then select "one" and deploy, the command will drop all the items. It seems to be some to do with the selection of the items.

So, is this expected behavior? Because due to the method's name ( DropEverything() ) I was expecting it to drop all of the inventory.

Edited by JackJohnsn
Link to comment
Share on other sites

Maybe it has to do with the "items on mouse" ? try dropping everything while you have an item on mouse.

And if it does not has to do with it, search more within the deploy/drop code and see if there is a problem with stacks/missing code for stacks.
 

Link to comment
Share on other sites

It is a bug, you can file a bug report for it.
Every single line in inventory.lua that currently looks like this:
self:DropItem(self.activeitem)
should be instead:
self:DropItem(self.activeitem,true)
to also drop stacks.

edit:
after these changes the whole stack that is on the mouse is dropped.
But of course it might be possible, that someone only want to drop one item from the stack. In this case my above code is not the final solution and the devs should find out why the rest of the active item is disappearing.

Edited by Serpens
  • Thanks 1
Link to comment
Share on other sites

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
 Share

×
  • Create New...