# Web Development 2 Level: Teatime HELP

**URL:** <https://discourse.codecombat.com/t/web-development-2-level-teatime-help/17560>\
**Category:** Level Help\
**Created:** [February 20, 2019, 8:42pm UTC](https://discourse.codecombat.com/t/web-development-2-level-teatime-help/17560 "2019-02-20T20:42:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![eri](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eri/32/9845_2.png) [@eri](https://discourse.codecombat.com/u/eri)\
**Post date:** [February 20, 2019, 8:42pm UTC](https://discourse.codecombat.com/t/web-development-2-level-teatime-help/17560/1 "2019-02-20T20:42:48Z")

</div>

whenever im trying to spawn in throwers it just spams so much and i was wondering if this was supposed to happen but i went over the code and its supposed to send out 2 throwers and i was wondering if anyone could help?

 ![throwers](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/ac9a660f6713cbdebfe52ba35f5c57e6c40eb912.png)  
this is my code

```python
// Use timers to spawn enemies and items.

// This spawns two aggressive munchkins.
function spawnMunchkins() {
    var munchkin1 = game.spawnXY("munchkin", 2, 12);
    var munchkin2 = game.spawnXY("munchkin", 2, 56);
    munchkin1.behavior = "AttacksNearest";
    munchkin2.behavior = "AttacksNearest";
}

// This spawns two aggressive throwers.
function spawnThrowers() {
    var thrower1 = game.spawnXY("thrower", 2, 16);
    var thrower2 = game.spawnXY("thrower", 2, 52);
    thrower1.behavior = "AttacksNearest";
    thrower2.behavior = "AttacksNearest";
}

// This spawns a health potion near the village.
function spawnPotion() {
    game.spawnXY("potion-large", 46, 34);
}

// Survive 30 seconds.
game.addSurviveGoal(30);

// The inital values of timers define the first appearance.
game.munchkinSpawnTime = 0;
game.throwerSpawnTime = 0;
game.potionSpawnTime = 6;
// This is used for UI.
game.nextPotionIn = 0;

ui.track(game, "time");
// Lets show how long until the next potion.
ui.track(game, "nextPotionIn");

var player = game.spawnPlayerXY("duelist", 40, 34);
player.maxSpeed = 15;

// This checks and updates timers.
function updateTimers() {
    // If game time is greater than the munchkinSpawnTime
    if (game.time > game.munchkinSpawnTime) {
        // Update the timer and spawn the munchkins.
        game.munchkinSpawnTime = game.munchkinSpawnTime + 6;
        spawnMunchkins();
    }
    // If game time is greater than potionSpawnTime
    if (game.time > game.potionSpawnTime) {
        player.say("The potion is here!");
        // Increase game.potionSpawnTime by 6:
        game.potionSpawnTime = game.potionSpawnTime + 6;
        // Call the spawnPotion function:
        spawnPotion();
    }
    // If game time is greater than throwerSpawnTime:
    if (game.time > game.throwerSpawnTime) 
        // Increase game.throwerSpawnTime by 9:
        game.throwerSpawnTime = game.throwerSpawnTime + 7;
        // Call the spawnThrowers function:
        spawnThrowers();
    // Update the UI timer until the next potion
    game.nextPotionIn = game.potionSpawnTime - game.time;
}
    
while (true) {
    updateTimers();
}

```

UPDATE: i redid my code but it still hasnt worked at all but i hope people can view it much more easier.

---

<div class="post-metadata">

**Author:** ![Luke10](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/luke10/32/19892_2.png) [@Luke10](https://discourse.codecombat.com/u/Luke10)\
**Post date:** [February 20, 2019, 9:10pm UTC](https://discourse.codecombat.com/t/web-development-2-level-teatime-help/17560/2 "2019-02-20T21:10:57Z")

</div>

> [@eri](#):
>
> ```python
> // This checks and updates timers.
> function updateTimers() {
> // If game time is greater than the munchkinSpawnTime
> if (game.time &gt; game.munchkinSpawnTime) {
> // Update the timer and spawn the munchkins.
> game.munchkinSpawnTime = game.munchkinSpawnTime + 6;
> spawnMunchkins();
> }
> // If game time is greater than potionSpawnTime
> if (game.time &gt; game.potionSpawnTime) {
> player.say(“The potion is here!”);
> // Increase game.potionSpawnTime by 6:
> game.potionSpawnTime = game.potionSpawnTime + 6;
> // Call the spawnPotion function:
> spawnPotion();
> }
> // If game time is greater than throwerSpawnTime:
> if (game.time &gt; game.throwerSpawnTime)
> // Increase game.throwerSpawnTime by 9:
> game.throwerSpawnTime = game.throwerSpawnTime + 7;
> // Call the spawnThrowers function:
> spawnThrowers();
> // Update the UI timer until the next potion
> game.nextPotionIn = game.potionSpawnTime - game.time;
> }
> 
> while (true) {
> updateTimers();
> }
> 
> ```

Alright so. I have only done a little bit of Web Development but I think what the issue is is that in the code that I quoted, you are spawning additional throwers. But you are also spawning them in the loop for your overall code.

---

<div class="post-metadata">

**Author:** ![eri](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eri/32/9845_2.png) [@eri](https://discourse.codecombat.com/u/eri)\
**Post date:** [March 6, 2019, 8:07pm UTC](https://discourse.codecombat.com/t/web-development-2-level-teatime-help/17560/3 "2019-03-06T20:07:00Z")

</div>

So how can I not make them go in a loop and not spawn so much? Because all I’m doing is putting in the code. I still need some help.

---

<div class="post-metadata">

**Author:** ![xython](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/xython/32/7269_2.png) [@xython](https://discourse.codecombat.com/u/xython)\
**Post date:** [March 7, 2019, 7:45am UTC](https://discourse.codecombat.com/t/web-development-2-level-teatime-help/17560/4 "2019-03-07T07:45:34Z")

</div>

You have missing braces:  
 ![braces](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/9/919ad410a83479f02f00d128b43a694eae9c56ef.jpeg)  
Put the braces and the required code after the fleshes. Don’t change the original code. You have too many editions in your first post and I cannot keep track of all of them.

---

<div class="post-metadata">

**Author:** ![Zayd\_Bari](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/zayd_bari/32/21837_2.png) [@Zayd\_Bari](https://discourse.codecombat.com/u/Zayd_Bari)\
**Post date:** [April 8, 2021, 6:55pm UTC](https://discourse.codecombat.com/t/web-development-2-level-teatime-help/17560/6 "2021-04-08T18:55:13Z")

</div>

it still spawns like a billion throwers either way

---

<div class="post-metadata">

**Author:** ![Anonym](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/anonym/32/47546_2.png) [@Anonym](https://discourse.codecombat.com/u/Anonym)\
**Post date:** [April 9, 2021, 11:22am UTC](https://discourse.codecombat.com/t/web-development-2-level-teatime-help/17560/7 "2021-04-09T11:22:40Z")

</div>

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review [this topic](https://discourse.codecombat.com/t/welcome-to-codecombat-discourse-forums/15601), which shows all essentials of this board! Thanks!

Hmm.This topic is not solved yet.You have any problems with this level?

---

<div class="post-metadata">

**Author:** ![397561](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/397561/32/33693_2.png) [@397561](https://discourse.codecombat.com/u/397561)\
**Post date:** [March 7, 2023, 3:06am UTC](https://discourse.codecombat.com/t/web-development-2-level-teatime-help/17560/8 "2023-03-07T03:06:54Z")

</div>

> [@eri](#):
>
> in a loop an

> [@eri](#):
>
> in a loop an

Can you please solve this and could you please put it in JavaScript.
