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

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

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

Post 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?
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

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

Post 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()
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

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

Post by bongobeat »

thank for the answer.

Well I have finally done something else. No need now to remove an object from inventory.
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
Post Reply