# Simplify these lines of code?

**URL:** <https://forum.makecode.com/t/simplify-these-lines-of-code/28966>\
**Category:** Help\
**Created:** [May 26, 2024, 9:03pm UTC](https://forum.makecode.com/t/simplify-these-lines-of-code/28966 "2024-05-26T21:03:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harmanuary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/harmanuary/32/21855_2.png) [@Harmanuary](https://forum.makecode.com/u/Harmanuary)\
**Post date:** [May 26, 2024, 9:03pm UTC](https://forum.makecode.com/t/simplify-these-lines-of-code/28966/1 "2024-05-26T21:03:53Z")

</div>

I’m not sure how I could simplify this to make it one line of code

 ![makecodehelp](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/5be274dd4fdc3bfd4b5587133849688193304d4e.png)

---

<div class="post-metadata">

**Author:** ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)\
**Post date:** [May 27, 2024, 1:22am UTC](https://forum.makecode.com/t/simplify-these-lines-of-code/28966/2 "2024-05-27T01:22:08Z")

</div>

Make a function, add a number parameter (type)  
if type = 0  
then make iron  
if type = 1  
then make gold  
the set wall and set empty can’t be in the function because location can’t be a parameter

---

<div class="post-metadata">

**Author:** ![Harmanuary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/harmanuary/32/21855_2.png) [@Harmanuary](https://forum.makecode.com/u/Harmanuary)\
**Post date:** [May 27, 2024, 6:45pm UTC](https://forum.makecode.com/t/simplify-these-lines-of-code/28966/3 "2024-05-27T18:45:08Z")

</div>

Ok i think i understand what you mean but could you visualize it for me? Thanks a lot

---

<div class="post-metadata">

**Author:** ![Harmanuary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/harmanuary/32/21855_2.png) [@Harmanuary](https://forum.makecode.com/u/Harmanuary)\
**Post date:** [May 29, 2024, 5:34pm UTC](https://forum.makecode.com/t/simplify-these-lines-of-code/28966/4 "2024-05-29T17:34:36Z")

</div>

I could send the link if you need

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [May 29, 2024, 5:55pm UTC](https://forum.makecode.com/t/simplify-these-lines-of-code/28966/5 "2024-05-29T17:55:00Z")

</div>

one way to combine the code for those two projectile events is to combine the tiles themselves and use the arcade-tile-util extension to make them _look_ different. the arcade-tile-util extension has several “cover tile” blocks that let you disguise one tile as a different one.

for example, take a look at this code:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/c/cd74dc2ea81cc8af234cc2edaeaccce62b893f82.png)

this game has four breakable tiles (each of the four colors). when the tilemap is loaded, i loop over each breakable tile and cover it with itself while replacing the tile _underneath_ with a different tile. then, i only need overlaps code for a single tile since they are all actually the same underneath.

also, in the overlaps code you need to clear the covered tile in addition to setting it to transparency. that’s the last line in that event block

here’s a link to that code:

> **[projectile-combine](https://arcade.makecode.com/S92764-26500-87764-91163)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![Harmanuary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/harmanuary/32/21855_2.png) [@Harmanuary](https://forum.makecode.com/u/Harmanuary)\
**Post date:** [May 29, 2024, 9:14pm UTC](https://forum.makecode.com/t/simplify-these-lines-of-code/28966/6 "2024-05-29T21:14:39Z")

</div>

Thank you, how though would i make them walls?

> **[ScarsShot V20 (Harmon's Beta)](https://arcade.makecode.com/S00166-31428-04300-69573)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [May 29, 2024, 9:18pm UTC](https://forum.makecode.com/t/simplify-these-lines-of-code/28966/7 "2024-05-29T21:18:01Z")

</div>

@Harmanuary if you want to do walls, swap the overlaps event with an “on hit wall” event and check the tile inside, like so:

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/d/dc6b40c6ec6f13b914febfcc6bf42c1720ba208a.png)

> **[projectile-combine-walls](https://arcade.makecode.com/96759-96207-78585-98267)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![Harmanuary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/harmanuary/32/21855_2.png) [@Harmanuary](https://forum.makecode.com/u/Harmanuary)\
**Post date:** [May 30, 2024, 5:24am UTC](https://forum.makecode.com/t/simplify-these-lines-of-code/28966/8 "2024-05-30T05:24:06Z")

</div>

ive tried to drag the scene block that is the tile but it isn’t working

---

<div class="post-metadata">

**Author:** ![Harmanuary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/harmanuary/32/21855_2.png) [@Harmanuary](https://forum.makecode.com/u/Harmanuary)\
**Post date:** [May 30, 2024, 5:25am UTC](https://forum.makecode.com/t/simplify-these-lines-of-code/28966/9 "2024-05-30T05:25:38Z")

</div>

the ones in the array chain
