Use a null check before accessing properties. Use if statements to make sure that there is always a target. Make sure that if you use something like findNearestEnemy, you use an if enemy: check before you do anything with enemy, because there might not be an enemy!įind the distance to a target unit: Same as above–if there is no target unit at some point during the level (possibly because you can’t see anyone or have killed everyone), you’ll pass a None target to distanceTo and error out. Is there always a target to attack?: you are probably trying to attack None. You might also just be trying to call a method that doesn’t exist. Make sure that you equipped the item that should provide it. Maybe you’re trying to buildXY but you have a sword instead of a builder’s hammer. Undefined is not a function: You probably don’t have the method that you’re trying to call. Most often, this happens either with an experimental programming language or a new, untested level. You can also try switching your programming language, hero, or gear to see if that lets you play. If the “Comment out my code” option doesn’t work, let us know. Infinite loop detected: uh oh, this is probably a problem on our end. I’ll pretend you’re writing Python, but most of this is the same for JavaScript or other languages. You could buy more gems, too, but it’s not required to beat the core level progression.Ĭommon error messages and how to debug them If you don’t have enough gems, consider playing more of the replayable challenge levels or simulating some multiplayer games. If you’re dying too quickly, try buying more armor. Some levels are easier with a warrior, wizard, or ranger, so try a different hero if you have one. In addition to writing the right code, for many levels, your hero will need to be strong enough to defeat her enemies and survive their slings and arrows. If a level is too hard, try a different hero or different items We’ve listed common gotchas and good-to-knows that will save you some serious brain agony. If you get stuck, first make sure you’ve carefully read the instructions in the comments, then chance the Hints, located in the upper right. hero.say("You can even put code in here")Ĭheck each level’s help guide for common tips Hero.say(“You can even put code in here”)Ĭlick here to learn the deep secrets of space This text will not be visible until you expand the spoiler. You can use the -block to hide text or even code in an expandable textblock. This: ```īecomes this: enemy = hero.findNearestEnemy() You can get your code to format properly by surrounding it in triple backticks. Post your code with radiant, harmonious formatting Playtest new levels for free as an Adventurer.Becoming an Archmage, Adventurer, Diplomat, Artisan, Scribe, or Ambassador.Buying CodeCombat for your school or group.Status of experimental programming languages.Personal coding help from the CodeCombat staff.Post your code with radiant, harmonious formatting.Common error messages and how to debug them.If a level is too hard, try a different hero or different items.Check each level’s help guide for common tips.… you know it’s sweet stuff! Might save your life some day.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |