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

Team work level misunderstanding (Python)


Hi Heroes,

Q1 : Is the word ( items ) in items = hero.findItems(), an array or a variable?
If it is an array, where are its item[0], item[1], item[2]…? Is this array defined previously in the game?

Q2 : What is the difference between items = hero.findNearestItems(), items = hero.findItems() and items = hero.findNearest(hero.findItems()), I don’t mean the difference of meaning ( nearest or any distance of items ) ?

Q3: In hero.say("Bruno " + gem0) or hero.say("Bruno " + items[0]), where is the code for gem0 or items[0] to “Bruno” go to gem and take it? and the same for "Matilda".



.1. An array can be stored in a variable. Therefore the items variable holds an array of items. items[0] would be the first item in that array.

The function hero.findItems() only returns an array if there are currently items in the game. So it can return null if it didn’t find any items. Meaning that there is no array stored in the variable items in the particular case where there are no items available in the game.

.2. Both item = hero.findNearestItem() and item = hero.findNearest(hero.findItems()) do similar things. They return a single item object that is the closest to the hero.

Where as items = hero.findItems() returns an array of all of the items in the game available.

Notice the difference between singular and plural. The ability for you to see an item is normally limited by the range of your glasses equipped. And blocked by walls/etc depending on how the game level was setup.

The hero is wearing Fine Wooden Glasses with a range of +10m. There are two gems in the level, one is 14m away and the other 5m away. By using hero.findItems() I get an array returned with items[0] holding the gem that was 4m away. And if I used hero.findNearestItem() I would get the single item object of the 4m away gem.

The first is still an array structure items[0] with only one element in it, and the second would be a single object item.

.3. The code for the making the other characters move around in the game is placed in the level or game code itself. So there is additional logic that is programmed for you "behind the scenes" to allow the game to work the way it does.

Also, in the game you will notice differences between levels. Not everything will stay constant like a video game. So make sure you read the instructions before assuming that a game element will act exactly the same in that case.

Just like your cell phone, you might not understand how it works, but that doesn’t stop you from using it daily to do things.

If you really want to learn more, the code base is open source and you can begin to read it when you are ready. You can create levels for the game as well by using the level editor and reading about design on the wiki.


Thank you so much Harry.