Check party items for "gold_key"

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
supercell1970
Posts: 7
Joined: Mon Mar 11, 2024 11:44 pm

Check party items for "gold_key"

Post by supercell1970 »

I need to be able to check party items for a "gold_key". Does anyone have some example script
that I can utilize. I keep getting a "nil" on the champion command.
User avatar
Slava
Posts: 63
Joined: Sun Aug 30, 2015 2:10 pm

Re: Check party items for "gold_key"

Post by Slava »

Try PartyComponent:isCarrying(string)

Code: Select all

party.party:isCarrying("gold_key")
This is an easy way to see if someone has gold key. Returns true or false.
My Generations of Kings mod
Link to Nexus mods
User avatar
Slava
Posts: 63
Joined: Sun Aug 30, 2015 2:10 pm

Re: Check party items for "gold_key"

Post by Slava »

You can also use a similar design

Code: Select all

function(champion, target)
	for i=1,ItemSlot.MaxSlots do
		local item = champion:getItem(i)
		if item then
			if item.go.name = target then
				return true
			else
				local container = item.go.containeritem
				if container then
					local capacity = container:getCapacity()
					for j=1,capacity do
						local item2 = container:getItem(j)
						if item2 = champion:getItem(i)
							return true
						end
					end
				end
			end
		end
	end
	return
end
where champion is a table obtained for example from party.party:getChampionByOrdinal(1).
target is the name of the item you are looking for: “gold_key”
My Generations of Kings mod
Link to Nexus mods
Post Reply

Return to “Mod Creation”