Why doesnt the mushroom get destroyed when i collect the potion but when i do the opposite it works

(I ALREADY SOLVED THIS BUT IM GOING TO LEAVE IT UP IN CASE SOMEONE SOMEHOW HAS THE SAME PROBLEM AS ME. The solution is that “potion-large” isn’t an item type its supposed to be just “potion”)

I tried to make code so that when you collect one item the other disappears but when I collect the potion the mushroom doesn’t disappear for some reason and I I’m pretty sure it should work, i don’t know if I’m doing anything wrong because I’m still learning how to code In python mostly

here’s the code i made here(python):


strengthUpgrade = game.spawnXY("mushroom", 31, 6)

def onCollect(event):
    item = event.other
    unit = event.target
    if item.type == "mushroom":
        unit.say("YAY now im STRONGER")
        vitalityUpgrade.destroy()
        #put the health upgrade here 
        pass
    elif item.type == "potion-large":
        strengthUpgrade.destroy()
        #same here :3
        pass


player.on("collect", onCollect)

You can mark this post as a solution for the Discourse.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.