I'm trying to make a script that checks if the champions have a particular item in inventory. There is a script for this in the "Useful scripts repository" thread for Grimrock 1, but it doesn't work in Grim 2 as is. Here's what I have so far:
First, I have the two functions from the post above.
To fix an error, I modified party:getChampion(i) to party.party:getChampion(i)
Code: Select all
function checkForItemParty(item)
local i = 1
repeat
if checkForItem(party.party:getChampion(i), item) then
return true
end
i = i + 1
until i == 5
return false
end
function checkForItem(champion, item)
local i = 1
repeat
local itemObj = champion:getItem(i)
if itemObj ~= nil then
if itemObj.name == item then
return true
end
end
i = i+1
until i == 32
return false
end
Code: Select all
if checkForItemParty("figure_skeleton") then
ok_to_pass = false
end
My guess is that champion.getItem() doesn't work in Grim 2 but I don't know how to fix it.