What's the collect term for game.setActionFor?

Hello, I’m on Game Development 2 for CodeCombat and I’m trying to make a passageway open as a person collects a chest. my code looks like this:

#Gates to unlock Levels
chest1 = game.spawnXY("chest", 28, 58)
forest11 = game.spawnXY("forest", 36.5, 7)
forest12 = game.spawnXY("forest", 36.5, 14)
def unlockForest1():
game.setActionFor("chest1", "**collect**", unlockForest1)

However, the bolded word collect does not seem to be working. What is the correct term to put here if I want the forest to unlock after the player collects chest1?

Welcome to the forum @SirStonk ! :partying_face: This is a friendly place where you can ask help on levels, report bugs, or just chat with other coders! Don’t forget to read the guidelines if you haven’t yet. Have a great time!

Please format your code properly with the code button

1 Like

I could be mistaken, but I think what you want is the “hero.on collect method”.

The snippet they provide:

def onCollect(event):
unit = event.target
item = event.other
unit.say("I’ve taken " + item.id)

hero = game.spawnHeroXY(“knight”, 20, 20)
hero.on(“collect”, onCollect)

You could just setup unlockForest1 to be the event triggered. If you define the parts destroyed like above, you can still reference them in the triggered event.

I’m not sure if this is part of the problem, but you need to add parenthesis to both of these lines at the end as they are methods. As for the term, I don’t know what it should be.