Jump to content

Remove item help


ProjectSky

Recommended Posts

You need to get the reference to the item you want to remove and the reference of the inventory (container, floor, player) you want to remove the item from. Basically something like this:

 

player:getInventory():Remove(item);

 

Link to comment
Share on other sites

13 minutes ago, Sky_Orc_Mm said:

@RoboMat

 


local player = getSpecificPlayer(0);
    local inv = player:getInventory();
	inv:Remove(item);

I try to use this code, but it doesn't seem to be able to remove items on the floor.

Look at how i removed my ash on my mod PZ Vanilla Patch latest release

Link to comment
Share on other sites

  • 7 months later...

Edit:

I recently looked at the javadoc, it helped me a lot, so the problem solved.

 

local sq = getCell():getGridSquare(x, y, z);
if (sq ~= nil) then
    for i = sq:getObjects():size(), 1, -1 do
        local obj = sq:getObjects():get(i - 1);
        if instanceof(obj, "IsoWorldInventoryObject") then
            if obj:getItem():getFullType() == ItemTable then
                sq:transmitRemoveItemFromSquare(obj)
                obj:removeFromSquare();
            end
        end
    end
end

 

Edited by Sky_Orc_Mm
problem solved.
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
×
×
  • Create New...