I have a free subscription. My equipment is as follows:
Programmaticon III
Leather belt
Simple wristwatch
Darksteel blade
Leather boots
Enchanted lenses
Quartz sense stone
Steel ring
Basic flags
Boss star II
Obsidian helmet
Painted steel breastplate
Steel shield
In several different levels, commands that include item.pos or enemy.type refuse to execute. Instead, they pop up an error message that says, “tmp[number] is undefined”. In each case, I made sure that I had defined “item” or “enemy”. The help is blank. Can you tell me whether the problem is my code or CodeCombat?
Give us an example. A screenshot with your code in it, the levels that it happens, and the error that follows, for example. Does this problem show up on some levels, but not others? Help us help you!
loop:
enemies = self.findEnemies()
enemy = enemies[enemyIndex]
enemyIndex = 0
while enemyIndex <= len(enemies):
if self.isReady("power-up"):
self.powerUp()
if enemy.type != 'sand-yak':
while enemy.health > 0:
if self.isReady("bash"):
self.bash(enemy)
else:
self.attack(enemy)
enemyIndex = enemyIndex + 1
I get the error message, “Line 8: tmp48 is undefined”, with “enemy.type” in “if enemy.type != ‘sand-yak’:” highlighted.
Shine Getter:
loop:
coinIndex = 0
coins = self.findItems()
loop:
coin = coins[coinIndex]
if coin.value == 3:
x = coin.pos.x
y = coin.pos.y
self.moveXY(x, y)
coinIndex = coinIndex + 1
The error is, “Line 6: tmp29 is undefined”, with " coin.value" in “if coin.value == 3:” highlighted.
Wild Horses:
loop:
# How do you find the nearest friendly unit?
# horse = ?
horses = self.findFriends()
horse = horses[horseys]
horseys = 0
while horseys < len(horses):
x1 = horse.pos.x - 7
x2 = horse.pos.x + 7
if x1 >= 1:
# Move to the horse's y position but use x1 for the x position.
hy = horse.pos.y
self.moveXY(x1, hy)
elif x2 <= 79:
# Move to the horse's y position but use x2 for the x position.
hy = horse.pos.y
self.moveXY(x2, hy)
distance = self.distanceTo(horse)
if distance <= 10:
self.say("Whoa")
# Move to the red x to return the horse to the farm.
self.moveXY(28, 53)
horseys = horseys + 1
# Move back out into the pasture to begin looking for the next horse.
The error message is, “Line 8: tmp42 is undefined”. “Horse.pos” in “x1 = horse.pos.x - 7” is highlighted.
In the future, please put triple backticks, or three of `, around you code, so it will format properly.
In Sarven Brawl, you use enemyIndex before you define it, which would explain the error.
With the weird indentation, it’s hard to tell on Shine Getter. However, why do you have two loops? You will never leave the first one without a break statement…
Similar thing to Sarven Brawl on Wild Horses. You use horseys before you define it.
Hm. Yes, it would indeed. Your problem is the canElectrocute. That tests whether the enemy is not inanimate, i.e a Beam Tower or a Palisade, not whether electrocute is ready. Add an isReady("electrocute").
“If enemy” didn’t help. (Might that be saying the same thing as “while enemyIndex < len(enemies)”?)
I only have 1099 gems, whereas glasses that see through walls require 1500. Besides, the enemy Tharin refuses to attack is not on the other side of a wall.
There is a flag that appears after killing the first ogre (presumably because of my placing it there last time), but I don’t think that’s affecting Tharin since I have no code concerning flags.
Nope. Tharin died. He killed an ogre and a scout, waited a few seconds while another scout attacked him, killed that scout, then stood there until decked by two more scouts and a thrower, all within easy fighting range.