I cannot get this to work no matter what I do. I suspect a couple of things.
1) The script, which I have tied to stepping on a pressure plate, activates as soon as I start the game in the editor. I'm not understanding why this is happening.
2) in adding a test print to the function, in order to see the actual values returned, I am getting null for all results. Even after I pick up the item, put it in inventory, and step on the plate. In fact, stepping on the plate does not trigger the script again. I do have it linked to the script in the editor. So the script executes upon startup, where obviously there is nothing yet in inventory, but never again.
So I suspect that the variable I am using, which was posted here in 2012, has somehow been changed. Thus, why I'm getting null. But again, because the script doesn't execute again after stepping on the pressure plate, I can't be sure.
Here is the modified script after copying from this forum and changing the relevant variables.
You'll notice I have two test prints. The first one is to make sure I'm actually printing the latest modification of the script as it's obvious the buffer doesn't clear from the test run unless you actually exit out of the dungeon editor. I know this because when removing the test prints and running again, the messages still show up on the screen, which means they have to be left over from the last run. So I increase Hello World from 1 to 2 to make sure it's running the current script.function checkForItemParty(item)
local i = 1
repeat
if checkForItem(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)
print "hello world2"
print(itemObj)
if itemObj ~= nil then
if itemObj.name == item
then return true
end
end
i = i+1
until i == 32
return false
end
if checkForItemParty("rock")
then temple_door_portcullis_1:open()
end
Anyway, when I press the play button on the editor, as soon as the game starts, the script executes. I have no idea why it does this. Stepping on the pressure plate does not activate the script again.
I am totally lost. If anybody has any suggestions, I'm all ears. I have run out of things to try.