Page 1 of 1

any way to remove an item from inventory or the game?

Posted: Thu Dec 17, 2015 11:07 pm
by bongobeat
Hello,
I wonder if it is possible to remove an item from inventory? Like some monsters just robb you:

I ve searched on the forum but I only have found something for grimrock1:
SpoilerShow

Code: Select all

    function removeTorches()

    local hastorches = false

    for i=1,4 do
     for v=1,31 do
      if party.party:getChampion(i):getItem(v) ~= nil then
        if party.party:getChampion(i):getItem(v).name == "torch" then party.party:getChampion(i):getItem(v):destroy() hastorches = true
       end
      end
     end
    end

    if hastorches then hudPrint ("All your torches fizzle and die") else hudPrint ("Since you have no torches, none of them fizzle and die lol") end

    end
when using this connected to a trigger plate it prints me the second hudprint sentences, it dont detect the torch in the inventory or in the hands.
Anyone knows how to do it?

Re: any way to remove an item from inventory or the game?

Posted: Thu Dec 17, 2015 11:34 pm
by minmay
http://www.grimrock.net/modding/scripting-reference/
Champion:removeItem(), Champion:removeItemFromSlot(), ContainerItemComponent:removeItem(), ContainerItemComponent:removeItemFromSlot()

Of course if you want a monster to steal the item you should add it to their inventory first with MonsterComponent:addItem()

Re: any way to remove an item from inventory or the game?

Posted: Wed Dec 23, 2015 8:14 pm
by bongobeat
thank for the answer.

Well I have finally done something else. No need now to remove an object from inventory.