Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Unable to complete [Backwoods Forest] Spring Thunder

while True:
    item = hero.findNearestItem()
    # A silver coin has a value of 2.
    # Collect if item.type is equal to "coin"
    # AND item.value is equal to 2.
    if item.type == "coin" and item.value == 2:
        hero.moveXY(item.pos.x, item.pos.y)
    # A blue gem has a value of 10.
    # Collect if item.type is equal to "gem"
    # AND item.value is equal to 10.
    if item.type == "gem" and item.value == "10":
        hero.moveXY(item.pos.x, item.pos.y)

I think I’m using what would be the right code here, but my character only moves to get silver coins, and skips the gems as they appear. Can anyone assist? Been racking my brain over it and even went for a little smoke break to clear my head lol.


The value of the gems are not supposed to be strings.

item = hero.findNearestItem()
value = item.value
# There is a difference between strings and variables.
# String:
hero.say("value") # the hero says the actual word "value"
# Variable:
hero.say(value) # the hero says the value of an item (like 2, 10, etc.)

You are having your hero associate a string with the gem’s value, which will produce an error, and the hero won’t collect the gems. Values are not the same as strings.

Like if this helps! :slight_smile:

I wouldn’t recommend drugs for people trying to find answers to code issues, or at all (unless I misunderstood “smoke break”).


Thank you!
Something so simple. >.<
and no, just a cigarette :stuck_out_tongue: Which is just as bad for other reasons, but old habits die hard.
I appreciate the help though!


Wait,wait,wait. The gem value is supposed to be 5. Understand?


This is probably a special level in which gems have random values. Good call though! :smiley:


It was 10 for me, but removing the quotes from around the value 10 worked.


Which is exactly the right thing to do! :smile: